GPTWorker is a project template designed to provide a set of tools for working with ChatGPT function calling. It includes functions for creating, deleting, reading files, listing directories, zipping directories, and unzipping directories.
dialogue := []openai.ChatCompletionMessage{
{Role: openai.ChatMessageRoleUser, Content: "Read current directory"},
}❯ go run cmd/main.go
Invoking list_directory function with arguments: {
"directory": "."
}
OpenAI answered the original request with: The current directory contains the following files and directories:
- .DS_Store
- README.md
- cmd
- go.mod
- go.sum
- internal
- pkgClone the project
git clone https://github.com/wedyarit/gpt-workerGo to the project directory
cd gpt-workerRun the application
go run cmd/main.goBuild the application
go run cmd/main.goDo not forget to set OPENAI_API_KEY env variable
export OPENAI_API_KEY="YOUR_OPENAI_API_KEY"You can create custom functions by implementing the Function interface:
type Function interface {
Execute(arguments string) string
Definition() *openai.FunctionDefinition
}To add your custom function to GPTWorker, you'll need to add the implementation to the functions_instances.
GPTWorker automatically adds this function to function_calling and GPT will be able to use this function when executing certain prompts.