ai

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GenerateCommitMessage 接受一个 diff 并返回一个 AI 生成的 commit message
	GenerateCommitMessage(promptTemplate string, diff string) (string, error)
}

Client 是所有 AI 客户端必须实现的接口

func GetClient

func GetClient(cfg config.Config) (Client, error)

GetClient 是一个工厂函数,根据配置返回正确的 AI 客户端

type GeminiClient

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

GeminiClient 实现了 ai.Client 接口 (示例)

func NewGeminiClient

func NewGeminiClient(cfg config.GeminiConfig, client *resty.Client) (*GeminiClient, error)

NewGeminiClient 创建一个新的 Gemini 客户端

func (*GeminiClient) GenerateCommitMessage

func (c *GeminiClient) GenerateCommitMessage(promptTemplate string, diff string) (string, error)

GenerateCommitMessage 实现了 ai.Client 接口

type OpenAIClient

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

OpenAIClient 实现了 ai.Client 接口

func NewOpenAIClient

func NewOpenAIClient(cfg config.OpenAIConfig, client *resty.Client) (*OpenAIClient, error)

NewOpenAIClient 创建一个新的 OpenAI 客户端

func (*OpenAIClient) GenerateCommitMessage

func (c *OpenAIClient) GenerateCommitMessage(promptTemplate string, diff string) (string, error)

GenerateCommitMessage 实现了 ai.Client 接口

type OpenRouterClient

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

OpenRouterClient 实现了 ai.Client 接口 (示例) OpenRouter 使用与 OpenAI 兼容的 API,所以我们可以复用很多逻辑

func NewOpenRouterClient

func NewOpenRouterClient(cfg config.OpenRouterConfig, client *resty.Client) (*OpenRouterClient, error)

NewOpenRouterClient 创建一个新的 OpenRouter 客户端

func (*OpenRouterClient) GenerateCommitMessage

func (c *OpenRouterClient) GenerateCommitMessage(promptTemplate string, diff string) (string, error)

GenerateCommitMessage 实现了 ai.Client 接口 注意:这使用了与 OpenAI 相同的请求/响应结构

Jump to

Keyboard shortcuts

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