service

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInfo

type FileInfo struct {
	Name      string
	Size      int64
	Extension string
	MD5       string
	URL       string
}

FileInfo 文件信息

type LLMProvider

type LLMProvider interface {
	// ChatCompletion 普通对话
	ChatCompletion(ctx context.Context, messages []Message, config ModelConfig) (string, Usage, error)
	// StreamCompletion 流式对话
	StreamCompletion(ctx context.Context, messages []Message, config ModelConfig, callback func(chunk string, usage Usage, err error))
	// ValidateModel 验证模型配置
	ValidateModel(ctx context.Context, config ModelConfig) ([]ModelInfo, error)
}

LLMProvider LLM 提供商接口

type Message

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

Message LLM 聊天消息

type ModelConfig

type ModelConfig struct {
	BaseURL string `json:"base_url"`
	APIKey  string `json:"api_key"`
	Model   string `json:"model"`
}

ModelConfig LLM 模型配置

type ModelInfo

type ModelInfo struct {
	ID      string `json:"id"`
	OwnedBy string `json:"owned_by"`
}

ModelInfo 模型信息

type SMSProvider

type SMSProvider interface {
	// SendCode 发送验证码
	SendCode(phone string, code string) error
	// SendMessage 发送普通短信
	SendMessage(phone string, content string, templateCode string) error
}

SMSProvider 短信服务提供商接口

type StorageProvider

type StorageProvider interface {
	// UploadFile 上传文件
	UploadFile(file []byte, filename string) (*FileInfo, error)
	// DeleteFile 删除文件
	DeleteFile(fileID string) error
	// GetFileURL 获取文件访问URL
	GetFileURL(fileID string) (string, error)
}

StorageProvider 文件存储提供商接口

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Usage Token 使用情况

Jump to

Keyboard shortcuts

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