Skip to content

Commit

Permalink
Add GPT-4 support (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
gventuri committed Apr 30, 2023
1 parent 12bbc2c commit beac78d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pandasai/llm/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
class OpenAI(LLM):
"""OpenAI LLM"""

_supported_chat_models = [
"gpt-4",
"gpt-4-0314",
"gpt-4-32k",
"gpt-4-32k-0314",
"gpt-3.5-turbo",
"gpt-3.5-turbo-0301",
]
_supported_completion_models = ["text-davinci-003"]

api_token: str
model: str = "gpt-3.5-turbo"
temperature: float = 0
Expand Down Expand Up @@ -93,9 +103,9 @@ def chat_completion(self, value: str) -> str:
return response["choices"][0]["message"]["content"]

def call(self, instruction: str, value: str) -> str:
if self.model == "text-davinci-003":
if self.model in self._supported_completion_models:
response = self.completion(str(instruction) + str(value))
elif self.model == "gpt-3.5-turbo":
elif self.model in self._supported_chat_models:
response = self.chat_completion(str(instruction) + str(value))
else:
raise UnsupportedOpenAIModelError("Unsupported model")
Expand Down

0 comments on commit beac78d

Please sign in to comment.