add viola file
This commit is contained in:
parent
1296fc4ba0
commit
2833447053
|
|
@ -0,0 +1,63 @@
|
|||
import requests
|
||||
from requests.exceptions import ChunkedEncodingError
|
||||
import json
|
||||
from uuid import uuid4
|
||||
|
||||
# Set the API endpoint URL
|
||||
API_ENDPOINT = "https://chat.getvoila.ai/api/v1/prompts/chat"
|
||||
|
||||
# Generate UUIDs
|
||||
conversation_id = str(uuid4())
|
||||
user_uuid = str(uuid4())
|
||||
|
||||
# Set the provided details
|
||||
payload = {
|
||||
"chat": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "hello", # Change this to the message you want to send
|
||||
"intent": None
|
||||
}
|
||||
],
|
||||
"email": "Your Email Address for your Voila account",
|
||||
"model": "gpt-4", # Change this to the model you want to use
|
||||
"auth_token": "Enter your Auth Token from request headers using the extension/addon",
|
||||
"context": "",
|
||||
"conversation": conversation_id,
|
||||
"user_uuid": user_uuid,
|
||||
"version": "1.5.4" # Change this to the version of the extension/addon you are using
|
||||
}
|
||||
|
||||
# Set the cookie values
|
||||
ph_phc_val = "Enter your Cookie Name for your php_phc cookie"
|
||||
posthog_val = "Enter your Cookie Value for your php_phc cookie"
|
||||
ahoy_visitor = "Enter your Cookie Value"
|
||||
ahoy_visit = "Enter your Cookie Value"
|
||||
|
||||
# Set the request headers
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"accept": "text/event-stream",
|
||||
"accept-language": "en-US,en;q=0.9",
|
||||
"cookie": f"{ph_phc_val}={posthog_val}; ahoy_visitor={ahoy_visitor}; ahoy_visit={ahoy_visit}",
|
||||
"origin": "chrome-extension://cakobppopkpmmglabcdcklncbckjpkcl", # Change this to the origin of the extension/addon you are using this might be different in upcoming versions
|
||||
"priority": "u=1, i",
|
||||
"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": "cross-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"
|
||||
}
|
||||
|
||||
# Send the request to the API
|
||||
with requests.Session() as session:
|
||||
try:
|
||||
response = session.post(API_ENDPOINT, data=json.dumps(payload), headers=headers, stream=True)
|
||||
for line in response.iter_lines():
|
||||
if line:
|
||||
print(line.decode())
|
||||
except ChunkedEncodingError:
|
||||
print("Streaming response ended.")
|
||||
Loading…
Reference in New Issue