Spaces:
Sleeping
Sleeping
works
Browse files- src/app.py +12 -14
src/app.py
CHANGED
|
@@ -1,9 +1,18 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
-
from llama_index.
|
| 4 |
-
from
|
|
|
|
| 5 |
import json
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# --- System prompt ---
|
| 8 |
SYSTEM_PROMPT = """
|
| 9 |
You are a medical assistant helping a user narrow down to the most likely ICD-10 code.
|
|
@@ -47,20 +56,9 @@ with gr.Blocks() as demo:
|
|
| 47 |
|
| 48 |
microphone = gr.Microphone(
|
| 49 |
streaming=True,
|
| 50 |
-
type="filepath" #
|
| 51 |
)
|
| 52 |
|
| 53 |
-
# MCP metadata (store in a separate variable, not as an attribute of demo)
|
| 54 |
-
mcp_metadata = {
|
| 55 |
-
"title": "Medical Symptom to ICD-10 Code Assistant",
|
| 56 |
-
"description": "Convert spoken symptoms to ICD-10 codes",
|
| 57 |
-
"version": "1.0.0",
|
| 58 |
-
"capabilities": {
|
| 59 |
-
"speech_input": True,
|
| 60 |
-
"streaming": True
|
| 61 |
-
}
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
# Connect the streaming microphone to the chat
|
| 65 |
microphone.stream(
|
| 66 |
fn=process_speech,
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
+
from llama_index.core import Settings
|
| 4 |
+
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
| 5 |
+
from parse_tabular import create_symptom_index # Change this import
|
| 6 |
import json
|
| 7 |
|
| 8 |
+
# Configure embeddings globally
|
| 9 |
+
Settings.embed_model = HuggingFaceEmbedding(
|
| 10 |
+
model_name="sentence-transformers/all-MiniLM-L6-v2"
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
# Create the index at startup
|
| 14 |
+
symptom_index = create_symptom_index()
|
| 15 |
+
|
| 16 |
# --- System prompt ---
|
| 17 |
SYSTEM_PROMPT = """
|
| 18 |
You are a medical assistant helping a user narrow down to the most likely ICD-10 code.
|
|
|
|
| 56 |
|
| 57 |
microphone = gr.Microphone(
|
| 58 |
streaming=True,
|
| 59 |
+
type="filepath" # Use 'filepath' to get the path to the recorded audio file
|
| 60 |
)
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
# Connect the streaming microphone to the chat
|
| 63 |
microphone.stream(
|
| 64 |
fn=process_speech,
|