saa231 commited on
Commit
2826fcf
·
verified ·
1 Parent(s): efcbc16

Update project_model.py

Browse files
Files changed (1) hide show
  1. project_model.py +16 -1
project_model.py CHANGED
@@ -198,8 +198,23 @@ def process_inputs(
198
  # Send prompt to Gemma 3
199
  gemma_output = gemma_pipe(text=session.message_history, max_new_tokens=200)
200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
 
202
- answer = gemma_output[0]["generated_text"][-1]["content"]
203
 
204
  # Append GEMMA's response to the history to maintain alternating structure
205
  session.add_answer(answer)
 
198
  # Send prompt to Gemma 3
199
  gemma_output = gemma_pipe(text=session.message_history, max_new_tokens=200)
200
 
201
+ # Debugging: Check the output structure
202
+ print("Gemma Output:", gemma_output)
203
+ print("Type of Gemma Output:", type(gemma_output))
204
+
205
+ # Make sure the output is in the expected format (a string)
206
+ if isinstance(gemma_output, list) and len(gemma_output) > 0:
207
+ # Assuming it's a list of dicts with the 'generated_text' field
208
+ gemma_text = gemma_output[0].get("generated_text", "")
209
+ if isinstance(gemma_text, str):
210
+ answer = gemma_text
211
+ else:
212
+ # Handle unexpected formats or empty text
213
+ answer = "No valid generated text found."
214
+ else:
215
+ answer = "No valid output from Gemma model"
216
 
217
+ # answer = gemma_output[0]["generated_text"][-1]["content"]
218
 
219
  # Append GEMMA's response to the history to maintain alternating structure
220
  session.add_answer(answer)