Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -155,15 +155,16 @@ def get_ai_text_response(provider, model_name, system_instruction, user_prompt,
|
|
| 155 |
full_model_name = f'models/{model_name}'
|
| 156 |
model = genai_client.GenerativeModel(full_model_name, system_instruction=system_instruction)
|
| 157 |
|
| 158 |
-
# CORRE脟脙O:
|
| 159 |
-
|
|
|
|
| 160 |
if json_schema:
|
| 161 |
-
|
| 162 |
-
response_mime_type
|
| 163 |
-
response_schema
|
| 164 |
-
|
| 165 |
|
| 166 |
-
response = model.generate_content(user_prompt, generation_config=
|
| 167 |
return json.loads(response.text) if json_schema else response.text
|
| 168 |
|
| 169 |
elif provider == 'groq':
|
|
|
|
| 155 |
full_model_name = f'models/{model_name}'
|
| 156 |
model = genai_client.GenerativeModel(full_model_name, system_instruction=system_instruction)
|
| 157 |
|
| 158 |
+
# CORRE脟脙O DEFINITIVA: O `generation_config` deve ser um dicion谩rio simples.
|
| 159 |
+
# O uso do `genai.types.GenerationConfig` estava causando o erro de inicializa莽茫o.
|
| 160 |
+
config = {}
|
| 161 |
if json_schema:
|
| 162 |
+
config = {
|
| 163 |
+
"response_mime_type": "application/json",
|
| 164 |
+
"response_schema": json_schema
|
| 165 |
+
}
|
| 166 |
|
| 167 |
+
response = model.generate_content(user_prompt, generation_config=config)
|
| 168 |
return json.loads(response.text) if json_schema else response.text
|
| 169 |
|
| 170 |
elif provider == 'groq':
|