Spaces:
Runtime error
Runtime error
import streamlit as st | |
from langchain.prompts.few_shot import FewShotChatMessagePromptTemplate | |
from langchain.prompts.example_selector import LengthBasedExampleSelector | |
# Example dialogues + summaries | |
examples = [ | |
{ | |
"input": "Doctor: What symptoms are you experiencing?\nPatient: I have a sore throat and runny nose.", | |
"output": "The patient reports sore throat and runny nose." | |
}, | |
{ | |
"input": "Patient: I've been feeling dizzy since morning.\nDoctor: Did you eat anything unusual?\nPatient: No, just normal food.", | |
"output": "The patient has dizziness but no unusual food intake." | |
} | |
] | |
# Create Few-Shot Prompt Template | |
prompt = FewShotChatMessagePromptTemplate.from_examples( | |
examples=examples, | |
example_selector=LengthBasedExampleSelector(examples=examples, max_length=100), | |
input_variables=["input"], | |
prefix="You are a medical assistant that summarizes doctor-patient conversations. Examples:", | |
suffix="Now summarize this conversation:\n{input}" | |
) | |
# Streamlit UI | |
st.title("π¬ Few-Shot Summarizer (No Model)") | |
input_text = st.text_area("Paste your medical conversation here:") | |
if st.button("Generate Prompt"): | |
if input_text.strip(): | |
messages = prompt.format_messages(input=input_text) | |
st.subheader("π Prompt Generated:") | |
for msg in messages: | |
st.markdown(f"**{msg.type.upper()}**:\n```\n{msg.content}\n```") | |
st.info("β οΈ This is just a prompt, not an actual summary.") | |
else: | |
st.warning("Please enter some conversation text.") | |