Skip to content

feature: use tools schema to provide more context for complex function calls #1

@Roasbeef

Description

@Roasbeef

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions