refactor(schemas, custom_tools): remove commented-out legacy code and clean up parameter handling
This commit is contained in:
parent
c93fe6a8db
commit
2b370a2a4d
@ -122,18 +122,6 @@ class AgentBase(BaseModel):
|
|||||||
def validate_api_key_id(cls, v, values):
|
def validate_api_key_id(cls, v, values):
|
||||||
return v
|
return v
|
||||||
|
|
||||||
# Código anterior (comentado temporariamente)
|
|
||||||
# # Se o tipo for llm, api_key_id é obrigatório
|
|
||||||
# if "type" in values and values["type"] == "llm" and not v:
|
|
||||||
# # Verifica se tem api_key no config (retrocompatibilidade)
|
|
||||||
# if "config" in values and values["config"] and "api_key" in values["config"]:
|
|
||||||
# # Tem api_key no config, então aceita
|
|
||||||
# return v
|
|
||||||
# raise ValueError(
|
|
||||||
# "api_key_id é obrigatório para agentes do tipo llm"
|
|
||||||
# )
|
|
||||||
# return v
|
|
||||||
|
|
||||||
@validator("config")
|
@validator("config")
|
||||||
def validate_config(cls, v, values):
|
def validate_config(cls, v, values):
|
||||||
if "type" in values and values["type"] == "a2a":
|
if "type" in values and values["type"] == "a2a":
|
||||||
|
@ -22,7 +22,6 @@ class CustomToolBuilder:
|
|||||||
values = tool_config.get("values", {})
|
values = tool_config.get("values", {})
|
||||||
error_handling = tool_config.get("error_handling", {})
|
error_handling = tool_config.get("error_handling", {})
|
||||||
|
|
||||||
# Garante que todos os parâmetros são dicts
|
|
||||||
path_params = parameters.get("path_params") or {}
|
path_params = parameters.get("path_params") or {}
|
||||||
query_params = parameters.get("query_params") or {}
|
query_params = parameters.get("query_params") or {}
|
||||||
body_params = parameters.get("body_params") or {}
|
body_params = parameters.get("body_params") or {}
|
||||||
@ -149,7 +148,6 @@ class CustomToolBuilder:
|
|||||||
"""Builds a list of tools based on the provided configuration. Accepts both 'tools' and 'custom_tools' (with http_tools)."""
|
"""Builds a list of tools based on the provided configuration. Accepts both 'tools' and 'custom_tools' (with http_tools)."""
|
||||||
self.tools = []
|
self.tools = []
|
||||||
|
|
||||||
# Permite receber tanto 'tools' quanto 'custom_tools' (com http_tools)
|
|
||||||
http_tools = []
|
http_tools = []
|
||||||
if tools_config.get("http_tools"):
|
if tools_config.get("http_tools"):
|
||||||
http_tools = tools_config.get("http_tools", [])
|
http_tools = tools_config.get("http_tools", [])
|
||||||
@ -157,7 +155,6 @@ class CustomToolBuilder:
|
|||||||
"http_tools"
|
"http_tools"
|
||||||
):
|
):
|
||||||
http_tools = tools_config["custom_tools"].get("http_tools", [])
|
http_tools = tools_config["custom_tools"].get("http_tools", [])
|
||||||
# Suporte para caso tools seja um dict com http_tools
|
|
||||||
elif (
|
elif (
|
||||||
tools_config.get("tools")
|
tools_config.get("tools")
|
||||||
and isinstance(tools_config["tools"], dict)
|
and isinstance(tools_config["tools"], dict)
|
||||||
|
Loading…
Reference in New Issue
Block a user