mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 14:51:44 +00:00
llmproxy: Make dotcom API URL configurable (#51629)
This commit is contained in:
parent
cb3f8ab1de
commit
554c2f63a3
@ -11,8 +11,6 @@ import (
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
const endpoint = "https://sourcegraph.com/.api/graphql"
|
||||
|
||||
// NewClient returns a new GraphQL client for the Sourcegraph.com API authenticated
|
||||
// with the given Sourcegraph access token.
|
||||
//
|
||||
@ -27,7 +25,7 @@ const endpoint = "https://sourcegraph.com/.api/graphql"
|
||||
// println(resp.GetDotcom().ProductSubscriptionByAccessToken.LlmProxyAccess.Enabled)
|
||||
//
|
||||
// The client generator automatically ensures we're up-to-date with the GraphQL schema.
|
||||
func NewClient(token string) graphql.Client {
|
||||
func NewClient(endpoint, token string) graphql.Client {
|
||||
return &tracedClient{graphql.NewClient(endpoint, &http.Client{
|
||||
Transport: &tokenAuthTransport{
|
||||
token: token,
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package shared
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/internal/env"
|
||||
@ -12,6 +13,7 @@ type Config struct {
|
||||
Address string
|
||||
|
||||
Dotcom struct {
|
||||
URL string
|
||||
AccessToken string
|
||||
}
|
||||
|
||||
@ -27,7 +29,17 @@ type Config struct {
|
||||
func (c *Config) Load() {
|
||||
c.Address = c.Get("LLM_PROXY_ADDR", ":9992", "Address to serve LLM proxy on.")
|
||||
c.Dotcom.AccessToken = c.Get("LLM_PROXY_DOTCOM_ACCESS_TOKEN", "", "The Sourcegraph.com access token to be used.")
|
||||
c.Dotcom.URL = c.Get("LLM_PROXY_DOTCOM_API_URL", "https://sourcegraph.com/.api/graphql", "Custom override for the dotcom API endpoint")
|
||||
c.Anthropic.AccessToken = c.Get("LLM_PROXY_ANTHROPIC_ACCESS_TOKEN", "", "The Anthropic access token to be used.")
|
||||
c.AllowAnonymous = c.GetBool("LLM_PROXY_ALLOW_ANONYMOUS", "false", "Allow anonymous access to LLM proxy.")
|
||||
c.SourcesSyncInterval = c.GetInterval("LLM_PROXY_SOURCES_SYNC_INTERVAL", "2m", "The interval at which to sync actor sources.")
|
||||
}
|
||||
|
||||
func (c *Config) Validate() error {
|
||||
_, err := url.Parse(c.Dotcom.URL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ func Main(ctx context.Context, obctx *observation.Context, ready service.ReadyFu
|
||||
productsubscription.NewSource(
|
||||
obctx.Logger,
|
||||
rcache.New("product-subscriptions"),
|
||||
dotcom.NewClient(config.Dotcom.AccessToken)),
|
||||
dotcom.NewClient(config.Dotcom.URL, config.Dotcom.AccessToken)),
|
||||
}
|
||||
|
||||
// Set up our handler chain, which is run from the bottom up
|
||||
|
||||
@ -396,6 +396,11 @@ commands:
|
||||
|
||||
go build -gcflags="$GCFLAGS" -o .bin/llm-proxy github.com/sourcegraph/sourcegraph/enterprise/cmd/llm-proxy
|
||||
checkBinary: .bin/llm-proxy
|
||||
env:
|
||||
LLM_PROXY_ANTHROPIC_ACCESS_TOKEN: foobar
|
||||
LLM_PROXY_DOTCOM_ACCESS_TOKEN: foobar
|
||||
LLM_PROXY_DOTCOM_API_URL: https://sourcegraph.test:3443/.api/graphql
|
||||
SRC_LOG_LEVEL: dbug
|
||||
watch:
|
||||
- lib
|
||||
- internal
|
||||
@ -1118,6 +1123,7 @@ commandsets:
|
||||
- zoekt-web-0
|
||||
- zoekt-web-1
|
||||
- caddy
|
||||
# If you modify this command set, please consider also updating the dotcom runset.
|
||||
enterprise: &enterprise_set
|
||||
requiresDevPrivate: true
|
||||
checks:
|
||||
@ -1152,7 +1158,32 @@ commandsets:
|
||||
EXTSVC_CONFIG_FILE: ''
|
||||
|
||||
dotcom:
|
||||
<<: *enterprise_set
|
||||
# This is 95% the enterprise runset, with the addition of LLM-proxy.
|
||||
requiresDevPrivate: true
|
||||
checks:
|
||||
- docker
|
||||
- redis
|
||||
- postgres
|
||||
- git
|
||||
commands:
|
||||
- frontend
|
||||
- worker
|
||||
- repo-updater
|
||||
- web
|
||||
- gitserver-0
|
||||
- gitserver-1
|
||||
- searcher
|
||||
- symbols
|
||||
- caddy
|
||||
- docsite
|
||||
- syntax-highlighter
|
||||
- github-proxy
|
||||
- zoekt-index-0
|
||||
- zoekt-index-1
|
||||
- zoekt-web-0
|
||||
- zoekt-web-1
|
||||
- blobstore
|
||||
- llm-proxy
|
||||
env:
|
||||
SOURCEGRAPHDOTCOM_MODE: true
|
||||
|
||||
@ -1426,9 +1457,6 @@ commandsets:
|
||||
- redis
|
||||
commands:
|
||||
- llm-proxy
|
||||
env:
|
||||
LLM_PROXY_ANTHROPIC_ACCESS_TOKEN: foobar
|
||||
LLM_PROXY_DOTCOM_ACCESS_TOKEN: foobar
|
||||
|
||||
tests:
|
||||
# These can be run with `sg test [name]`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user