add instructions for Viola
This commit is contained in:
parent
2833447053
commit
3750f7d2c2
103
README.md
103
README.md
|
|
@ -1,3 +1,102 @@
|
|||
# viola
|
||||
# Reverse API for Voila Chat
|
||||
|
||||
Reverse Engineer of Voilà's API
|
||||
This Python script provides a reverse API for interacting with the Voila chat API. It allows you to send messages to the Voila chat API and receive the response in a streaming format.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Python 3.x
|
||||
- `requests` library
|
||||
|
||||
## Installation
|
||||
|
||||
1. Install the required library:
|
||||
|
||||
```
|
||||
pip install requests
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
1. Set the API endpoint URL:
|
||||
|
||||
```python
|
||||
API_ENDPOINT = "https://chat.getvoila.ai/api/v1/prompts/chat"
|
||||
```
|
||||
|
||||
2. Generate UUIDs for the conversation and user:
|
||||
|
||||
```python
|
||||
conversation_id = str(uuid4())
|
||||
user_uuid = str(uuid4())
|
||||
```
|
||||
|
||||
3. Set the provided details in the `payload` dictionary:
|
||||
|
||||
```python
|
||||
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
|
||||
}
|
||||
```
|
||||
|
||||
4. Set the cookie values:
|
||||
|
||||
```python
|
||||
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"
|
||||
```
|
||||
|
||||
5. Set the request headers:
|
||||
|
||||
```python
|
||||
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"
|
||||
}
|
||||
```
|
||||
|
||||
6. Send the request to the API:
|
||||
|
||||
```python
|
||||
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.")
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- You'll need to grab the cookie values from your Voila account at https://www.getvoila.ai/account and enter them accordingly.
|
||||
- You'll need to grab your auth token when you send a request in the Chrome extension or Firefox addon, and enter that value in the `auth_token` field.
|
||||
- The `origin` field in the headers might need to be changed if you're using a different extension/addon.
|
||||
- The `version` field in the `payload` should be updated to match the version of the extension/addon you're using.
|
||||
|
|
|
|||
Loading…
Reference in New Issue