add select agent llm handler (#1713)

This commit is contained in:
Shuchang Zheng
2025-02-04 19:16:39 +08:00
committed by GitHub
parent 4bdc32ce2c
commit 430c6b7851
3 changed files with 8 additions and 7 deletions

View File

@@ -94,6 +94,7 @@ class Settings(BaseSettings):
# ACTIVE LLM PROVIDER
LLM_KEY: str = "OPENAI_GPT4O"
SECONDARY_LLM_KEY: str | None = None
SELECT_AGENT_LLM_KEY: str | None = None
# COMMON
LLM_CONFIG_TIMEOUT: int = 300
LLM_CONFIG_MAX_TOKENS: int = 4096

View File

@@ -35,6 +35,11 @@ LLM_API_HANDLER = LLMAPIHandlerFactory.get_llm_api_handler(SettingsManager.get_s
SECONDARY_LLM_API_HANDLER = LLMAPIHandlerFactory.get_llm_api_handler(
SETTINGS_MANAGER.SECONDARY_LLM_KEY if SETTINGS_MANAGER.SECONDARY_LLM_KEY else SETTINGS_MANAGER.LLM_KEY
)
SELECT_AGENT_LLM_API_HANDLER = (
LLMAPIHandlerFactory.get_llm_api_handler(SETTINGS_MANAGER.SELECT_AGENT_LLM_KEY)
if SETTINGS_MANAGER.SELECT_AGENT_LLM_KEY
else SECONDARY_LLM_API_HANDLER
)
WORKFLOW_CONTEXT_MANAGER = WorkflowContextManager()
WORKFLOW_SERVICE = WorkflowService()
AGENT_FUNCTION = AgentFunction()

View File

@@ -2161,12 +2161,7 @@ async def select_from_dropdown(
step_id=step.step_id,
task_id=task.task_id,
)
if context.is_date_related:
# HACK: according to the test, secondary LLM is not doing well on the date picker
# using the main LLM to handle the case
json_response = await app.LLM_API_HANDLER(prompt=prompt, step=step, prompt_name="custom-select")
else:
json_response = await app.SECONDARY_LLM_API_HANDLER(prompt=prompt, step=step, prompt_name="custom-select")
json_response = await app.SELECT_AGENT_LLM_API_HANDLER(prompt=prompt, step=step, prompt_name="custom-select")
value: str | None = json_response.get("value", None)
single_select_result.value = value
select_reason: str | None = json_response.get("reasoning", None)
@@ -2618,7 +2613,7 @@ async def normal_select(
options=options_html,
)
json_response = await app.LLM_API_HANDLER(prompt=prompt, step=step, prompt_name="custom-select")
json_response = await app.SELECT_AGENT_LLM_API_HANDLER(prompt=prompt, step=step, prompt_name="custom-select")
index: int | None = json_response.get("index")
value: str | None = json_response.get("value")