11package types
22
3+ // LLMProvider identifies the large language model backend used to author
4+ // commit messages.
35type LLMProvider string
46
57const (
@@ -11,35 +13,34 @@ const (
1113 ProviderOllama LLMProvider = "Ollama"
1214)
1315
16+ // String returns the provider identifier as a plain string.
1417func (p LLMProvider ) String () string {
1518 return string (p )
1619}
1720
21+ // IsValid reports whether the provider is part of the supported set.
1822func (p LLMProvider ) IsValid () bool {
1923 switch p {
2024 case ProviderOpenAI , ProviderClaude , ProviderGemini , ProviderGrok , ProviderGroq , ProviderOllama :
2125 return true
22- // LLMProvider identifies the large language model backend used to author
23- // commit messages.
2426 default :
2527 return false
2628 }
2729}
2830
31+ // GetSupportedProviders returns all available provider enums.
2932func GetSupportedProviders () []LLMProvider {
3033 return []LLMProvider {
3134 ProviderOpenAI ,
3235 ProviderClaude ,
3336 ProviderGemini ,
3437 ProviderGrok ,
35- // String returns the string form of the provider identifier.
3638 ProviderGroq ,
3739 ProviderOllama ,
3840 }
3941}
4042
41- // IsValid reports whether the provider is part of the supported set.
42-
43+ // GetSupportedProviderStrings returns the human-friendly names for providers.
4344func GetSupportedProviderStrings () []string {
4445 providers := GetSupportedProviders ()
4546 strings := make ([]string , len (providers ))
@@ -49,42 +50,39 @@ func GetSupportedProviderStrings() []string {
4950 return strings
5051}
5152
52- // GetSupportedProviders returns all available provider enums.
53-
53+ // ParseLLMProvider converts a string into an LLMProvider enum when supported.
5454func ParseLLMProvider (s string ) (LLMProvider , bool ) {
5555 provider := LLMProvider (s )
5656 return provider , provider .IsValid ()
5757}
5858
59- // Configuration structure
59+ // Config stores CLI-level configuration including named repositories.
6060type Config struct {
6161 GrokAPI string `json:"grok_api"`
6262 Repos map [string ]RepoConfig `json:"repos"`
6363}
6464
65- // GetSupportedProviderStrings returns the human-friendly names for providers.
66-
67- // Repository configuration
65+ // RepoConfig tracks metadata for a configured Git repository.
6866type RepoConfig struct {
6967 Path string `json:"path"`
7068 LastRun string `json:"last_run"`
7169}
7270
73- // Grok/ X.AI API request structure
71+ // GrokRequest represents a chat completion request sent to X.AI's API.
7472type GrokRequest struct {
75- // ParseLLMProvider converts a string into an LLMProvider enum when supported.
7673 Messages []Message `json:"messages"`
7774 Model string `json:"model"`
7875 Stream bool `json:"stream"`
7976 Temperature float64 `json:"temperature"`
8077}
8178
79+ // Message captures the role/content pairs exchanged with Grok.
8280type Message struct {
8381 Role string `json:"role"`
8482 Content string `json:"content"`
8583}
8684
87- // Grok/ X.AI API response structure
85+ // GrokResponse contains the relevant fields parsed from X.AI responses.
8886type GrokResponse struct {
8987 Message Message `json:"message,omitempty"`
9088 Choices []Choice `json:"choices,omitempty"`
@@ -95,12 +93,14 @@ type GrokResponse struct {
9593 Usage UsageInfo `json:"usage,omitempty"`
9694}
9795
96+ // Choice details a single response option returned by Grok.
9897type Choice struct {
9998 Message Message `json:"message"`
10099 Index int `json:"index"`
101100 FinishReason string `json:"finish_reason"`
102101}
103102
103+ // UsageInfo reports token usage statistics from Grok responses.
104104type UsageInfo struct {
105105 PromptTokens int `json:"prompt_tokens"`
106106 CompletionTokens int `json:"completion_tokens"`
0 commit comments