XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

added create bot method in Poe class

95fa113a
Raju Komati <komatiraju032@gmail.com>
提交于

代码差异

1 个文件 +24 -5
Modified quora/__init__.py +24 -5
@@ -377,7 +377,7 @@ class Completion:
377 377
378 378
379 379 class Poe:
380 def __init__(self, model: str = "sage"):
380 def __init__(self, model: str = "gpt-3.5-turbo"):
381 381 self.cookie = self.__load_cookie()
382 382 self.model = MODELS[model]
383 383 self.client = PoeClient(self.cookie)
@@ -402,7 +402,7 @@ class Poe:
402 402
403 403 print(mail_address)
404 404 options = webdriver.FirefoxOptions()
405 options.add_argument("-headless")
405 # options.add_argument("-headless")
406 406 driver = webdriver.Firefox(options=options)
407 407
408 408 driver.get("https://www.poe.com")
@@ -440,9 +440,28 @@ class Poe:
440 440 driver.close()
441 441 return cookie
442 442
443 def chat(self, message: str):
443 def chat(self, message: str, model: Optional[str] = None) -> str:
444 model = model or self.model
444 445 response = None
445 for chunk in self.client.send_message(self.model, message):
446 for chunk in self.client.send_message(model, message):
446 447 response = chunk["text"]
447
448 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"]}')