1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-08 05:47:07 +09:00
anytype-heart/cmd/generator
2025-04-20 02:04:15 +02:00
..
generator custom object creator 2025-04-20 02:04:15 +02:00
main.go custom object creator 2025-04-20 02:04:15 +02:00
README.md assistant: use the internal api instead 2025-04-19 20:45:13 +02:00
swagger.json assistant: use the internal api instead 2025-04-19 20:45:13 +02:00
swagger.yaml assistant: use the internal api instead 2025-04-19 20:45:13 +02:00

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:

  1. Read the swagger.yaml file in the current directory
  2. Convert each API endpoint into an OpenAI function tool
  3. 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:

  1. A package declaration: package assistant
  2. Required imports
  3. 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.