Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,14 +17,15 @@ def generate_minecraft_command(description):
|
|
| 17 |
|
| 18 |
response = requests.post(os.getenv("BASE_URL"), headers=headers, json=payload)
|
| 19 |
data = json.loads(response.text)
|
|
|
|
| 20 |
if 'choices' in data and len(data['choices']) > 0:
|
| 21 |
command = data['choices'][0]['text'].strip()
|
| 22 |
return command
|
| 23 |
elif 'error' in data:
|
| 24 |
-
error_message = data['error']
|
| 25 |
return f'Ошибка: {error_message}'
|
| 26 |
else:
|
| 27 |
-
return 'Не удалось сгенерировать команду для Minecraft.'
|
| 28 |
|
| 29 |
iface = gr.Interface(fn=generate_minecraft_command, inputs="text", outputs="text", title="Minecraft Command Generator")
|
| 30 |
iface.launch()
|
|
|
|
| 17 |
|
| 18 |
response = requests.post(os.getenv("BASE_URL"), headers=headers, json=payload)
|
| 19 |
data = json.loads(response.text)
|
| 20 |
+
|
| 21 |
if 'choices' in data and len(data['choices']) > 0:
|
| 22 |
command = data['choices'][0]['text'].strip()
|
| 23 |
return command
|
| 24 |
elif 'error' in data:
|
| 25 |
+
error_message = data['error']['message']
|
| 26 |
return f'Ошибка: {error_message}'
|
| 27 |
else:
|
| 28 |
+
return f'Не удалось сгенерировать команду для Minecraft. Причина: {data}'
|
| 29 |
|
| 30 |
iface = gr.Interface(fn=generate_minecraft_command, inputs="text", outputs="text", title="Minecraft Command Generator")
|
| 31 |
iface.launch()
|