From f68e8a1dfbb938e1ae605aa77fb58d5aba3fba2a Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 12 Sep 2024 15:50:24 -0700 Subject: [PATCH] o1-preview and o1-mini, refs #570 --- docs/openai-models.md | 2 ++ docs/usage.md | 20 ++++++++++++++++++++ llm/default_plugins/openai_models.py | 10 +++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/openai-models.md b/docs/openai-models.md index 9d9a8daa..d0fc6fcd 100644 --- a/docs/openai-models.md +++ b/docs/openai-models.md @@ -41,6 +41,8 @@ OpenAI Chat: gpt-4-turbo-2024-04-09 OpenAI Chat: gpt-4-turbo (aliases: gpt-4-turbo-preview, 4-turbo, 4t) OpenAI Chat: gpt-4o (aliases: 4o) OpenAI Chat: gpt-4o-mini (aliases: 4o-mini) +OpenAI Chat: o1-preview +OpenAI Chat: o1-mini OpenAI Completion: gpt-3.5-turbo-instruct (aliases: 3.5-instruct, chatgpt-instruct) ``` diff --git a/docs/usage.md b/docs/usage.md index 4d6ef5bd..005a1690 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -345,6 +345,26 @@ OpenAI Chat: gpt-4o-mini (aliases: 4o-mini) logit_bias: dict, str seed: int json_object: boolean +OpenAI Chat: o1-preview + temperature: float + max_tokens: int + top_p: float + frequency_penalty: float + presence_penalty: float + stop: str + logit_bias: dict, str + seed: int + json_object: boolean +OpenAI Chat: o1-mini + temperature: float + max_tokens: int + top_p: float + frequency_penalty: float + presence_penalty: float + stop: str + logit_bias: dict, str + seed: int + json_object: boolean OpenAI Completion: gpt-3.5-turbo-instruct (aliases: 3.5-instruct, chatgpt-instruct) temperature: float What sampling temperature to use, between 0 and 2. Higher values like diff --git a/llm/default_plugins/openai_models.py b/llm/default_plugins/openai_models.py index e8ca566d..657c0d20 100644 --- a/llm/default_plugins/openai_models.py +++ b/llm/default_plugins/openai_models.py @@ -35,6 +35,9 @@ def register_models(register): # GPT-4o register(Chat("gpt-4o"), aliases=("4o",)) register(Chat("gpt-4o-mini"), aliases=("4o-mini",)) + # o1 + register(Chat("o1-preview", can_stream=False, allows_system_prompt=False)) + register(Chat("o1-mini", can_stream=False, allows_system_prompt=False)) # The -instruct completion model register( Completion("gpt-3.5-turbo-instruct", default_max_tokens=256), @@ -248,7 +251,6 @@ def validate_logit_bias(cls, logit_bias): class Chat(Model): needs_key = "openai" key_env_var = "OPENAI_API_KEY" - can_stream: bool = True default_max_tokens = None @@ -268,6 +270,8 @@ def __init__( api_version=None, api_engine=None, headers=None, + can_stream=True, + allows_system_prompt=True, ): self.model_id = model_id self.key = key @@ -277,12 +281,16 @@ def __init__( self.api_version = api_version self.api_engine = api_engine self.headers = headers + self.can_stream = can_stream + self.allows_system_prompt = allows_system_prompt def __str__(self): return "OpenAI Chat: {}".format(self.model_id) def execute(self, prompt, stream, response, conversation=None): messages = [] + if prompt.system and not self.allows_system_prompt: + raise NotImplementedError("Model does not support system prompts") current_system = None if conversation is not None: for prev_response in conversation.responses: