How to set up Cody Gateway locally
This guide documents how to set up Cody Gateway locally for development.
To get started, Cody Gateway is included in the standard dotcom
run set.Since Cody Gateway cucrently depends on Sourcegraph.com, there's not much point running any other run set.
sg start dotcom
Then, set up some feature flags:
product-subscriptions-service-account
: set totrue
globally for convenience.In production, this flag is used to denote service accounts, but in development it doesn't matter.- You can also create an additional user and set this flag to
true
only for that user for more robust testing.
- You can also create an additional user and set this flag to
cody-gateway-management-ui
(TODO: this will no logner be required once Cody Gateway is GA)
Configure Cody features to talk to your local Cody Gateway:
{ "completions": { "enabled": true, "provider": "sourcegraph", "endpoint": "http://localhost:9992", "chatModel": "anthropic/claude-2", "completionModel": "anthropic/claude-instant-1", // Create a subscription and create a license key: // https://sourcegraph.test:3443/site-admin/dotcom/product/subscriptions // Under "Cody services", ensure access is enabled and get the access token // to use here. // Note that the license and tokens will only work locally. "accessToken": "..." } }
Add the following to your sg.config.overwrite.yaml
:
commands: cody-gateway: env: # Get from dev-private access token CODY_GATEWAY_ANTHROPIC_ACCESS_TOKEN: "..." # Create a personal access token on https://sourcegraph.test:3443/user/settings/tokens # or on your `product-subscriptions-service-account` user. CODY_GATEWAY_DOTCOM_ACCESS_TOKEN: "..."
For more configuration options, refer to the configuration source code.
Then, restart sg start dotcom
and try interacting with Cody!
Observing Cody Gateway
You can get full tracing of Cody interactions, including Cody Gateway parts, with sg start monitoring
's Jaeger component.Cody Gateway will also emit traces of its background jobs.
All event logging is output as standard logs in development under the cody-gateway.events
log scope.
Working with BigQuery for events logging
To send events to BigQuery while developing Cody Gateway locally, add the following to your sg.config.overwrite.yaml
:
commands: cody-gateway: env: CODY_GATEWAY_BIGQUERY_PROJECT_ID: cody-gateway-dev
Then to view events statistics on the product subscription page, add the following section in the site configuration, and run the sg start dotcom
stack:
{ "dotcom": { "codyGateway": { "bigQueryGoogleProjectID": "cody-gateway-dev", "bigQueryDataset": "cody_gateway", "bigQueryTable": "events" } } }