Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,25 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
|
|
3 |
|
4 |
-
def
|
5 |
-
url = "https://copilot.github1s.tk/"
|
6 |
headers = {
|
7 |
-
|
8 |
-
|
9 |
}
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
"model": "gpt-3.5-turbo"
|
15 |
}
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
19 |
else:
|
20 |
-
return
|
21 |
|
22 |
-
iface = gr.Interface(fn=
|
23 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
+
import json
|
4 |
|
5 |
+
def generate_minecraft_command(description):
|
|
|
6 |
headers = {
|
7 |
+
'Content-Type': 'application/json',
|
8 |
+
'Authorization': 'Bearer dummy'
|
9 |
}
|
10 |
+
|
11 |
+
payload = {
|
12 |
+
'prompt': f'Напиши пожалуйста команду для Minecraft JAVA 1.20, под описание: "{description}"',
|
13 |
+
'max_tokens': 500
|
|
|
14 |
}
|
15 |
+
|
16 |
+
response = requests.post('https://copilot.github1s.tk/', headers=headers, json=payload)
|
17 |
+
data = json.loads(response.text)
|
18 |
+
if 'choices' in data and len(data['choices']) > 0:
|
19 |
+
command = data['choices'][0]['text'].strip()
|
20 |
+
return command
|
21 |
else:
|
22 |
+
return 'Не удалось сгенерировать команду для Minecraft.'
|
23 |
|
24 |
+
iface = gr.Interface(fn=generate_minecraft_command, inputs="text", outputs="text", title="Minecraft Command Generator")
|
25 |
iface.launch()
|