Documentation
¶
Index ¶
- Variables
- func CloseGormDB() error
- func EnsureDir(path string) error
- func FileExists(path string) bool
- func GetDefaultConfig() *models.AppConfig
- func GetGormDB() (*gorm.DB, error)
- func InitAppDirs() error
- func ValidateAIConfig(config *models.AIConfig) error
- type AIClient
- func (c *AIClient) CallAI(ctx context.Context, reqConfig *AIRequestConfig) *AIResponse
- func (c *AIClient) CallAIStream(ctx context.Context, systemPrompt, userPrompt string, enableStreaming bool) (string, error)
- func (c *AIClient) CallAISync(ctx context.Context, systemPrompt, userPrompt string) (string, error)
- type AIRequestConfig
- type AIRequestMode
- type AIResponse
- type Config
- func (c *Config) GetAppDir() string
- func (c *Config) GetAppSeriesDir() string
- func (c *Config) GetConfigDir() string
- func (c *Config) GetConfigPath() string
- func (c *Config) GetDbDir() string
- func (c *Config) GetDbPath() string
- func (c *Config) GetHomeDir() string
- func (c *Config) GetLogDir() string
- func (c *Config) GetLogPath() string
- func (c *Config) LoadConfig() *models.AppConfig
- func (c *Config) SaveConfig(config *models.AppConfig)
Constants ¶
This section is empty.
Variables ¶
View Source
var ConfigInstance = Config{}
Functions ¶
func CloseGormDB ¶
func CloseGormDB() error
func ValidateAIConfig ¶
ValidateAIConfig 验证AI配置是否完整
Types ¶
type AIClient ¶
type AIClient struct {
// contains filtered or unexported fields
}
AIClient AI客户端封装
func (*AIClient) CallAI ¶
func (c *AIClient) CallAI(ctx context.Context, reqConfig *AIRequestConfig) *AIResponse
CallAI 调用AI接口的统一入口
type AIRequestConfig ¶
type AIRequestConfig struct {
SystemPrompt string // 系统提示词
UserPrompt string // 用户输入内容
Mode AIRequestMode // 请求模式
Streaming bool // 是否启用流式输出显示
}
AIRequestConfig AI请求配置
type AIRequestMode ¶
type AIRequestMode int
AIRequestMode AI请求模式
const ( // AIRequestModeSync 同步(非流式)请求 AIRequestModeSync AIRequestMode = iota // AIRequestModeStream 流式请求 AIRequestModeStream )
type AIResponse ¶
type AIResponse struct {
Content string // AI返回的内容
Duration time.Duration // 请求耗时
Success bool // 是否成功
Error error // 错误信息
}
AIResponse AI响应结果
type Config ¶
type Config struct {
HomeDir string
AppSeriesDir string
AppDir string
ConfigDir string
ConfigPath string
DbDir string
DbPath string
LogDir string
LogPath string
}
func (*Config) GetAppSeriesDir ¶
func (*Config) GetConfigDir ¶
func (*Config) GetConfigPath ¶
func (*Config) GetHomeDir ¶
func (*Config) GetLogPath ¶
func (*Config) LoadConfig ¶
func (*Config) SaveConfig ¶
Click to show internal directories.
Click to hide internal directories.