返回提交历史
Modified
quora/__init__.py
+11
-2
XFEstudio/gpt4free
added validation for model parameter
2c720f83
代码差异
1 个文件
+11
-2
@@ -380,8 +380,13 @@ class Completion:
380
380
381
381
class Poe:
382
382
def __init__(self, model: str = "ChatGPT"):
383
self.cookie = self.__load_cookie()
383
# validating the model
384
if model and model not in MODELS:
385
raise RuntimeError(
386
"Sorry, the model you provided does not exist. Please check and try again."
387
)
384
388
self.model = MODELS[model]
389
self.cookie = self.__load_cookie()
385
390
self.client = PoeClient(self.cookie)
386
391
387
392
def __load_cookie(self) -> str:
@@ -443,7 +448,11 @@ class Poe:
443
448
return cookie
444
449
445
450
def chat(self, message: str, model: Optional[str] = None) -> str:
446
model = MODELS[model] or self.model
451
if model and model not in MODELS:
452
raise RuntimeError(
453
"Sorry, the model you provided does not exist. Please check and try again."
454
)
455
model = MODELS[model] if model else self.model
447
456
response = None
448
457
for chunk in self.client.send_message(model, message):
449
458
response = chunk["text"]