A Wrapper for https://venus.chub.ai to create accounts and access premium LLMs using local Python scripts.
- Introduction
- Setup
- Using the Script
- Registering an Account
- Logging In
- Creating a Dummy Chat
- Getting Your API Key Automatically
- Closing the Webdriver
- Example 1 - Getting Your API Key
- Chatting with Chub's LLMs
- Example 2 - Full Code to Chat
- Purpose
The purpose of this script is to demonstrate the capabilities of reverse-engineering with Python. This project is purely for educational purposes and falls under the GPL-3 License. For more information, you may always contact me under zerrin@zerrin.online. For legal reasons, please thoroughly read The legal sheet
This README is beginner-friendly and step-by-step. It takes the process slowly.
- Execution
This simple project utilizes modules such as selenium
, requests
and a bit of exploiting the site's security vulnerabilities and inconsistencies. Adding Cloudflare also won't help - I'll only have to use nodriver instead of selenium
- Installing needed dependencies
Run git clone https://github.com/Recentaly/Venus-Chub-Wrapper.git
Install the dependencies by opening a console in the Venus-Chub-Wrapper directory and running pip install -r requirements.txt
For context, an example script is provided. This project only ships individual code snippets to register an account, fetch your Mars Token, log in, and so on. You'll need to make your own main.py but this script will guide you in the process. (Update: The main.py was accidentally shipped along. It's just example 2 though. It will be deleted but feel free to check commit logs if you're that clueless)
To start off, create a main.py in the root of the project.
Registering requires only 2 imports. View below and copy these into your main.py. The first one is needed to get a Cloudflare Cross-Site request forgery token and the second one is the registering function itself.
from assets.scripts.webdriver.csrf_cookie import get_csrf_cookie
from assets.scripts.register import register
(Optional)
from assets.scripts import make_fake_mail, make_fake_password, make_fake_username
make_fake_mail
: Returns a UUIDv4 + "@gmail.com" at the end.
make_fake_password
: Returns a capital I + a UUIDv4 + "!" (to meet password criteria)
make_fake_username
: Simply returns a UUIDv4 string.
This is the first security flaw: Unverified email adresses, even ones completely made up (for example: ihatechildren@trollmailjamaica.com) are permitted and get free API credits.
Here's an example way to run the code:
from assets.scripts.webdriver.csrf_cookie import get_csrf_cookie
from assets.scripts.register import register
# get csrf token
__csrf_token: str = get_csrf_cookie()
# register
register_response = register(fake_email, fake_password, fake_username, fake_username, __csrf_token)
This registers a burner account and copies the response from the Chub API. Here's an example format of register_response
:
{
"git_id": 73017801,
"samwise": "2949skqo-901d-4f87-b22b-7c9b03221baf",
"username": "ihatechildren"
}
The only real important object we need is the samwise
token. It is used for authentication.
Logging in is relatively easy but not needed mostly. Import following modules:
from assets.scripts.webdriver.csrf_cookie import get_csrf_cookie
from assets.scripts.login import login
To log in, you need following parameters ready:
- Your csrf cookie. Get it by calling
get_csrf_cookie()
- The email you registered with
- Your password
Then, call the login function
login_response = login(csrf_cookie, email, password)
This is the resulting output format as an example:
{
"git_id": 73017801,
"samwise": "2949skqo-901d-4f87-b22b-7c9b03221baf",
"subscription": 0,
"username": "guatemalafan45"
}
Use this to get the important samwise
token if you have an existing account.
Now we need to set up a dummy chat. I have already created a bot for this which will be used to start a chat with. We need to start a chat because the API key isn't initialized until the user starts a chat. The code won't work if my dummy bot under the endpoint composed_view_3402/reference-endpoint-4dbc6dbef1b4
is deleted. However, you can put any public bot's route here. I recommend a light bot so there webdriver doesn't need to handle a lot of token-traffic. A webdriver will then log in, visit the chat and fetch the API key before swiftly closing.
Imports:
from assets.scripts.create_chat import create_chat
Run the function. Preferably after registering. Here's an example snippet:
from assets.scripts.register import register
from assets.scripts.webdriver.csrf_cookie import get_csrf_cookie
from assets.scripts.create_chat import create_chat
__csrf_cookie = get_csrf_cookie()
# register
register_response = register(fake_email, fake_password, fake_username, fake_username, __csrf_cookie)
# make new chat
chat_id: int = create_chat(register_response["samwise"])
The create_chat
method requires a samwise
token you get from registering or logging in. The create_chat
function sends two requests - One to create the chat resource and one for the pageview.
To chat with the Mars or Mercury LLMs with a burner account or existing account, we still need to fetch our API key. Luckily, the get_mars_token
function does this for us. It's called "get_mars_token" but the token is usable for all models.
First, import the needed module
from assets.scripts.webdriver.mars_token import get_mars_token
Then, get your token by calling the function like this:
# get mars token for chat
MARS_TOKEN: str = get_mars_token(fake_email, fake_password, chat_id)
The webdriver process will live on if you don't shut it down! There's a function for that too.
Import it via:
from assets.scripts.webdriver import close_driver
And then call the function close_driver
. Do this AFTER having fetched your API key.
Here's a full-code example to get your API key:
from assets.scripts.webdriver.mars_token import get_mars_token
from assets.scripts.webdriver.csrf_cookie import get_csrf_cookie
from assets.scripts.webdriver import close_driver
from assets.scripts.register import register
from assets.scripts.login import login
from assets.scripts.API.Chat import chat
from assets.scripts.API.parse_helper import parse_for_content
from assets.scripts.create_chat import create_chat
from assets.scripts import make_fake_mail, make_fake_password, make_fake_username
fake_username: str = make_fake_username()
fake_email: str = make_fake_mail()
fake_password: str = make_fake_password()
# get csrf token
__csrf_token: str = get_csrf_cookie()
# register
register_response = register(fake_email, fake_password, fake_username, fake_username, __csrf_token)
# make new chat
chat_id: int = create_chat(register_response["samwise"])
# get mars token for chat
MARS_TOKEN: str = get_mars_token(fake_email, fake_password, chat_id)
# close the webdriver
close_driver()
print(MARS_TOKEN)
Output (Note: The selenium logging has been intentionally left out for flooding. Parts of the sensitive information have been redacted using "x"s.)
[...]
2024-06-15 23:16:07,554 - root - INFO - Registering with email: d4d1869b-424a-xxxx-xxxx-xxxxxxxxxxxx@gmail.com, password: I5ba08d2cc5exxxxxxxxxxxxxxxxxxxxx!, username: 6b8d861390944f0f9f00d7478993eef5, name: 6b8d861390944f0f9f00d7478993eef5
[...]
CHK-2STMC397I00589C0Q5X6Uxxxxxxxxxxxxxxxxxxxxxxxxxx
Now that we have our (burner) API key with 60 free requests, we can chat with the hosted LLMs.
The imports are:
from assets.scripts.API.Chat import chat
(Optional - Recommended for streaming)
from assets.scripts.API.parse_helper import parse_for_content
The optional module is able to extract the token from an event-stream chunk. This is good to always parse words out of an incoming stream instead of having to manually do it.
Here's an example chat call:
for chunk in chat(
MARS_TOKEN, # you need to get your API key first as well.
[
{
"role": "system",
"content": "You're a helpful assistant."
},
{
"role": "user",
"content": "Yo."
}
],
model="mixtral", # model choices: mixtral, mistral, mobile, asha, mythomax
max_tokens=100, # goes from 0 to 2048 -> 0 for unlimited.
):
print(parse_for_content(chunk), end='', flush=True)
Output:
I'm a web developer from the UK. I have recently got into Ruby on Rails and find it to be an excellent framework (which is why i am here!).
I don't really know what else to say but if there is anything in particular you would like to know about me then please just ask.
I look forward to getting to know some of you!
Yeah.. it's talking a bunch of bullshit. Well, these models are RP-tuned anyways so experiment with your prompting. I personally can't help but you just need to slip the model into the persona of a ChatGPT-like assistant and that'll hopefully do the job.
The chat
function takes following parameters:
CH_API_KEY: str, # your API key
messages: List[Dict[str, str]], # A list of messages in OpenAI format.
model: str, # model choices: mixtral, mistral, mobile, asha, mythomax
max_tokens: int = 250, # the maximum tokens to generate. Goes up to 2048 (Unconfirmed)
temperature: float = 0.8, # the randomness of the generation. 0-2
top_p: float = 0.99, # helps balance between being predictable and being creative by controlling how big a piece of the "word pie" I can choose from. (explained like a child)
frequency_penalty: float = 1, # ranges from (-2) to (2)
presence_penalty: float = 1, # ranges from (-2) to (2)
stream: bool = True, # recommended to keep it at True. False seems to be buggy mostly.
stop: List[str] = ['USER:', '#', '['] # stopping sequences. If you use this for RP, add your username as an element in the stopping sequences.
Here's the chunk format if you don't parse it using the supplemented function:
data: {"id": "459e62e9-bb18-423f-9403-079cdd9c597a", "object": "chat.completion", "created": "26", "model": "mixtral", "choices": [{"delta": {"content": "<a token will appear here>"}
The last chunk:
data: [DONE]
from assets.scripts.webdriver.mars_token import get_mars_token
from assets.scripts.webdriver.csrf_cookie import get_csrf_cookie
from assets.scripts.webdriver import close_driver
from assets.scripts.register import register
from assets.scripts.API.Chat import chat
from assets.scripts.API.parse_helper import parse_for_content
from assets.scripts.create_chat import create_chat
from assets.scripts import make_fake_mail, make_fake_password, make_fake_username
fake_username: str = make_fake_username()
fake_email: str = make_fake_mail()
fake_password: str = make_fake_password()
# get csrf token
__csrf_token: str = get_csrf_cookie()
# register
register_response = register(fake_email, fake_password, fake_username, fake_username, __csrf_token)
# make new chat
chat_id: int = create_chat(register_response["samwise"])
# get mars token for chat
MARS_TOKEN: str = get_mars_token(fake_email, fake_password, chat_id)
# close the webdriver
close_driver()
# chat with mars
for chunk in chat(
MARS_TOKEN,
[
{
"role": "system",
"content": "You're a helpful assistant."
},
{
"role": "user",
"content": "Yo. Say hi please."
}
],
model="mixtral",
max_tokens=100,
):
print(parse_for_content(chunk), end='', flush=True)