zoya23 commited on
Commit
52d4ec9
·
verified ·
1 Parent(s): 36a55d1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain.prompts.few_shot import FewShotChatMessagePromptTemplate
3
+ from langchain.prompts.example_selector import LengthBasedExampleSelector
4
+
5
+ # Example dialogues + summaries
6
+ examples = [
7
+ {
8
+ "input": "Doctor: What symptoms are you experiencing?\nPatient: I have a sore throat and runny nose.",
9
+ "output": "The patient reports sore throat and runny nose."
10
+ },
11
+ {
12
+ "input": "Patient: I've been feeling dizzy since morning.\nDoctor: Did you eat anything unusual?\nPatient: No, just normal food.",
13
+ "output": "The patient has dizziness but no unusual food intake."
14
+ }
15
+ ]
16
+
17
+ # Create Few-Shot Prompt Template
18
+ prompt = FewShotChatMessagePromptTemplate.from_examples(
19
+ examples=examples,
20
+ example_selector=LengthBasedExampleSelector(examples=examples, max_length=100),
21
+ input_variables=["input"],
22
+ prefix="You are a medical assistant that summarizes doctor-patient conversations. Examples:",
23
+ suffix="Now summarize this conversation:\n{input}"
24
+ )
25
+
26
+ # Streamlit UI
27
+ st.title("💬 Few-Shot Summarizer (No Model)")
28
+
29
+ input_text = st.text_area("Paste your medical conversation here:")
30
+
31
+ if st.button("Generate Prompt"):
32
+ if input_text.strip():
33
+ messages = prompt.format_messages(input=input_text)
34
+
35
+ st.subheader("📋 Prompt Generated:")
36
+ for msg in messages:
37
+ st.markdown(f"**{msg.type.upper()}**:\n```\n{msg.content}\n```")
38
+
39
+ st.info("⚠️ This is just a prompt, not an actual summary.")
40
+ else:
41
+ st.warning("Please enter some conversation text.")