noumanjavaid commited on
Commit
4afb504
·
verified ·
1 Parent(s): d6a8d5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -20,6 +20,7 @@ import websockets.exceptions
20
 
21
  from google import genai
22
  from google.genai import types
 
23
 
24
  from streamlit_webrtc import (
25
  webrtc_streamer,
@@ -165,8 +166,9 @@ class GeminiInteractionLoop:
165
  return
166
  try:
167
  logging.info(f"Sending text to Gemini: '{user_text[:50]}...'")
168
- # Send text using input parameter format
169
- await self.gemini_session.send(input={"text": user_text})
 
170
  except Exception as e:
171
  logging.error(
172
  f"Error sending text message to Gemini: {e}", exc_info=True)
@@ -433,8 +435,9 @@ class GeminiInteractionLoop:
433
  f"Gemini session established with API for model {MODEL_NAME}.")
434
  try:
435
  logging.info("Sending system prompt to Gemini...")
436
- # Send system prompt using input parameter format
437
- await self.gemini_session.send(input={"text": MEDICAL_ASSISTANT_SYSTEM_PROMPT})
 
438
  logging.info("System prompt sent successfully.")
439
  except Exception as e:
440
  logging.error(
 
20
 
21
  from google import genai
22
  from google.genai import types
23
+ from google.genai.types import Content, Part
24
 
25
  from streamlit_webrtc import (
26
  webrtc_streamer,
 
166
  return
167
  try:
168
  logging.info(f"Sending text to Gemini: '{user_text[:50]}...'")
169
+ # Use send_client_content as specified in the error message
170
+ content = Content(parts=[Part(text=user_text)])
171
+ await self.gemini_session.send_client_content(content)
172
  except Exception as e:
173
  logging.error(
174
  f"Error sending text message to Gemini: {e}", exc_info=True)
 
435
  f"Gemini session established with API for model {MODEL_NAME}.")
436
  try:
437
  logging.info("Sending system prompt to Gemini...")
438
+ # Use send_client_content with proper format
439
+ content = Content(parts=[Part(text=MEDICAL_ASSISTANT_SYSTEM_PROMPT)])
440
+ await self.gemini_session.send_client_content(content)
441
  logging.info("System prompt sent successfully.")
442
  except Exception as e:
443
  logging.error(