updated the bot names in poe

This commit is contained in:
Raju Komati 2023-04-24 13:52:43 +05:30
parent 95fa113a60
commit 2200e777c1
No known key found for this signature in database
GPG Key ID: A581A5D67A8EB090
2 changed files with 23 additions and 11 deletions

View File

@ -52,7 +52,12 @@ print(response.completion.choices[0].text)
```python ```python
from quora import Poe from quora import Poe
poe = Poe(model='sage') # available models: ['Sage', 'GPT-4', 'Claude+', 'Claude-instant', 'ChatGPT', 'Dragonfly', 'NeevaAI']
poe = Poe(model='gpt-3.5-turbo')
poe.chat('who won the football world cup most?') poe.chat('who won the football world cup most?')
# new bot creation
poe.create_bot('new_bot_name', prompt='You are new test bot', base_model='gpt-3.5-turbo')
``` ```

View File

@ -6,6 +6,7 @@ from pathlib import Path
from random import choice, choices, randint from random import choice, choices, randint
from re import search, findall from re import search, findall
from string import ascii_letters, digits from string import ascii_letters, digits
from typing import Optional
from urllib.parse import unquote from urllib.parse import unquote
import selenium.webdriver.support.expected_conditions as EC import selenium.webdriver.support.expected_conditions as EC
@ -18,17 +19,18 @@ from tls_client import Session as TLS
from quora.api import Client as PoeClient from quora.api import Client as PoeClient
from quora.mail import Emailnator from quora.mail import Emailnator
from typing import Optional
# from twocaptcha import TwoCaptcha # from twocaptcha import TwoCaptcha
# solver = TwoCaptcha('72747bf24a9d89b4dcc1b24875efd358') # solver = TwoCaptcha('72747bf24a9d89b4dcc1b24875efd358')
MODELS = { MODELS = {
"sage": "capybara", "Sage": "capybara",
"gpt-4": "beaver", "GPT-4": "beaver",
"claude-v1.2": "a2_2", "Claude+": "a2_2",
"claude-instant-v1.0": "a2", "Claude-instant": "a2",
"gpt-3.5-turbo": "chinchilla", "ChatGPT": "chinchilla",
"Dragonfly": "nutria",
"NeevaAI": "hutia",
} }
@ -377,7 +379,7 @@ class Completion:
class Poe: class Poe:
def __init__(self, model: str = "gpt-3.5-turbo"): def __init__(self, model: str = "ChatGPT"):
self.cookie = self.__load_cookie() self.cookie = self.__load_cookie()
self.model = MODELS[model] self.model = MODELS[model]
self.client = PoeClient(self.cookie) self.client = PoeClient(self.cookie)
@ -441,7 +443,7 @@ class Poe:
return cookie return cookie
def chat(self, message: str, model: Optional[str] = None) -> str: def chat(self, message: str, model: Optional[str] = None) -> str:
model = model or self.model model = MODELS[model] or self.model
response = None response = None
for chunk in self.client.send_message(model, message): for chunk in self.client.send_message(model, message):
response = chunk["text"] response = chunk["text"]
@ -452,11 +454,13 @@ class Poe:
name: str, name: str,
/, /,
prompt: str = "", prompt: str = "",
base_model: str = "gpt-3.5-turbo", base_model: str = "ChatGPT",
description: str = "", description: str = "",
) -> None: ) -> None:
if base_model not in MODELS: if base_model not in MODELS:
raise RuntimeError('Sorry, the base_model you provided does not exist. Please check and try again.') raise RuntimeError(
"Sorry, the base_model you provided does not exist. Please check and try again."
)
response = self.client.create_bot( response = self.client.create_bot(
handle=name, handle=name,
@ -465,3 +469,6 @@ class Poe:
description=description, description=description,
) )
print(f'Successfully created bot with name: {response["bot"]["displayName"]}') print(f'Successfully created bot with name: {response["bot"]["displayName"]}')
def list_bots(self) -> list:
return list(self.client.bot_names.values())