ai

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommitMessageResponseSchema = GenerateSchema[CommitMessageResponse]()

Generate the JSON schema at initialization time

View Source
var HistoryAnalysisResponseSchema = GenerateSchema[HistoryAnalysisResponse]()

Generate the JSON schema at initialization time

View Source
var QuestionsResponseSchema = GenerateSchema[QuestionsResponse]()

Generate the JSON schema at initialization time

Functions

func GenerateSchema

func GenerateSchema[T any]() interface{}

GenerateSchema creates a JSON schema for a given type T. This is used for OpenAI Structured Outputs.

Types

type CommitMessageResponse

type CommitMessageResponse struct {
	Subject string `json:"subject" jsonschema_description:"The commit message subject line, following Conventional Commits specification."`
	Body    string `json:"body" jsonschema_description:"The detailed commit message body explaining the 'what' and 'why'."`
}

type HistoryAnalysisResponse

type HistoryAnalysisResponse struct {
	IsRelevant bool     `json:"is_relevant" jsonschema_description:"Whether the recent history is relevant to the current changes."`
	KeyContext []string `` /* 131-byte string literal not displayed */
}

type OllamaClient

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

func NewOllamaClient

func NewOllamaClient(baseURL, model string) *OllamaClient

func (*OllamaClient) AnalyzeHistory

func (c *OllamaClient) AnalyzeHistory(ctx context.Context, diff string, history string) (*HistoryAnalysisResponse, error)

func (*OllamaClient) GenerateCommitMessage

func (c *OllamaClient) GenerateCommitMessage(ctx context.Context, diff string, history string, answers map[string]string) (string, error)

func (*OllamaClient) GenerateQuestions

func (c *OllamaClient) GenerateQuestions(ctx context.Context, diff string, history string) ([]string, error)

type OpenAIClient

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

func NewOpenAIClient

func NewOpenAIClient(apiKey string) *OpenAIClient

func (*OpenAIClient) AnalyzeHistory

func (c *OpenAIClient) AnalyzeHistory(ctx context.Context, diff string, history string) (*HistoryAnalysisResponse, error)

func (*OpenAIClient) GenerateCommitMessage

func (c *OpenAIClient) GenerateCommitMessage(ctx context.Context, diff string, history string, answers map[string]string) (string, error)

func (*OpenAIClient) GenerateQuestions

func (c *OpenAIClient) GenerateQuestions(ctx context.Context, diff string, history string) ([]string, error)

type Provider

type Provider interface {
	GenerateQuestions(ctx context.Context, diff string, history string) ([]string, error)
	GenerateCommitMessage(ctx context.Context, diff string, history string, answers map[string]string) (string, error)
	AnalyzeHistory(ctx context.Context, diff string, history string) (*HistoryAnalysisResponse, error)
}

Provider defines the interface for AI providers.

func NewClient

func NewClient(cfg *config.Config) (Provider, error)

NewClient creates a new AI provider based on the configuration.

type QuestionsResponse

type QuestionsResponse struct {
	Questions []string `` /* 147-byte string literal not displayed */
}

Jump to

Keyboard shortcuts

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