hterhhrth / app.py
Dooratre's picture
Create app.py
c03acd5 verified
raw
history blame
2.55 kB
import requests
import json
def send_chat_request():
# Define the URL of the API endpoint
url = 'https://www.blackbox.ai/api/chat'
# Headers
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
'Content-Type': 'application/json' # Assuming the API expects JSON format
}
# Payload
payload = {
"agentMode": {},
"clickedAnswer2": False,
"clickedAnswer3": False,
"clickedForceWebSearch": False,
"codeModelMode": True,
"githubToken": None,
"id": "hFnU6fo",
"isChromeExt": False,
"isMicMode": False,
"maxTokens": 1024,
"messages": [
{
"id": "hFnU6fo",
"content": "GIve me FULL NEWS ABOUT BTC YOU CAN GET IT FROM WEB",
"role": "user"
}
],
"mobileClient": False,
"previewToken": None,
"trendingAgentMode": {},
"userId": None,
"userSelectedModel": None,
"visitFromDelta": False
}
# Send the POST request
response = requests.post(url, headers=headers, data=json.dumps(payload))
first = response.text# Print the response text
return first
def send_chat_request_v2(first):
# Define the URL of the API endpoint
url = 'https://www.blackbox.ai/api/chat'
# Headers
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
'Content-Type': 'application/json' # Assuming the API expects JSON format
}
# Payload
payload = {
"agentMode": {},
"id": "hFnU6fo",
"messages": [
{
"id": "hFnU6fo",
"content": "GIve me FULL NEWS ABOUT BTC YOU CAN GET IT FROM WEB",
"role": "user"
},
{
"id": "9RsMsaM",
"createdAt": "2024-09-21T08:11:09.953Z",
"content": first
,
"role": "assistant"
}
],
"mobileClient": False,
"mode": "continue",
"trendingAgentMode": {},
"userId": None
}
# Send the POST request
response = requests.post(url, headers=headers, data=json.dumps(payload))
second = response.text# Print the response text
return second
first = send_chat_request()
second = send_chat_request_v2(first)
print (f"{first}{second}")