client

package
v1.0.0-beta.20241028 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseClient

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

func NewBaseClient

func NewBaseClient(info ClientInfo) *BaseClient

func (*BaseClient) Complete

func (c *BaseClient) Complete(ctx context.Context, inputText string, fromLanguage string, toLanguage string) (string, error)

func (*BaseClient) GetClientInfo

func (c *BaseClient) GetClientInfo() ClientInfo

type Cache

type Cache interface {
	Get(key string) (string, error)
	Set(key string, value string, expiration time.Duration) error
}

type Client

type Client interface {
	Complete(ctx context.Context, inputText string, fromLanguage string, toLanguage string, forceRefresh bool) (string, error)
	GetClientInfo() ClientInfo
}

type ClientInfo

type ClientInfo struct {
	Name             string
	MaxTokens        int
	Temperature      float32
	RateLimit        float64
	Prompt           string
	ModelName        string
	BaseURL          string
	Endpoint         string
	CacheExpireHours int
}

type ClientManager

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

func NewClientManager

func NewClientManager() *ClientManager

func (*ClientManager) AddClient

func (m *ClientManager) AddClient(endpoint string, client Client)

func (*ClientManager) GetAllEndpoints

func (m *ClientManager) GetAllEndpoints() []string

func (*ClientManager) GetAllNames

func (m *ClientManager) GetAllNames() []string

func (*ClientManager) GetClientByEndpoint

func (m *ClientManager) GetClientByEndpoint(endpoint string) (Client, error)

func (*ClientManager) GetClientByName

func (m *ClientManager) GetClientByName(name string) (Client, error)

type MemoryCache

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

func NewMemoryCache

func NewMemoryCache(defaultExpiration, cleanupInterval time.Duration) *MemoryCache

func (*MemoryCache) Get

func (mc *MemoryCache) Get(key string) (string, error)

func (*MemoryCache) Set

func (mc *MemoryCache) Set(key string, value string, expiration time.Duration) error

type OpenAIClient

type OpenAIClient struct {
	BaseClient
	// contains filtered or unexported fields
}

func NewOpenAIClient

func NewOpenAIClient(info ClientInfo, apiKey string) *OpenAIClient

func (*OpenAIClient) Complete

func (c *OpenAIClient) Complete(ctx context.Context, inputText string, fromLanguage string, toLanguage string, forceRefresh bool) (string, error)

func (*OpenAIClient) GetClientInfo

func (c *OpenAIClient) GetClientInfo() ClientInfo

Jump to

Keyboard shortcuts

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