Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +11 -3
src/streamlit_app.py
CHANGED
|
@@ -28,7 +28,9 @@ from datasets import load_dataset, get_dataset_split_names
|
|
| 28 |
from PIL import Image
|
| 29 |
import openai
|
| 30 |
import comet_llm
|
| 31 |
-
from
|
|
|
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
|
|
@@ -109,7 +111,13 @@ st.title("🩺 Multimodal Medical Chatbot")
|
|
| 109 |
query = st.text_input("Enter your medical question or symptom description:")
|
| 110 |
uploaded_file = st.file_uploader("Upload an image to find similar medical cases:", type=["png", "jpg", "jpeg"])
|
| 111 |
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
def get_chat_completion_openai(client, prompt: str):
|
| 114 |
return client.chat.completions.create(
|
| 115 |
model="gpt-4o", # or "gpt-4" if you need the older GPT-4
|
|
@@ -118,7 +126,7 @@ def get_chat_completion_openai(client, prompt: str):
|
|
| 118 |
max_tokens=150
|
| 119 |
)
|
| 120 |
|
| 121 |
-
@
|
| 122 |
def get_similar_prompt(query):
|
| 123 |
text_embeddings = embed_dataset_texts(combined_texts) # cached
|
| 124 |
query_embedding = embed_query_text(query) # recalculated each time
|
|
|
|
| 28 |
from PIL import Image
|
| 29 |
import openai
|
| 30 |
import comet_llm
|
| 31 |
+
from functools import wraps
|
| 32 |
+
from opik import track as opik_track
|
| 33 |
+
|
| 34 |
|
| 35 |
|
| 36 |
|
|
|
|
| 111 |
query = st.text_input("Enter your medical question or symptom description:")
|
| 112 |
uploaded_file = st.file_uploader("Upload an image to find similar medical cases:", type=["png", "jpg", "jpeg"])
|
| 113 |
|
| 114 |
+
def safe_track(func):
|
| 115 |
+
@wraps(func)
|
| 116 |
+
def wrapper(*args, **kwargs):
|
| 117 |
+
return opik_track(func)(*args, **kwargs)
|
| 118 |
+
return wrapper
|
| 119 |
+
|
| 120 |
+
@safe_track
|
| 121 |
def get_chat_completion_openai(client, prompt: str):
|
| 122 |
return client.chat.completions.create(
|
| 123 |
model="gpt-4o", # or "gpt-4" if you need the older GPT-4
|
|
|
|
| 126 |
max_tokens=150
|
| 127 |
)
|
| 128 |
|
| 129 |
+
@safe_track
|
| 130 |
def get_similar_prompt(query):
|
| 131 |
text_embeddings = embed_dataset_texts(combined_texts) # cached
|
| 132 |
query_embedding = embed_query_text(query) # recalculated each time
|