modelrepo

package
v0.0.76 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupported = errors.New("operation not supported")

ErrNotSupported is returned when an operation is not supported.

Functions

func SetupOllamaLocalInstance

func SetupOllamaLocalInstance(ctx context.Context, tag string) (string, testcontainers.Container, func(), error)

func SetupVLLMLocalInstance

func SetupVLLMLocalInstance(ctx context.Context, model string, tag string, toolParser string) (string, testcontainers.Container, func(), error)

SetupVLLMLocalInstance creates a vLLM container for testing.

Types

type CapabilityConfig

type CapabilityConfig struct {
	ContextLength int
	CanChat       bool
	CanEmbed      bool
	CanStream     bool
	CanPrompt     bool
	CanThink      bool
}

type ChatArgument added in v0.0.66

type ChatArgument interface {
	Apply(config *ChatConfig)
}

func WithMaxTokens

func WithMaxTokens(tokens int) ChatArgument

func WithSeed added in v0.0.66

func WithSeed(seed int) ChatArgument

func WithTemperature

func WithTemperature(temp float64) ChatArgument

func WithTool added in v0.0.69

func WithTool(tool Tool) ChatArgument

func WithTools added in v0.0.69

func WithTools(tools ...Tool) ChatArgument

func WithTopP added in v0.0.66

func WithTopP(p float64) ChatArgument

type ChatConfig added in v0.0.66

type ChatConfig struct {
	Temperature *float64 `json:"temperature,omitempty"`
	MaxTokens   *int     `json:"max_tokens,omitempty"`
	TopP        *float64 `json:"top_p,omitempty"`
	Seed        *int     `json:"seed,omitempty"`
	Tools       []Tool   `json:"tools,omitempty"`
}

type ChatResult added in v0.0.69

type ChatResult struct {
	Message   Message
	ToolCalls []ToolCall
}

type FunctionTool added in v0.0.69

type FunctionTool struct {
	Name        string      `json:"name"`
	Description string      `json:"description,omitempty"`
	Parameters  interface{} `json:"parameters,omitempty"`
}

type LLMChatClient

type LLMChatClient interface {
	Chat(ctx context.Context, messages []Message, args ...ChatArgument) (ChatResult, error)
}

Client interfaces

type LLMEmbedClient

type LLMEmbedClient interface {
	Embed(ctx context.Context, prompt string) ([]float64, error)
}

type LLMPromptExecClient

type LLMPromptExecClient interface {
	Prompt(ctx context.Context, systemInstruction string, temperature float32, prompt string) (string, error)
}

type LLMStreamClient

type LLMStreamClient interface {
	Stream(ctx context.Context, prompt string, args ...ChatArgument) (<-chan *StreamParcel, error)
}

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type MockChatClient

type MockChatClient struct{}

MockChatClient is a mock implementation of LLMChatClient for testing.

func (*MockChatClient) Chat

func (m *MockChatClient) Chat(ctx context.Context, messages []Message, opts ...ChatArgument) (ChatResult, error)

Chat returns a mock response.

func (*MockChatClient) Close

func (m *MockChatClient) Close() error

Close is a no-op for the mock client.

type MockEmbedClient

type MockEmbedClient struct{}

MockEmbedClient is a mock implementation of LLMEmbedClient for testing.

func (*MockEmbedClient) Close

func (m *MockEmbedClient) Close() error

Close is a no-op for the mock client.

func (*MockEmbedClient) Embed

func (m *MockEmbedClient) Embed(ctx context.Context, prompt string) ([]float64, error)

Embed returns a mock embedding.

type MockPromptClient

type MockPromptClient struct{}

MockPromptClient is a mock implementation of LLMPromptExecClient for testing.

func (*MockPromptClient) Close

func (m *MockPromptClient) Close() error

Close is a no-op for the mock client.

func (*MockPromptClient) Prompt

func (m *MockPromptClient) Prompt(ctx context.Context, systemInstruction string, temperature float32, prompt string) (string, error)

Prompt returns a mock response.

type MockProvider

type MockProvider struct {
	ID            string
	Name          string
	ContextLength int
	CanChatFlag   bool
	CanEmbedFlag  bool
	CanStreamFlag bool
	CanPromptFlag bool
	Backends      []string
}

MockProvider is a mock implementation of the Provider interface for testing.

func (*MockProvider) CanChat

func (m *MockProvider) CanChat() bool

CanChat returns whether the mock provider can chat.

func (*MockProvider) CanEmbed

func (m *MockProvider) CanEmbed() bool

CanEmbed returns whether the mock provider can embed.

func (*MockProvider) CanPrompt

func (m *MockProvider) CanPrompt() bool

CanPrompt returns whether the mock provider can prompt.

func (*MockProvider) CanStream

func (m *MockProvider) CanStream() bool

CanStream returns whether the mock provider can stream.

func (*MockProvider) CanThink

func (m *MockProvider) CanThink() bool

CanThink returns whether the mock provider can think.

func (*MockProvider) GetBackendIDs

func (m *MockProvider) GetBackendIDs() []string

GetBackendIDs returns the backend IDs for the mock provider.

func (*MockProvider) GetChatConnection

func (m *MockProvider) GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)

GetChatConnection returns a mock chat client.

func (*MockProvider) GetContextLength

func (m *MockProvider) GetContextLength() int

GetContextLength returns the context length for the mock provider.

func (*MockProvider) GetEmbedConnection

func (m *MockProvider) GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)

GetEmbedConnection returns a mock embed client.

func (*MockProvider) GetID

func (m *MockProvider) GetID() string

GetID returns the ID for the mock provider.

func (*MockProvider) GetPromptConnection

func (m *MockProvider) GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)

GetPromptConnection returns a mock prompt client.

func (*MockProvider) GetStreamConnection

func (m *MockProvider) GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)

GetStreamConnection returns a mock stream client.

func (*MockProvider) GetType

func (m *MockProvider) GetType() string

GetType returns the provider type for the mock provider.

func (*MockProvider) ModelName

func (m *MockProvider) ModelName() string

ModelName returns the model name for the mock provider.

type MockStreamClient

type MockStreamClient struct{}

MockStreamClient is a mock implementation of LLMStreamClient for testing.

func (*MockStreamClient) Close

func (m *MockStreamClient) Close() error

Close is a no-op for the mock client.

func (*MockStreamClient) Stream

func (m *MockStreamClient) Stream(ctx context.Context, prompt string, args ...ChatArgument) (<-chan *StreamParcel, error)

Stream returns a channel with mock stream parcels.

type Provider

type Provider interface {
	GetBackendIDs() []string
	ModelName() string
	GetID() string
	GetType() string
	GetContextLength() int
	CanChat() bool
	CanEmbed() bool
	CanStream() bool
	CanPrompt() bool
	CanThink() bool
	GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)
	GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)
	GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)
	GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)
}

type StreamParcel

type StreamParcel struct {
	Data  string
	Error error
}

type Tool added in v0.0.69

type Tool struct {
	Type     string        `json:"type"`
	Function *FunctionTool `json:"function,omitempty"`
}

type ToolCall added in v0.0.69

type ToolCall struct {
	ID       string `json:"id,omitempty"`
	Type     string `json:"type"` // only "function" for now
	Function struct {
		Name      string `json:"name"`
		Arguments string `json:"arguments"`
	} `json:"function"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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