mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-09-12 08:29:30 -04:00
added validation for model parameter
This commit is contained in:
parent
94282777ea
commit
2c720f83a8
@ -380,8 +380,13 @@ class Completion:
|
|||||||
|
|
||||||
class Poe:
|
class Poe:
|
||||||
def __init__(self, model: str = "ChatGPT"):
|
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.model = MODELS[model]
|
||||||
|
self.cookie = self.__load_cookie()
|
||||||
self.client = PoeClient(self.cookie)
|
self.client = PoeClient(self.cookie)
|
||||||
|
|
||||||
def __load_cookie(self) -> str:
|
def __load_cookie(self) -> str:
|
||||||
@ -443,7 +448,11 @@ class Poe:
|
|||||||
return cookie
|
return cookie
|
||||||
|
|
||||||
def chat(self, message: str, model: Optional[str] = None) -> str:
|
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
|
response = None
|
||||||
for chunk in self.client.send_message(model, message):
|
for chunk in self.client.send_message(model, message):
|
||||||
response = chunk["text"]
|
response = chunk["text"]
|
||||||
|
Loading…
Reference in New Issue
Block a user