Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,11 @@ def generate_minecraft_command(minecraft_version, description=""):
|
|
16 |
}
|
17 |
|
18 |
response = requests.post(os.getenv("BASE_URL"), headers=headers, json=payload)
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
|
21 |
if 'choices' in data and len(data['choices']) > 0:
|
22 |
command = data['choices'][0]['message']['content'].strip()
|
@@ -43,4 +47,4 @@ iface = gr.Interface(fn=generate_minecraft_command, inputs=[
|
|
43 |
gr.Textbox(label="Версия Minecraft", placeholder="Minecraft Java 1.20"),
|
44 |
gr.Textbox(label="Описание команды")
|
45 |
], outputs=gr.Textbox(label="Команда"), examples=examples, title="Minecraft Command Generator")
|
46 |
-
iface.launch()
|
|
|
16 |
}
|
17 |
|
18 |
response = requests.post(os.getenv("BASE_URL"), headers=headers, json=payload)
|
19 |
+
|
20 |
+
try:
|
21 |
+
data = response.json()
|
22 |
+
except json.decoder.JSONDecodeError as e:
|
23 |
+
return f'Ошибка при декодировании JSON: {str(e)}'
|
24 |
|
25 |
if 'choices' in data and len(data['choices']) > 0:
|
26 |
command = data['choices'][0]['message']['content'].strip()
|
|
|
47 |
gr.Textbox(label="Версия Minecraft", placeholder="Minecraft Java 1.20"),
|
48 |
gr.Textbox(label="Описание команды")
|
49 |
], outputs=gr.Textbox(label="Команда"), examples=examples, title="Minecraft Command Generator")
|
50 |
+
iface.launch()
|