mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
support o1-series
This commit is contained in:
parent
50cdecf627
commit
325e45247e
4 changed files with 13 additions and 1 deletions
|
|
@ -90,6 +90,9 @@ class LLMConfig(YamlModel):
|
|||
# Cost Control
|
||||
calc_usage: bool = True
|
||||
|
||||
# For Messages Control
|
||||
use_system_prompt: bool = True
|
||||
|
||||
@field_validator("api_key")
|
||||
@classmethod
|
||||
def check_llm_key(cls, v):
|
||||
|
|
|
|||
|
|
@ -37,7 +37,11 @@ def register_provider(keys):
|
|||
|
||||
def create_llm_instance(config: LLMConfig) -> BaseLLM:
|
||||
"""get the default llm provider"""
|
||||
return LLM_REGISTRY.get_provider(config.api_type)(config)
|
||||
llm = LLM_REGISTRY.get_provider(config.api_type)(config)
|
||||
if llm.use_system_prompt and not config.use_system_prompt:
|
||||
# for models like o1-series, default openai provider.use_system_prompt is True, but it should be False for o1-*
|
||||
llm.use_system_prompt = config.use_system_prompt
|
||||
return llm
|
||||
|
||||
|
||||
# Registry instance
|
||||
|
|
|
|||
|
|
@ -138,6 +138,10 @@ class OpenAILLM(BaseLLM):
|
|||
"model": self.model,
|
||||
"timeout": self.get_timeout(timeout),
|
||||
}
|
||||
if "o1-" in self.model:
|
||||
# compatible to openai o1-series
|
||||
kwargs["temperature"] = 1
|
||||
kwargs.pop("max_tokens")
|
||||
if extra_kwargs:
|
||||
kwargs.update(extra_kwargs)
|
||||
return kwargs
|
||||
|
|
|
|||
|
|
@ -397,6 +397,7 @@ def count_input_tokens(messages, model="gpt-3.5-turbo-0125"):
|
|||
"gpt-4-turbo",
|
||||
"gpt-4-turbo-preview",
|
||||
"gpt-4-0125-preview",
|
||||
"gpt-4-1106-preview",
|
||||
"gpt-4-turbo",
|
||||
"gpt-4-vision-preview",
|
||||
"gpt-4-1106-vision-preview",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue