add select agent llm handler (#1713)
This commit is contained in:
@@ -94,6 +94,7 @@ class Settings(BaseSettings):
|
|||||||
# ACTIVE LLM PROVIDER
|
# ACTIVE LLM PROVIDER
|
||||||
LLM_KEY: str = "OPENAI_GPT4O"
|
LLM_KEY: str = "OPENAI_GPT4O"
|
||||||
SECONDARY_LLM_KEY: str | None = None
|
SECONDARY_LLM_KEY: str | None = None
|
||||||
|
SELECT_AGENT_LLM_KEY: str | None = None
|
||||||
# COMMON
|
# COMMON
|
||||||
LLM_CONFIG_TIMEOUT: int = 300
|
LLM_CONFIG_TIMEOUT: int = 300
|
||||||
LLM_CONFIG_MAX_TOKENS: int = 4096
|
LLM_CONFIG_MAX_TOKENS: int = 4096
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ LLM_API_HANDLER = LLMAPIHandlerFactory.get_llm_api_handler(SettingsManager.get_s
|
|||||||
SECONDARY_LLM_API_HANDLER = LLMAPIHandlerFactory.get_llm_api_handler(
|
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
|
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_CONTEXT_MANAGER = WorkflowContextManager()
|
||||||
WORKFLOW_SERVICE = WorkflowService()
|
WORKFLOW_SERVICE = WorkflowService()
|
||||||
AGENT_FUNCTION = AgentFunction()
|
AGENT_FUNCTION = AgentFunction()
|
||||||
|
|||||||
@@ -2161,12 +2161,7 @@ async def select_from_dropdown(
|
|||||||
step_id=step.step_id,
|
step_id=step.step_id,
|
||||||
task_id=task.task_id,
|
task_id=task.task_id,
|
||||||
)
|
)
|
||||||
if context.is_date_related:
|
json_response = await app.SELECT_AGENT_LLM_API_HANDLER(prompt=prompt, step=step, prompt_name="custom-select")
|
||||||
# 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")
|
|
||||||
value: str | None = json_response.get("value", None)
|
value: str | None = json_response.get("value", None)
|
||||||
single_select_result.value = value
|
single_select_result.value = value
|
||||||
select_reason: str | None = json_response.get("reasoning", None)
|
select_reason: str | None = json_response.get("reasoning", None)
|
||||||
@@ -2618,7 +2613,7 @@ async def normal_select(
|
|||||||
options=options_html,
|
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")
|
index: int | None = json_response.get("index")
|
||||||
value: str | None = json_response.get("value")
|
value: str | None = json_response.get("value")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user