Documentation
¶
Overview ¶
Package service 声明框架预留的外部服务扩展点接口(短信、对象存储、LLM).
该包当前为实验性(Experimental)API:框架本身没有引用它,也不附带实现, 接口签名可能随实际需求在 1.x 的 minor 版本中调整或删除,不承诺源码兼容。 如果需要在业务中集成这些能力,建议先在自己的包内定义接口,待本包稳定后再迁移。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 ModelConfig ¶
type ModelConfig struct {
BaseURL string `json:"base_url"`
APIKey string `json:"api_key"`
Model string `json:"model"`
}
ModelConfig LLM 模型配置
type SMSProvider ¶
type SMSProvider interface {
// SendCode 发送验证码
SendCode(ctx context.Context, phone string, code string) error
// SendMessage 发送普通短信
SendMessage(ctx context.Context, phone string, content string, templateCode string) error
}
SMSProvider 短信服务提供商接口. 远程调用应遵循 ctx 的超时/取消;实现方需在 ctx 结束时尽快返回.
type StorageProvider ¶
type StorageProvider interface {
// UploadFile 上传文件
UploadFile(ctx context.Context, file []byte, filename string) (*FileInfo, error)
// DeleteFile 删除文件
DeleteFile(ctx context.Context, fileID string) error
// GetFileURL 获取文件访问URL
GetFileURL(ctx context.Context, fileID string) (string, error)
}
StorageProvider 文件存储提供商接口. 上传/下载/删除均可能访问远端存储,因此统一接收 ctx.