Skip to content

Project template designed to provide a set of tools for working with ChatGPT function calling in Go

License

Notifications You must be signed in to change notification settings

Wedyarit/gpt-worker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPT Worker

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.

Go Version Version MIT License

Example of usage

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
- pkg

Run Locally

Clone the project

  git clone https://github.com/wedyarit/gpt-worker

Go to the project directory

  cd gpt-worker

Run the application

  go run cmd/main.go

Build the application

  go run cmd/main.go

Do not forget to set OPENAI_API_KEY env variable

  export OPENAI_API_KEY="YOUR_OPENAI_API_KEY"

API Reference

Function Interface

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.

Authors

License

MIT

About

Project template designed to provide a set of tools for working with ChatGPT function calling in Go

Resources

License

Stars

Watchers

Forks

Languages