Spaces:
Runtime error
Runtime error
lionelgarnier
commited on
Commit
·
16d258e
1
Parent(s):
69e268f
message assistent content
Browse files
app.py
CHANGED
@@ -61,9 +61,15 @@ def refine_prompt(prompt):
|
|
61 |
{"role": "user", "content": prompt},
|
62 |
]
|
63 |
refined_prompt = text_gen(messages)
|
|
|
64 |
# Extract just the assistant's content from the response
|
65 |
try:
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
67 |
return assistant_content
|
68 |
except (KeyError, IndexError):
|
69 |
return "Error: Unexpected response format from the model"
|
|
|
61 |
{"role": "user", "content": prompt},
|
62 |
]
|
63 |
refined_prompt = text_gen(messages)
|
64 |
+
|
65 |
# Extract just the assistant's content from the response
|
66 |
try:
|
67 |
+
messages = refined_prompt[0]['generated_text']
|
68 |
+
# Find the last message with role 'assistant'
|
69 |
+
assistant_messages = [msg for msg in messages if msg['role'] == 'assistant']
|
70 |
+
if not assistant_messages:
|
71 |
+
return "Error: No assistant response found"
|
72 |
+
assistant_content = assistant_messages[-1]['content']
|
73 |
return assistant_content
|
74 |
except (KeyError, IndexError):
|
75 |
return "Error: Unexpected response format from the model"
|