ai

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TargetPartsCount is the expected number of parts when splitting target (provider/model).
	TargetPartsCount = 2
	// StreamReadBufferSize is the buffer size for reading SSE streams.
	StreamReadBufferSize = 4096
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

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

Proxy implements proxy.Proxy for LLM upstream connections.

func NewProxy

func NewProxy(opts ProxyOptions) (*Proxy, error)

NewProxy creates a new AIProxy instance.

func (*Proxy) Close

func (p *Proxy) Close() error

Close releases resources.

func (*Proxy) Endpoint

func (p *Proxy) Endpoint() *target.Endpoint

Endpoint returns the endpoint info associated with this proxy.

func (*Proxy) ID

func (p *Proxy) ID() string

ID returns the unique identifier for the proxy.

func (*Proxy) LLMAdapter

func (p *Proxy) LLMAdapter() (ai.LLMAdapter, error)

LLMAdapter returns the initialized LLMAdapter for the proxy.

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(ctx context.Context, hzCtx *app.RequestContext)

ServeHTTP handles incoming HTTP requests and proxies them to the target LLM provider.

func (*Proxy) SetEndpoint

func (p *Proxy) SetEndpoint(ep *target.Endpoint)

SetEndpoint updates the endpoint info associated with this proxy.

func (*Proxy) Target

func (p *Proxy) Target() string

Target returns the backend target (provider/model format).

type ProxyOptions

type ProxyOptions struct {
	ID             string
	Target         string
	AIOptions      *config.AIOptions
	MetricsEnabled bool
	Pricing        *config.AIPricingOptions
	Endpoint       *target.Endpoint
}

ProxyOptions contains configuration options for creating a new AI Proxy.

Jump to

Keyboard shortcuts

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