compat_oai

package
v0.0.0-...-3efcfba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BasicText describes model capabilities for text-only GPT models.
	BasicText = ai.ModelSupports{
		Multiturn:  true,
		Tools:      true,
		SystemRole: true,
		Media:      false,
	}

	// Multimodal describes model capabilities for multimodal GPT models.
	Multimodal = ai.ModelSupports{
		Multiturn:  true,
		Tools:      true,
		SystemRole: true,
		Media:      true,
		ToolChoice: true,
	}
)

Functions

This section is empty.

Types

type ModelGenerator

type ModelGenerator struct {
	// contains filtered or unexported fields
}

ModelGenerator handles OpenAI generation requests

func NewModelGenerator

func NewModelGenerator(client *openai.Client, modelName string) *ModelGenerator

NewModelGenerator creates a new ModelGenerator instance

func (*ModelGenerator) Generate

func (g *ModelGenerator) Generate(ctx context.Context, req *ai.ModelRequest, handleChunk func(context.Context, *ai.ModelResponseChunk) error) (*ai.ModelResponse, error)

Generate executes the generation request

func (*ModelGenerator) GetRequest

func (*ModelGenerator) WithConfig

func (g *ModelGenerator) WithConfig(config any) *ModelGenerator

WithConfig adds configuration parameters from the model request see https://platform.openai.com/docs/api-reference/responses/create for more details on openai's request fields

func (*ModelGenerator) WithMessages

func (g *ModelGenerator) WithMessages(messages []*ai.Message) *ModelGenerator

WithMessages adds messages to the request

func (*ModelGenerator) WithTools

func (g *ModelGenerator) WithTools(tools []*ai.ToolDefinition) *ModelGenerator

WithTools adds tools to the request

type OpenAICompatible

type OpenAICompatible struct {

	// Opts contains request options for the OpenAI client.
	// Required: Must include at least WithAPIKey for authentication.
	// Optional: Can include other options like WithOrganization, WithBaseURL, etc.
	Opts []option.RequestOption

	// Provider is a unique identifier for the plugin.
	// This will be used as a prefix for model names (e.g., "myprovider/model-name").
	// Should be lowercase and match the plugin's Name() method.
	Provider string

	// API key to use with the desired plugin.
	APIKey string

	// Base URL to use for custom endpoints.
	// This should be used if you are running through a proxy or
	// using a non-official endpoint
	BaseURL string
	// contains filtered or unexported fields
}

OpenAICompatible is a plugin that provides compatibility with OpenAI's Compatible APIs. It allows defining models and embedders that can be used with Genkit.

func (*OpenAICompatible) DefineEmbedder

func (o *OpenAICompatible) DefineEmbedder(provider, name string, embedOpts *ai.EmbedderOptions) ai.Embedder

DefineEmbedder defines an embedder with a given name.

func (*OpenAICompatible) DefineModel

func (o *OpenAICompatible) DefineModel(provider, id string, opts ai.ModelOptions) ai.Model

DefineModel defines a model in the registry

func (*OpenAICompatible) Embedder

func (o *OpenAICompatible) Embedder(g *genkit.Genkit, name string) ai.Embedder

Embedder returns the ai.Embedder with the given name. It returns nil if the embedder was not defined.

func (*OpenAICompatible) Init

func (o *OpenAICompatible) Init(ctx context.Context) []api.Action

Init implements genkit.Plugin.

func (*OpenAICompatible) IsDefinedEmbedder

func (o *OpenAICompatible) IsDefinedEmbedder(g *genkit.Genkit, name string) bool

IsDefinedEmbedder reports whether the named [Embedder] is defined by this plugin.

func (*OpenAICompatible) IsDefinedModel

func (o *OpenAICompatible) IsDefinedModel(g *genkit.Genkit, name string) bool

IsDefinedModel reports whether the named [Model] is defined by this plugin.

func (*OpenAICompatible) ListActions

func (o *OpenAICompatible) ListActions(ctx context.Context) []api.ActionDesc

func (*OpenAICompatible) Model

func (o *OpenAICompatible) Model(g *genkit.Genkit, name string) ai.Model

Model returns the ai.Model with the given name. It returns nil if the model was not defined.

func (*OpenAICompatible) Name

func (o *OpenAICompatible) Name() string

Name implements genkit.Plugin.

func (*OpenAICompatible) ResolveAction

func (o *OpenAICompatible) ResolveAction(atype api.ActionType, name string) api.Action

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL