enotkrutoy commited on
Commit
a638203
·
verified ·
1 Parent(s): 8025603

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -72,17 +72,14 @@ for ($i = 0; $i -lt 10; $i++) {
72
  { "role": "user", "content": f"Вот код для проверки: {message}" }
73
  ]
74
  }
75
-
76
- # Set the headers including your API key
77
  headers = {
78
  "Content-Type": "application/json",
79
  "Authorization": "Bearer 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" # Replace with your API key
80
  }
81
-
82
  try:
83
  # Make the POST request to the Groq API
84
  response = requests.post("https://api.groq.com/openai/v1/chat/completions", headers=headers, data=json.dumps(payload))
85
-
86
  # Check if the request was successful
87
  if response.status_code == 200:
88
  data = response.json()
@@ -91,18 +88,17 @@ for ($i = 0; $i -lt 10; $i++) {
91
  return f"Error: {response.status_code}, {response.text}"
92
  except requests.exceptions.RequestException as e:
93
  return f"Error: {e}"
94
-
95
  # Set up Gradio interface
96
  gr.Interface(
97
  fn=chat_function, # Function that handles the chatbot
98
- inputs=gr.Textbox(placeholder="Введите код для проверки..."), # Input for user message
99
  outputs="text", # Output as text
100
  title="Groq-Gradio Chat", # Title of the interface
101
- theme="compact", # Using a valid theme
102
  examples=[
103
- "Исправьте ошибку в коде на Python:",
104
- "Исправьте цикл в PowerShell:",
105
- "Нужна обработка исключений в Python:"
 
106
  ]
107
  ).launch()
108
-
 
72
  { "role": "user", "content": f"Вот код для проверки: {message}" }
73
  ]
74
  }
75
+ # Set the headers including your API key
 
76
  headers = {
77
  "Content-Type": "application/json",
78
  "Authorization": "Bearer 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" # Replace with your API key
79
  }
 
80
  try:
81
  # Make the POST request to the Groq API
82
  response = requests.post("https://api.groq.com/openai/v1/chat/completions", headers=headers, data=json.dumps(payload))
 
83
  # Check if the request was successful
84
  if response.status_code == 200:
85
  data = response.json()
 
88
  return f"Error: {response.status_code}, {response.text}"
89
  except requests.exceptions.RequestException as e:
90
  return f"Error: {e}"
 
91
  # Set up Gradio interface
92
  gr.Interface(
93
  fn=chat_function, # Function that handles the chatbot
94
+ inputs=gr.Textbox(placeholder="Ask 🐇🐇🐇..."), # Input for user message
95
  outputs="text", # Output as text
96
  title="Groq-Gradio Chat", # Title of the interface
97
+ theme="upsatwal/mlsc_tiet", # Ensure theme is valid
98
  examples=[
99
+ "Исправьте PowerShell-скрипт:",
100
+ "##PYTHON",
101
+ "ПРОГНОЗ РЕЗУЛЬТАТА?",
102
+ "##НУЖЕН ВЕТЕР"
103
  ]
104
  ).launch()