summaryrefslogtreecommitdiff
path: root/internal/llm/copilot.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-08-17 23:06:37 +0300
committerPaul Buetow <paul@buetow.org>2025-08-17 23:06:37 +0300
commit041d1f140436c6fdd223844b04c6592c84951878 (patch)
treee44df5d5691408216a26d472f7e96278095319d2 /internal/llm/copilot.go
parentd72f95ae4e6cd4e7a0beca2b9764511c10de8655 (diff)
refactor(ordering): place constructors immediately after type definitions as first functions
Diffstat (limited to 'internal/llm/copilot.go')
-rw-r--r--internal/llm/copilot.go34
1 files changed, 17 insertions, 17 deletions
diff --git a/internal/llm/copilot.go b/internal/llm/copilot.go
index 22b0ae4..680e7ec 100644
--- a/internal/llm/copilot.go
+++ b/internal/llm/copilot.go
@@ -54,6 +54,23 @@ type copilotChatResponse struct {
} `json:"error,omitempty"`
}
+// Constructor (kept among the first functions by convention)
+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"),
+ }
+}
+
func (c copilotClient) Chat(ctx context.Context, messages []Message, opts ...RequestOption) (string, error) {
if strings.TrimSpace(c.apiKey) == "" {
return nilStringErr("missing Copilot API key")
@@ -144,20 +161,3 @@ 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"),
- }
-}