-
Notifications
You must be signed in to change notification settings - Fork 18
feature: use tools schema to provide more context for complex function calls #1
Description
Today we create a series of wrappers around the base set of lnd gRPC API endpoints. This works well for simple calls like addinvoice that have simple inputs, but for other calls, we want to be able to give more context to the agent in form of a better input schema.
Some examples of this are here: https://python.langchain.com/docs/modules/agents/tools/how_to/tool_input_validation
As an example, consider the new_address tool. The input is actually an enum of the address type with the following values: WITNESS_PUBKEY_HASH, TAPROOT_PUBKEY, etc, etc. We can define a more structred input that looks something like:
class AddrTypes(Enum):
TAPROOT_PUBKEY = 0
WITNESS_PUBKEY_HASH = 1
class NewAddrSchema(BaseModel):
addr_type: AddrTypes = Field("the type of address to create")Then each time we use the @tool decorator, we also pass the schema for the input like @tool(args_schema=NewAddrSchema).
For other calls that need more arguments, like finding a route on LN to a dest, then we can use a similar pattern to be able to profile few-shot examples for each of the fields, and also validate them.