diff --git a/openai_api_call/__init__.py b/openai_api_call/__init__.py index dd2673a..3791fa5 100644 --- a/openai_api_call/__init__.py +++ b/openai_api_call/__init__.py @@ -2,7 +2,7 @@ __author__ = """Rex Wang""" __email__ = '1073853456@qq.com' -__version__ = '1.0.1' +__version__ = '1.1.0' import os, requests from .chattool import Chat, Resp diff --git a/openai_api_call/chattool.py b/openai_api_call/chattool.py index fdc786e..1f84b89 100644 --- a/openai_api_call/chattool.py +++ b/openai_api_call/chattool.py @@ -35,6 +35,7 @@ def __init__( self raise ValueError("msg should be a list of dict, a string or None") self._api_key = openai_api_call.api_key if api_key is None else api_key self._chat_url = chat_url + self._model = 'gpt-3.5-turbo' def prompt_token(self, model:str="gpt-3.5-turbo-0613"): """Get the prompt token for the model @@ -47,6 +48,15 @@ def prompt_token(self, model:str="gpt-3.5-turbo-0613"): """ return num_tokens_from_messages(self.chat_log, model=model) + @property + def model(self): + return self._model + + @model.setter + def model(self, model:str): + # assert model.startswith('gpt-'), f'unsupported model {model}' + self._model = model + @property def api_key(self): """Get API key""" @@ -77,7 +87,7 @@ def getresponse( self , timeout:int = 0 , timeinterval:int = 0 , api_key:Union[str, None]=None - , model:str = "gpt-3.5-turbo" + , model:str = None , update:bool = True , **options)->Resp: """Get the API response @@ -96,6 +106,8 @@ def getresponse( self if api_key is None: api_key = self.api_key assert api_key is not None, "API key is not set!" + if model is None: + model = self.model # initialize prompt message msg = self.chat_log diff --git a/setup.py b/setup.py index 6c8b188..3e853d1 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open('README.md') as readme_file: readme = readme_file.read() -VERSION = '1.0.1' +VERSION = '1.1.0' requirements = [ 'Click>=7.0', 'requests>=2.20',