Spaces:
Running
Running
interactive questioning enhancement
Browse files- src/app.py +13 -10
src/app.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2 |
import gradio as gr
|
3 |
from llama_index.llms.huggingface import HuggingFaceLLM
|
4 |
from parse_tabular import symptom_index
|
|
|
5 |
|
6 |
# --- System prompt ---
|
7 |
SYSTEM_PROMPT = """
|
@@ -16,19 +17,21 @@ def process_speech(new_transcript, history):
|
|
16 |
if not new_transcript:
|
17 |
return history
|
18 |
|
19 |
-
# Build
|
20 |
-
|
21 |
|
22 |
-
# Query index
|
23 |
-
|
24 |
-
prompt += f"\nuser: {new_transcript}"
|
25 |
|
26 |
-
response
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
29 |
|
30 |
-
# Append
|
31 |
-
history.append((new_transcript,
|
32 |
return history
|
33 |
|
34 |
# Build Gradio interface
|
|
|
2 |
import gradio as gr
|
3 |
from llama_index.llms.huggingface import HuggingFaceLLM
|
4 |
from parse_tabular import symptom_index
|
5 |
+
import json
|
6 |
|
7 |
# --- System prompt ---
|
8 |
SYSTEM_PROMPT = """
|
|
|
17 |
if not new_transcript:
|
18 |
return history
|
19 |
|
20 |
+
# Build conversation context
|
21 |
+
context = "\n".join([f"{role}: {msg}" for role, msg in history])
|
22 |
|
23 |
+
# Query symptom index for relevant codes
|
24 |
+
response = symptom_index.as_query_engine().query(new_transcript)
|
|
|
25 |
|
26 |
+
# Format response as structured JSON
|
27 |
+
formatted_response = {
|
28 |
+
"diagnoses": [str(response).split(":")[0]], # Extract ICD code
|
29 |
+
"confidences": [0.8], # Add confidence scoring
|
30 |
+
"follow_up": "Is the cough productive or dry?" # Add interactive questioning
|
31 |
+
}
|
32 |
|
33 |
+
# Append exchange to history
|
34 |
+
history.append((new_transcript, json.dumps(formatted_response, indent=2)))
|
35 |
return history
|
36 |
|
37 |
# Build Gradio interface
|