Raju Komati
commited on
added create bot method in Poe class
Browse files- quora/__init__.py +24 -5
quora/__init__.py
CHANGED
@@ -377,7 +377,7 @@ class Completion:
|
|
377 |
|
378 |
|
379 |
class Poe:
|
380 |
-
def __init__(self, model: str = "
|
381 |
self.cookie = self.__load_cookie()
|
382 |
self.model = MODELS[model]
|
383 |
self.client = PoeClient(self.cookie)
|
@@ -402,7 +402,7 @@ class Poe:
|
|
402 |
|
403 |
print(mail_address)
|
404 |
options = webdriver.FirefoxOptions()
|
405 |
-
options.add_argument("-headless")
|
406 |
driver = webdriver.Firefox(options=options)
|
407 |
|
408 |
driver.get("https://www.poe.com")
|
@@ -440,9 +440,28 @@ class Poe:
|
|
440 |
driver.close()
|
441 |
return cookie
|
442 |
|
443 |
-
def chat(self, message: str):
|
|
|
444 |
response = None
|
445 |
-
for chunk in self.client.send_message(
|
446 |
response = chunk["text"]
|
447 |
-
|
448 |
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
|
378 |
|
379 |
class Poe:
|
380 |
+
def __init__(self, model: str = "gpt-3.5-turbo"):
|
381 |
self.cookie = self.__load_cookie()
|
382 |
self.model = MODELS[model]
|
383 |
self.client = PoeClient(self.cookie)
|
|
|
402 |
|
403 |
print(mail_address)
|
404 |
options = webdriver.FirefoxOptions()
|
405 |
+
# options.add_argument("-headless")
|
406 |
driver = webdriver.Firefox(options=options)
|
407 |
|
408 |
driver.get("https://www.poe.com")
|
|
|
440 |
driver.close()
|
441 |
return cookie
|
442 |
|
443 |
+
def chat(self, message: str, model: Optional[str] = None) -> str:
|
444 |
+
model = model or self.model
|
445 |
response = None
|
446 |
+
for chunk in self.client.send_message(model, message):
|
447 |
response = chunk["text"]
|
|
|
448 |
return response
|
449 |
+
|
450 |
+
def create_bot(
|
451 |
+
self,
|
452 |
+
name: str,
|
453 |
+
/,
|
454 |
+
prompt: str = "",
|
455 |
+
base_model: str = "gpt-3.5-turbo",
|
456 |
+
description: str = "",
|
457 |
+
) -> None:
|
458 |
+
if base_model not in MODELS:
|
459 |
+
raise RuntimeError('Sorry, the base_model you provided does not exist. Please check and try again.')
|
460 |
+
|
461 |
+
response = self.client.create_bot(
|
462 |
+
handle=name,
|
463 |
+
prompt=prompt,
|
464 |
+
base_model=MODELS[base_model],
|
465 |
+
description=description,
|
466 |
+
)
|
467 |
+
print(f'Successfully created bot with name: {response["bot"]["displayName"]}')
|