Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,11 +8,12 @@ openai.api_key = os.environ.get("OPENAI_API_KEY")
|
|
8 |
# Основная функция общения с ChatGPT
|
9 |
def chatgpt_prompt(prompt):
|
10 |
try:
|
11 |
-
|
|
|
12 |
model="gpt-3.5-turbo",
|
13 |
messages=[{"role": "user", "content": prompt}]
|
14 |
)
|
15 |
-
return response
|
16 |
except Exception as e:
|
17 |
return f"Ошибка ChatGPT: {str(e)}"
|
18 |
|
|
|
8 |
# Основная функция общения с ChatGPT
|
9 |
def chatgpt_prompt(prompt):
|
10 |
try:
|
11 |
+
client = openai.OpenAI(api_key=openai.api_key)
|
12 |
+
response = client.chat.completions.create(
|
13 |
model="gpt-3.5-turbo",
|
14 |
messages=[{"role": "user", "content": prompt}]
|
15 |
)
|
16 |
+
return response.choices[0].message.content
|
17 |
except Exception as e:
|
18 |
return f"Ошибка ChatGPT: {str(e)}"
|
19 |
|