diff options
author | Raju Komati <komatiraju032@gmail.com> | 2023-04-24 11:04:14 +0200 |
---|---|---|
committer | Raju Komati <komatiraju032@gmail.com> | 2023-04-24 11:04:14 +0200 |
commit | 2c720f83a857f3fe102d42d9193e48c8b46da55c (patch) | |
tree | eddfa06fbf415fc3cf2e5ca8b100fe924560f00b /quora/__init__.py | |
parent | updated poe readme (diff) | |
download | gpt4free-2c720f83a857f3fe102d42d9193e48c8b46da55c.tar gpt4free-2c720f83a857f3fe102d42d9193e48c8b46da55c.tar.gz gpt4free-2c720f83a857f3fe102d42d9193e48c8b46da55c.tar.bz2 gpt4free-2c720f83a857f3fe102d42d9193e48c8b46da55c.tar.lz gpt4free-2c720f83a857f3fe102d42d9193e48c8b46da55c.tar.xz gpt4free-2c720f83a857f3fe102d42d9193e48c8b46da55c.tar.zst gpt4free-2c720f83a857f3fe102d42d9193e48c8b46da55c.zip |
Diffstat (limited to '')
-rw-r--r-- | quora/__init__.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/quora/__init__.py b/quora/__init__.py index 88c9d0c4..4eeeb697 100644 --- a/quora/__init__.py +++ b/quora/__init__.py @@ -380,8 +380,13 @@ class Completion: class Poe: def __init__(self, model: str = "ChatGPT"): - self.cookie = self.__load_cookie() + # validating the model + if model and model not in MODELS: + raise RuntimeError( + "Sorry, the model you provided does not exist. Please check and try again." + ) self.model = MODELS[model] + self.cookie = self.__load_cookie() self.client = PoeClient(self.cookie) def __load_cookie(self) -> str: @@ -443,7 +448,11 @@ class Poe: return cookie def chat(self, message: str, model: Optional[str] = None) -> str: - model = MODELS[model] or self.model + if model and model not in MODELS: + raise RuntimeError( + "Sorry, the model you provided does not exist. Please check and try again." + ) + model = MODELS[model] if model else self.model response = None for chunk in self.client.send_message(model, message): response = chunk["text"] |