Skip to content

Commit

Permalink
Fix delegator LLM config when config is set from UI (All-Hands-AI#2913)
Browse files Browse the repository at this point in the history
  • Loading branch information
li-boxuan authored Jul 13, 2024
1 parent 7e68de7 commit f249254
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions opendevin/server/session/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,25 @@ async def _create_controller(self, start_event: dict):
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)
Expand Down

0 comments on commit f249254

Please sign in to comment.