File size: 838 Bytes
df07284
1870dee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from .state import AgentState, tools_config

def validate_tool(state: AgentState):
    selected_tool = state["selected_tool"]

    # Find selected tool configuration
    tool = next(
        (t for t in tools_config
         if t["name"] == selected_tool),
        None
    )

    if tool is None:
        return {
            "tool_args": {},
            "missing_params": []
        }

    global_params = state["global_params"]

    tool_args = {}
    missing = []

    for param in tool["parameters"]:
        name = param["name"]
        required = param["required"]

        value = global_params.get(name)

        if value is None:
            if required:
                missing.append(name)
        else:
            tool_args[name] = value

    return {
        "tool_args": tool_args,
        "missing_params": missing
    }