Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -78,7 +78,19 @@ def generate_standard_prompt(description, advantages, *selected_values):
|
|
78 |
# Функции для генерации сообщений
|
79 |
def generate_message_gpt4o(prompt, temperature=1):
|
80 |
try:
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
except Exception as e:
|
83 |
return f"Ошибка при обращении к ChatGPT-4o-Latest: {e}"
|
84 |
|
|
|
78 |
# Функции для генерации сообщений
|
79 |
def generate_message_gpt4o(prompt, temperature=1):
|
80 |
try:
|
81 |
+
headers = {
|
82 |
+
"Content-Type": "application/json",
|
83 |
+
"Authorization": f"Bearer {openai_api_key}"
|
84 |
+
}
|
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 |
+
return clean_message(response_data["choices"][0]["message"]["content"].strip()) + f" {temperature}"
|
94 |
except Exception as e:
|
95 |
return f"Ошибка при обращении к ChatGPT-4o-Latest: {e}"
|
96 |
|