mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-08 05:47:07 +09:00
.. | ||
generator | ||
main.go | ||
README.md | ||
swagger.json | ||
swagger.yaml |
OpenAPI to OpenAI Tools Generator
This generator converts an OpenAPI specification (swagger.yaml) into OpenAI function tools.
Usage
Run the generator with:
go run main.go
This will:
- Read the
swagger.yaml
file in the current directory - Convert each API endpoint into an OpenAI function tool
- Create a file at
pkg/assistant/tools.gen.go
with the generated tools
Configuration
You can customize the generator by modifying:
ignoredProperties
: Properties to exclude from the generated tools- Output path: Change the output directory and filename in the code
- Function naming: Modify the
sanitizeName
function to change how functions are named
Generated Output
The generated output is a Go file containing:
- A package declaration:
package assistant
- Required imports
- A variable
AnytypeTools
containing an array of OpenAI tools
Integration
After generating the tools, you can import them in your Go code:
import "github.com/anyproto/anytype-heart/pkg/assistant"
// Use the tools
tools := assistant.AnytypeTools
Then use these tools with the OpenAI API or with the included tool handlers.