Skip to content

LLM tool calls code generation tools for golang

Notifications You must be signed in to change notification settings

cloudcarver/tcgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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')"}`)
    }