Spaces:
Sleeping
Sleeping
file added
Browse files
app.py
CHANGED
@@ -234,8 +234,7 @@ def customLLMBot(user_input, uploaded_image, chat_history):
|
|
234 |
medical_entities = extract_medical_entities(user_input)
|
235 |
logger.info(f"Extracted medical entities: {medical_entities}")
|
236 |
|
237 |
-
|
238 |
-
chat_history.append(user_input)
|
239 |
|
240 |
if uploaded_image is not None:
|
241 |
base64_image = encode_image(uploaded_image)
|
@@ -272,8 +271,7 @@ def customLLMBot(user_input, uploaded_image, chat_history):
|
|
272 |
LLM_reply = response.choices[0].message.content
|
273 |
logger.debug(f"LLM reply: {LLM_reply}")
|
274 |
|
275 |
-
|
276 |
-
chat_history.append(LLM_reply)
|
277 |
messages.append({"role": "assistant", "content": LLM_reply})
|
278 |
|
279 |
audio_file = f"response_{uuid.uuid4().hex}.mp3"
|
@@ -285,8 +283,8 @@ def customLLMBot(user_input, uploaded_image, chat_history):
|
|
285 |
|
286 |
except Exception as e:
|
287 |
logger.error(f"Error in customLLMBot function: {e}")
|
288 |
-
return [user_input or "Image uploaded", f"An error occurred: {e}"], None
|
289 |
-
|
290 |
# Gradio Interface
|
291 |
def chatbot_ui():
|
292 |
logger.info("Setting up Gradio interface...")
|
|
|
234 |
medical_entities = extract_medical_entities(user_input)
|
235 |
logger.info(f"Extracted medical entities: {medical_entities}")
|
236 |
|
237 |
+
chat_history.append(("user", user_input))
|
|
|
238 |
|
239 |
if uploaded_image is not None:
|
240 |
base64_image = encode_image(uploaded_image)
|
|
|
271 |
LLM_reply = response.choices[0].message.content
|
272 |
logger.debug(f"LLM reply: {LLM_reply}")
|
273 |
|
274 |
+
chat_history.append(("bot", LLM_reply))
|
|
|
275 |
messages.append({"role": "assistant", "content": LLM_reply})
|
276 |
|
277 |
audio_file = f"response_{uuid.uuid4().hex}.mp3"
|
|
|
283 |
|
284 |
except Exception as e:
|
285 |
logger.error(f"Error in customLLMBot function: {e}")
|
286 |
+
return [("user", user_input or "Image uploaded"), ("bot", f"An error occurred: {e}")], None
|
287 |
+
|
288 |
# Gradio Interface
|
289 |
def chatbot_ui():
|
290 |
logger.info("Setting up Gradio interface...")
|