Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,6 +30,20 @@ def call_groq_api(prompt, model="llama3-70b-8192"):
|
|
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 = {
|
@@ -37,13 +51,18 @@ def call_blackbox_agent(prompt):
|
|
37 |
"Authorization": f"Bearer {BLACKBOX_API_KEY}"
|
38 |
}
|
39 |
data = {
|
40 |
-
"
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
response = requests.post(url, headers=headers, json=data)
|
43 |
if response.status_code == 200:
|
44 |
-
return response.json()
|
45 |
-
#else:
|
46 |
-
|
|
|
47 |
|
48 |
# --- UTILS ---
|
49 |
def code_matches_language(code, language):
|
|
|
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 |
def call_blackbox_agent(prompt):
|
48 |
url = "https://api.code.blackbox.ai/v1/chat/completions"
|
49 |
headers = {
|
|
|
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 ---
|
68 |
def code_matches_language(code, language):
|