Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,38 +30,21 @@ def call_groq_api(prompt, model="llama3-70b-8192"):
|
|
| 30 |
else:
|
| 31 |
return f"[Groq API Error] {response.text}"
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
url = "https://api.code.blackbox.ai/v1/chat/completions"
|
| 49 |
-
headers = {
|
| 50 |
-
"Content-Type": "application/json",
|
| 51 |
-
"Authorization": f"Bearer {BLACKBOX_API_KEY}"
|
| 52 |
-
}
|
| 53 |
-
data = {
|
| 54 |
-
"model": "code-chat",
|
| 55 |
-
"messages": [
|
| 56 |
-
{"role": "system", "content": "You are a helpful coding assistant."},
|
| 57 |
-
{"role": "user", "content": prompt}
|
| 58 |
-
]
|
| 59 |
-
}
|
| 60 |
-
response = requests.post(url, headers=headers, json=data)
|
| 61 |
-
if response.status_code == 200:
|
| 62 |
-
return response.json()["choices"][0]["message"]["content"]
|
| 63 |
-
# else:
|
| 64 |
-
# return call_groq_api(prompt)
|
| 65 |
|
| 66 |
|
| 67 |
# --- UTILS ---
|
|
|
|
| 30 |
else:
|
| 31 |
return f"[Groq API Error] {response.text}"
|
| 32 |
|
| 33 |
+
def call_blackbox_agent(prompt):
|
| 34 |
+
url = "https://api.code.blackbox.ai/v1/chat/completions"
|
| 35 |
+
headers = {
|
| 36 |
+
"Content-Type": "application/json",
|
| 37 |
+
"Authorization": f"Bearer {BLACKBOX_API_KEY}"
|
| 38 |
+
}
|
| 39 |
+
data = {
|
| 40 |
+
"message": prompt
|
| 41 |
+
}
|
| 42 |
+
response = requests.post(url, headers=headers, json=data)
|
| 43 |
+
if response.status_code == 200:
|
| 44 |
+
return response.json().get("response", response.json())
|
| 45 |
+
else:
|
| 46 |
+
return call_groq_api(prompt)
|
| 47 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
# --- UTILS ---
|