Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement tool DSL #25

Open
nsmnds opened this issue Sep 26, 2024 · 0 comments
Open

Implement tool DSL #25

nsmnds opened this issue Sep 26, 2024 · 0 comments

Comments

@nsmnds
Copy link
Collaborator

nsmnds commented Sep 26, 2024

Implement tool DSL

Currently there is a DSL which builds an agent. In order to configure tool which can be used by an agent you currently have to instantiate the objects yourself. For example like this:

object SaveInvoiceTool : Tool {

    val numberParameter = Parameter.Primitive(
        name = "number",
        description = "The invoice number",
        isRequired = true,
        ParameterType.Primitive.String
    )

    val date = Parameter.Primitive(
        name = "date",
        description = "The invoice date",
        isRequired = false,
        ParameterType.Primitive.String
    )

    val customerName = Parameter.Primitive(
        name = "customerName",
        description = "The invoice customer",
        isRequired = true,
        ParameterType.Primitive.String
    )

    val lines = Parameter.Complex.Array(
        name = "lines",
        description = "The invoice lines",
        isRequired = true,
        itemDefinition = Parameter.Complex.Object(
            name = "itemDefinition",
            description = "The invoice item",
            isRequired = true,
            parameters = listOf(
                Parameter.Primitive(
                    name = "itemName",
                    description = "The invoice item",
                    isRequired = true,
                    ParameterType.Primitive.String
                ),
                Parameter.Primitive(
                    name = "costAmount",
                    description = "The invoiced amound",
                    isRequired = true,
                    ParameterType.Primitive.String
                )
            )
        )
    )

    override val description: String = "Saves the invoice"
    override val name = ToolName("saveInvoice")
    override val parameters: List<Parameter> = listOf(numberParameter, date, customerName, lines)
    override val handler: suspend (JsonObject) -> String = { arguments ->
        println("Saved invoice: $arguments")
        "Saved"
    }

}

Please implement a DSL which under the hood instantiate a tool with parameters. Something like:

tool {
 name = "saveInvoice"
 description = "Saves the invoice"
 stringParameter {
   name = "number"
 }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant