mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Fix delegator LLM config when config is set from UI (#2913)
This commit is contained in:
parent
7e68de746d
commit
f249254ba4
@ -81,18 +81,25 @@ class AgentSession:
|
||||
if value != ''
|
||||
} # remove empty values, prevent FE from sending empty strings
|
||||
agent_cls = args.get(ConfigType.AGENT, config.default_agent)
|
||||
llm_config = config.get_llm_config_from_agent(agent_cls)
|
||||
model = args.get(ConfigType.LLM_MODEL, llm_config.model)
|
||||
api_key = args.get(ConfigType.LLM_API_KEY, llm_config.api_key)
|
||||
api_base = llm_config.base_url
|
||||
confirmation_mode = args.get(
|
||||
ConfigType.CONFIRMATION_MODE, config.confirmation_mode
|
||||
)
|
||||
max_iterations = args.get(ConfigType.MAX_ITERATIONS, config.max_iterations)
|
||||
|
||||
logger.info(f'Creating agent {agent_cls} using LLM {model}')
|
||||
llm = LLM(model=model, api_key=api_key, base_url=api_base)
|
||||
# override default LLM config
|
||||
default_llm_config = config.get_llm_config()
|
||||
default_llm_config.model = args.get(
|
||||
ConfigType.LLM_MODEL, default_llm_config.model
|
||||
)
|
||||
default_llm_config.api_key = args.get(
|
||||
ConfigType.LLM_API_KEY, default_llm_config.api_key
|
||||
)
|
||||
|
||||
# TODO: override other LLM config & agent config groups (#2075)
|
||||
|
||||
llm = LLM(llm_config=config.get_llm_config_from_agent(agent_cls))
|
||||
agent = Agent.get_cls(agent_cls)(llm)
|
||||
logger.info(f'Creating agent {agent.name} using LLM {llm}')
|
||||
if isinstance(agent, CodeActAgent):
|
||||
if not self.runtime or not (
|
||||
isinstance(self.runtime, ServerRuntime)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user