61 lines
1.8 KiB
Python
61 lines
1.8 KiB
Python
import requests
|
|
from requests.exceptions import ChunkedEncodingError
|
|
import uuid
|
|
|
|
# Variable section
|
|
authorization_token = 'Bearer Auth Token'
|
|
content = "hello"
|
|
url = 'https://uam.getmerlin.in/thread/unified?customJWT=true&version=1.1'
|
|
headers = {
|
|
'accept': 'text/event-stream',
|
|
'accept-language': 'en-US,en;q=0.7',
|
|
'authorization': authorization_token,
|
|
'content-type': 'application/json',
|
|
'origin': 'https://www.getmerlin.in',
|
|
'priority': 'u=1, i',
|
|
'referer': 'https://www.getmerlin.in/',
|
|
'sec-ch-ua': '"Chromium";v="124", "Brave";v="124", "Not-A.Brand";v="99"',
|
|
'sec-ch-ua-mobile': '?0',
|
|
'sec-ch-ua-platform': '"Linux"',
|
|
'sec-fetch-dest': 'empty',
|
|
'sec-fetch-mode': 'cors',
|
|
'sec-fetch-site': 'same-site',
|
|
'sec-gpc': '1',
|
|
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
|
|
'x-merlin-version': 'extension-null'
|
|
}
|
|
data = {
|
|
"action": {
|
|
"message": {
|
|
"attachments": [],
|
|
"content": content,
|
|
"metadata": {
|
|
"context": ""
|
|
},
|
|
"parentId": "root",
|
|
"role": "user"
|
|
},
|
|
"type": "NEW"
|
|
},
|
|
"activeThreadSnippet": [],
|
|
"chatId": "a39969ee-1342-4e3c-80fb-93cb5e40e17c",
|
|
"language": "AUTO",
|
|
"metadata": None,
|
|
"mode": "VANILLA_CHAT",
|
|
"model": "claude-3-opus",
|
|
"personaConfig": {}
|
|
}
|
|
|
|
def generate_response():
|
|
try:
|
|
with requests.Session() as session:
|
|
response = session.post(url, headers=headers, json=data, stream=True)
|
|
for line in response.iter_lines():
|
|
if line:
|
|
print(line.decode())
|
|
except ChunkedEncodingError:
|
|
print("Streaming response ended.")
|
|
|
|
if __name__ == "__main__":
|
|
generate_response()
|