|
|
@@ -26,6 +26,7 @@ import (
|
|
|
"github.com/charmbracelet/crush/internal/log"
|
|
|
"github.com/charmbracelet/crush/internal/lsp"
|
|
|
"github.com/charmbracelet/crush/internal/message"
|
|
|
+ "github.com/charmbracelet/crush/internal/oauth/copilot"
|
|
|
"github.com/charmbracelet/crush/internal/permission"
|
|
|
"github.com/charmbracelet/crush/internal/session"
|
|
|
"golang.org/x/sync/errgroup"
|
|
|
@@ -582,15 +583,23 @@ func (c *coordinator) buildOpenrouterProvider(_, apiKey string, headers map[stri
|
|
|
return openrouter.New(opts...)
|
|
|
}
|
|
|
|
|
|
-func (c *coordinator) buildOpenaiCompatProvider(baseURL, apiKey string, headers map[string]string, extraBody map[string]any) (fantasy.Provider, error) {
|
|
|
+func (c *coordinator) buildOpenaiCompatProvider(baseURL, apiKey string, headers map[string]string, extraBody map[string]any, providerID string) (fantasy.Provider, error) {
|
|
|
opts := []openaicompat.Option{
|
|
|
openaicompat.WithBaseURL(baseURL),
|
|
|
openaicompat.WithAPIKey(apiKey),
|
|
|
}
|
|
|
- if c.cfg.Options.Debug {
|
|
|
- httpClient := log.NewHTTPClient()
|
|
|
+
|
|
|
+ // Set HTTP client based on provider and debug mode.
|
|
|
+ var httpClient *http.Client
|
|
|
+ if providerID == string(catwalk.InferenceProviderCopilot) {
|
|
|
+ httpClient = copilot.NewClient(c.cfg.Options.Debug)
|
|
|
+ } else if c.cfg.Options.Debug {
|
|
|
+ httpClient = log.NewHTTPClient()
|
|
|
+ }
|
|
|
+ if httpClient != nil {
|
|
|
opts = append(opts, openaicompat.WithHTTPClient(httpClient))
|
|
|
}
|
|
|
+
|
|
|
if len(headers) > 0 {
|
|
|
opts = append(opts, openaicompat.WithHeaders(headers))
|
|
|
}
|
|
|
@@ -745,7 +754,7 @@ func (c *coordinator) buildProvider(providerCfg config.ProviderConfig, model con
|
|
|
}
|
|
|
providerCfg.ExtraBody["tool_stream"] = true
|
|
|
}
|
|
|
- return c.buildOpenaiCompatProvider(baseURL, apiKey, headers, providerCfg.ExtraBody)
|
|
|
+ return c.buildOpenaiCompatProvider(baseURL, apiKey, headers, providerCfg.ExtraBody, providerCfg.ID)
|
|
|
case hyper.Name:
|
|
|
return c.buildHyperProvider(baseURL, apiKey)
|
|
|
default:
|