Raju Komati
commited on
added validation for model parameter
Browse files- quora/__init__.py +11 -2
quora/__init__.py
CHANGED
@@ -380,8 +380,13 @@ class Completion:
|
|
380 |
|
381 |
class Poe:
|
382 |
def __init__(self, model: str = "ChatGPT"):
|
383 |
-
|
|
|
|
|
|
|
|
|
384 |
self.model = MODELS[model]
|
|
|
385 |
self.client = PoeClient(self.cookie)
|
386 |
|
387 |
def __load_cookie(self) -> str:
|
@@ -443,7 +448,11 @@ class Poe:
|
|
443 |
return cookie
|
444 |
|
445 |
def chat(self, message: str, model: Optional[str] = None) -> str:
|
446 |
-
model
|
|
|
|
|
|
|
|
|
447 |
response = None
|
448 |
for chunk in self.client.send_message(model, message):
|
449 |
response = chunk["text"]
|
|
|
380 |
|
381 |
class Poe:
|
382 |
def __init__(self, model: str = "ChatGPT"):
|
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 |
+
)
|
388 |
self.model = MODELS[model]
|
389 |
+
self.cookie = self.__load_cookie()
|
390 |
self.client = PoeClient(self.cookie)
|
391 |
|
392 |
def __load_cookie(self) -> str:
|
|
|
448 |
return cookie
|
449 |
|
450 |
def chat(self, message: str, model: Optional[str] = None) -> str:
|
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
|
456 |
response = None
|
457 |
for chunk in self.client.send_message(model, message):
|
458 |
response = chunk["text"]
|