Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/microsoft/guidance into main
Browse files Browse the repository at this point in the history
  • Loading branch information
slundberg committed Jun 15, 2023
2 parents 4deae4f + 3db2c1e commit 89e45d5
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions guidance/llms/_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ def add_text_to_chat_mode(chat_mode):
c['text'] = c['message']['content']
return chat_mode

# model that need to use the chat completion API
chat_models = [
"gpt-4",
"gpt-4-32k",
"gpt-4-0314",
"gpt-4-32k-0314",
"gpt-3.5-turbo",
"gpt-3.5-turbo-0301"
]

class OpenAI(LLM):
llm_name: str = "openai"

Expand Down Expand Up @@ -103,7 +93,9 @@ def __init__(self, model=None, caching=True, max_retries=5, max_calls_per_min=60

# auto detect chat completion mode
if chat_mode == "auto":
if model in chat_models:
# parse to determin if the model need to use the chat completion API
chat_model_pattern = r'^(gpt-3\.5-turbo|gpt-4)(-\d+k)?(-\d{4})?$'
if re.match(chat_model_pattern, model):
chat_mode = True
else:
chat_mode = False
Expand Down

0 comments on commit 89e45d5

Please sign in to comment.