driver

package
v0.0.0-...-4dbb630 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Drivers = []string{"openai", "anthropic", "gemini", "dify", "vertex"}

Functions

func ListString

func ListString() string

Types

type Anthropic

type Anthropic struct {
	anthropic.Client
	// contains filtered or unexported fields
}

Anthropic implements the driver interface for Anthropic's API

func NewAnthropic

func NewAnthropic(p config.Provider) (*Anthropic, error)

NewAnthropic creates a new Anthropic client.

func (*Anthropic) BatchCancel

func (a *Anthropic) BatchCancel(ctx context.Context, b *openai.Batch) error

func (*Anthropic) BatchReceive

func (a *Anthropic) BatchReceive(ctx context.Context, b *openai.Batch) (outputs []openai.BatchOutput, ret error)

func (*Anthropic) BatchRefresh

func (a *Anthropic) BatchRefresh(ctx context.Context, b *openai.Batch) error

func (*Anthropic) BatchSend

func (a *Anthropic) BatchSend(ctx context.Context, b *openai.Batch) error

func (*Anthropic) BatchUpload

func (a *Anthropic) BatchUpload(ctx context.Context, b *openai.Batch, inputs []openai.BatchInput) error

func (*Anthropic) Chat

func (a *Anthropic) Chat(ctx context.Context, req openai.ChatCompletionRequest) (c openai.ChatCompletionResponse, ret error)

func (*Anthropic) Complete

func (a *Anthropic) Complete(ctx context.Context, req openai.CompletionRequest) (c openai.CompletionResponse, err error)

func (*Anthropic) Embed

func (a *Anthropic) Embed(ctx context.Context, req openai.EmbeddingRequest) (e openai.EmbeddingResponse, err error)

func (*Anthropic) List

func (a *Anthropic) List(ctx context.Context) ([]openai.Model, error)

type Daemon

type Daemon struct {
	OpenAI
	// contains filtered or unexported fields
}

Daemon is the hairpin driver: basically, glorified IPC over HTTP.

Big think!

func NewDaemon

func NewDaemon(cfg config.Daemon) (*Daemon, error)

NewDaemon creates a daemon client for the simulating proxy.

func (*Daemon) Ping

func (d *Daemon) Ping() error

type Dify

type Dify struct {
	Provider config.Provider
}

Dify is a workflow GUI thing that can be used to build LLM agents.

func NewDify

func NewDify(p config.Provider) *Dify

NewDify creates a new Dify provider, implementing the official API.

func (*Dify) Complete

func (o *Dify) Complete(ctx context.Context, req openai.ChatCompletionRequest) (c openai.ChatCompletionResponse, err error)

func (*Dify) Embed

func (o *Dify) Embed(ctx context.Context, req openai.EmbeddingRequest) (e openai.EmbeddingResponse, err error)

func (*Dify) List

func (o *Dify) List(ctx context.Context) ([]openai.Model, error)

type Gemini

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

Gemini implements the driver interface for Google's Gemini API

func NewGemini

func NewGemini(p config.Provider) (*Gemini, error)

NewGemini creates a new Gemini client.

func (*Gemini) Chat

func (g *Gemini) Chat(ctx context.Context, req openai.ChatCompletionRequest) (c openai.ChatCompletionResponse, err error)

func (*Gemini) Complete

func (g *Gemini) Complete(ctx context.Context, req openai.CompletionRequest) (c openai.CompletionResponse, err error)

func (*Gemini) Embed

func (g *Gemini) Embed(ctx context.Context, req openai.EmbeddingRequest) (e openai.EmbeddingResponse, err error)

func (*Gemini) List

func (g *Gemini) List(ctx context.Context) ([]openai.Model, error)

type OpenAI

type OpenAI struct {
	openai.Client
	config.Provider
}

OpenAI is the most basic kind of driver, because it's the API that we're emulating.

Big think!

func NewOpenAI

func NewOpenAI(p config.Provider) (*OpenAI, error)

NewOpenAI creates a new OpenAI client.

func (*OpenAI) BatchCancel

func (o *OpenAI) BatchCancel(ctx context.Context, batch *openai.Batch) error

func (*OpenAI) BatchReceive

func (o *OpenAI) BatchReceive(ctx context.Context, batch *openai.Batch) (outputs []openai.BatchOutput, err error)

func (*OpenAI) BatchRefresh

func (o *OpenAI) BatchRefresh(ctx context.Context, batch *openai.Batch) error

func (*OpenAI) BatchSend

func (o *OpenAI) BatchSend(ctx context.Context, batch *openai.Batch) error

func (*OpenAI) BatchUpload

func (o *OpenAI) BatchUpload(ctx context.Context, batch *openai.Batch, inputs []openai.BatchInput) error

func (*OpenAI) Chat

func (o *OpenAI) Chat(ctx context.Context, req openai.ChatCompletionRequest) (c openai.ChatCompletionResponse, err error)

func (*OpenAI) Complete

func (o *OpenAI) Complete(ctx context.Context, req openai.CompletionRequest) (c openai.CompletionResponse, err error)

func (*OpenAI) Embed

func (o *OpenAI) Embed(ctx context.Context, req openai.EmbeddingRequest) (e openai.EmbeddingResponse, err error)

func (*OpenAI) List

func (o *OpenAI) List(ctx context.Context) ([]openai.Model, error)

type Vertex

type Vertex struct {
	config.Provider
	// contains filtered or unexported fields
}

Vertex implements the driver interface using Google's Vertex AI API

func NewVertex

func NewVertex(p config.Provider) (*Vertex, error)

NewVertex creates a new Vertex AI client.

func (*Vertex) BatchCancel

func (v *Vertex) BatchCancel(ctx context.Context, batch *openai.Batch) error

func (*Vertex) BatchReceive

func (v *Vertex) BatchReceive(ctx context.Context, batch *openai.Batch) (outputs []openai.BatchOutput, err error)

func (*Vertex) BatchRefresh

func (v *Vertex) BatchRefresh(ctx context.Context, batch *openai.Batch) error

func (*Vertex) BatchSend

func (v *Vertex) BatchSend(ctx context.Context, batch *openai.Batch) error

func (*Vertex) BatchUpload

func (v *Vertex) BatchUpload(ctx context.Context, batch *openai.Batch, inputs []openai.BatchInput) error

func (*Vertex) Chat

func (v *Vertex) Chat(ctx context.Context, req openai.ChatCompletionRequest) (c openai.ChatCompletionResponse, err error)

func (*Vertex) Complete

func (v *Vertex) Complete(ctx context.Context, req openai.CompletionRequest) (c openai.CompletionResponse, err error)

func (*Vertex) Embed

func (v *Vertex) Embed(ctx context.Context, req openai.EmbeddingRequest) (e openai.EmbeddingResponse, ret error)

func (*Vertex) List

func (v *Vertex) List(ctx context.Context) ([]openai.Model, error)

type VertexC

type VertexC struct {
	Role  string    `json:"role,omitempty"`
	Parts []VertexP `json:"parts"`
}

VertexC is a message content.

type VertexF

type VertexF struct {
	FileUri  string `json:"fileUri,omitempty"`
	MimeType string `json:"mimeType,omitempty"`
}

type VertexP

type VertexP struct {
	Text string   `json:"text,omitempty"`
	File *VertexF `json:"fileData,omitempty"`
}

VertexP is a message content part.

Jump to

Keyboard shortcuts

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