Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -85,12 +85,13 @@ def generate_message_gpt4o(prompt, temperature):
|
|
85 |
data = {
|
86 |
"model": "chatgpt-4o-latest",
|
87 |
"messages": [{"role": "system", "content": prompt}],
|
88 |
-
"max_tokens": 101,
|
89 |
-
"temperature": temperature #
|
90 |
}
|
91 |
response = requests.post("https://api.openai.com/v1/chat/completions", json=data, headers=headers)
|
92 |
response_data = response.json()
|
93 |
-
|
|
|
94 |
except Exception as e:
|
95 |
return f"Ошибка при обращении к ChatGPT-4o-Latest: {e}"
|
96 |
|
|
|
85 |
data = {
|
86 |
"model": "chatgpt-4o-latest",
|
87 |
"messages": [{"role": "system", "content": prompt}],
|
88 |
+
"max_tokens": 101, # Значение max_tokens можно зафиксировать, если не нужно передавать его
|
89 |
+
"temperature": temperature # Используем переданное значение температуры
|
90 |
}
|
91 |
response = requests.post("https://api.openai.com/v1/chat/completions", json=data, headers=headers)
|
92 |
response_data = response.json()
|
93 |
+
message = response_data["choices"][0]["message"]["content"].strip()
|
94 |
+
return clean_message(message)
|
95 |
except Exception as e:
|
96 |
return f"Ошибка при обращении к ChatGPT-4o-Latest: {e}"
|
97 |
|