summaryrefslogtreecommitdiff
path: root/internal/llm/copilot.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-08-17 23:03:24 +0300
committerPaul Buetow <paul@buetow.org>2025-08-17 23:03:24 +0300
commitd72f95ae4e6cd4e7a0beca2b9764511c10de8655 (patch)
treed5b034abce358cc26f271c3fc492d97da6e5734c /internal/llm/copilot.go
parent8dfbbbb6de0f0c67413ee157e976fc3eaee4f914 (diff)
refactor(ordering): types/constants first; exported before private; ensure consistent receiver semantics per file
Diffstat (limited to 'internal/llm/copilot.go')
-rw-r--r--internal/llm/copilot.go51
1 files changed, 26 insertions, 25 deletions
diff --git a/internal/llm/copilot.go b/internal/llm/copilot.go
index cf24565..22b0ae4 100644
--- a/internal/llm/copilot.go
+++ b/internal/llm/copilot.go
@@ -17,35 +17,19 @@ import (
// copilotClient implements Client against GitHub Copilot's Chat Completions API.
type copilotClient struct {
- httpClient *http.Client
- apiKey string
- baseURL string
- defaultModel string
+ httpClient *http.Client
+ apiKey string
+ baseURL string
+ defaultModel string
chatLogger logging.ChatLogger
}
-func newCopilot(baseURL, model, apiKey string) Client {
- if strings.TrimSpace(baseURL) == "" {
- baseURL = "https://api.githubcopilot.com"
- }
- if strings.TrimSpace(model) == "" {
- model = "gpt-4.1"
- }
- return copilotClient{
- httpClient: &http.Client{Timeout: 30 * time.Second},
- apiKey: apiKey,
- baseURL: strings.TrimRight(baseURL, "/"),
- defaultModel: model,
- chatLogger: logging.NewChatLogger("copilot"),
- }
-}
-
type copilotChatRequest struct {
- Model string `json:"model"`
- Messages []copilotMessage `json:"messages"`
- Temperature *float64 `json:"temperature,omitempty"`
- MaxTokens *int `json:"max_tokens,omitempty"`
- Stop []string `json:"stop,omitempty"`
+ Model string `json:"model"`
+ Messages []copilotMessage `json:"messages"`
+ Temperature *float64 `json:"temperature,omitempty"`
+ MaxTokens *int `json:"max_tokens,omitempty"`
+ Stop []string `json:"stop,omitempty"`
}
type copilotMessage struct {
@@ -160,3 +144,20 @@ func (c copilotClient) Chat(ctx context.Context, messages []Message, opts ...Req
// Provider metadata
func (c copilotClient) Name() string { return "copilot" }
func (c copilotClient) DefaultModel() string { return c.defaultModel }
+
+// Private constructor
+func newCopilot(baseURL, model, apiKey string) Client {
+ if strings.TrimSpace(baseURL) == "" {
+ baseURL = "https://api.githubcopilot.com"
+ }
+ if strings.TrimSpace(model) == "" {
+ model = "gpt-4.1"
+ }
+ return copilotClient{
+ httpClient: &http.Client{Timeout: 30 * time.Second},
+ apiKey: apiKey,
+ baseURL: strings.TrimRight(baseURL, "/"),
+ defaultModel: model,
+ chatLogger: logging.NewChatLogger("copilot"),
+ }
+}