Kackle commited on
Commit
99a8618
·
verified ·
1 Parent(s): 6a5b033

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -84,6 +84,12 @@ class GeminiModelAdapter:
84
  kwargs.pop('stop_sequences', None) # Remove unsupported argument for Gemini
85
  result = self.model.generate_content(*args, **kwargs)
86
  print(f"[DEBUG] Gemini raw result type: {type(result)}; value: {result}")
 
 
 
 
 
 
87
  # Try all known ways to extract text
88
  if hasattr(result, "text"):
89
  print(f"[DEBUG] Gemini .text: {result.text}")
 
84
  kwargs.pop('stop_sequences', None) # Remove unsupported argument for Gemini
85
  result = self.model.generate_content(*args, **kwargs)
86
  print(f"[DEBUG] Gemini raw result type: {type(result)}; value: {result}")
87
+ # ChatMessage extraction
88
+ if type(result).__name__ == "ChatMessage" and hasattr(result, "content"):
89
+ content = result.content
90
+ if isinstance(content, list) and content and isinstance(content[0], dict) and "text" in content[0]:
91
+ print(f"[DEBUG] Gemini ChatMessage .content[0]['text']: {content[0]['text']}")
92
+ return content[0]["text"]
93
  # Try all known ways to extract text
94
  if hasattr(result, "text"):
95
  print(f"[DEBUG] Gemini .text: {result.text}")