Categorygithub.com/cloudcarver/tcgen
repository
0.3.4
Repository: https://github.com/cloudcarver/tcgen.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author

# README

Tool Calls Code Generator

Quick Start

  1. Install tcgen:

    go install github.com/cloudcarver/tcgen/cmd/tcgen@latest
    
  2. Define tool calls in test.yaml:

    functions:
    - name: RunPython
        description: Python code execution
        parameters:
        type: object
        required: [code]
        properties:
            code:
            type: string
            description: the Python code you want to run
    
  3. Run the code generator:

    tcgen -path test.yaml > fn_gen.go
    
  4. Then you can get the parameter types and the function signature in fn_gen.go, all you need to do is implementing the interfaces and then you can call tools with plain text returned by LLMs:

    type MyExecutor struct {
    }
    
    func (e *MyExecutor) RunPython(params *RunPythonParameters) (string, error) {
        // implement your logic here
        return "", nil
    }
    
    func main() {
        fc := NewFunctionCaller(&MyExecutor{})
        _, err := fc.Call("RunPython", `{"code": "print('hello')"}`)
    }