Rooni commited on
Commit
18f89c2
1 Parent(s): 11a17ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -10,7 +10,7 @@ def generate_minecraft_command(description):
10
  }
11
 
12
  payload = {
13
- 'prompt': f'Напиши пожалуйста команду для Minecraft JAVA 1.20, под описание: "{description}"',
14
  'max_tokens': 500,
15
  'model': 'gpt-3.5-turbo'
16
  }
@@ -19,13 +19,13 @@ def generate_minecraft_command(description):
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'Не удалось сгенерировать команду. {data}'
29
 
30
  iface = gr.Interface(fn=generate_minecraft_command, inputs="text", outputs="text", title="Minecraft Command Generator")
31
- iface.launch()
 
10
  }
11
 
12
  payload = {
13
+ 'messages': [{'role': 'system', 'content': f'Generate Minecraft command for description: {description}'}],
14
  'max_tokens': 500,
15
  'model': 'gpt-3.5-turbo'
16
  }
 
19
  data = json.loads(response.text)
20
 
21
  if 'choices' in data and len(data['choices']) > 0:
22
+ command = data['choices'][0]['message']['content'].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()