cody-gateway: rename all externally-facing LLM-proxy references (#52646)

Renames all externally-facing LLM-proxy references, notably the GraphQL
queries and mutations. This will cause some temporary breakage in the
service's syncing capabilities but shouldn't affect any instances that
have had their access details cached, and currently only internal
instances use these GraphQL queries and mutations.

This also renames the UI, docs, and other references I found.

Part of #52258. I will follow up with another PR to rename database
columns and database structs.

## Test plan

CI?
This commit is contained in:
Robert Lin 2023-05-30 17:43:22 -07:00 committed by GitHub
parent 8960487e85
commit c9da1c936d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 396 additions and 388 deletions

View File

@ -1006,8 +1006,8 @@ ts_project(
"src/enterprise/site-admin/cody/SiteAdminCodyPage.tsx",
"src/enterprise/site-admin/cody/backend.ts",
"src/enterprise/site-admin/dotcom/customers/SiteAdminCustomersPage.tsx",
"src/enterprise/site-admin/dotcom/productSubscriptions/CodyGatewayRateLimitModal.tsx",
"src/enterprise/site-admin/dotcom/productSubscriptions/CodyServicesSection.tsx",
"src/enterprise/site-admin/dotcom/productSubscriptions/LlmProxyRateLimitModal.tsx",
"src/enterprise/site-admin/dotcom/productSubscriptions/ModelBadges.tsx",
"src/enterprise/site-admin/dotcom/productSubscriptions/SiteAdminCreateProductSubscriptionPage.tsx",
"src/enterprise/site-admin/dotcom/productSubscriptions/SiteAdminGenerateProductLicenseForSubscriptionForm.tsx",

View File

@ -6,32 +6,28 @@ import { Button, Modal, Input, H3, Text, ErrorAlert, Form } from '@sourcegraph/w
import { LoaderButton } from '../../../../components/LoaderButton'
import {
LLMProxyRateLimitFields,
CodyGatewayRateLimitFields,
Scalars,
UpdateLLMProxyConfigResult,
UpdateLLMProxyConfigVariables,
UpdateCodyGatewayConfigResult,
UpdateCodyGatewayConfigVariables,
} from '../../../../graphql-operations'
import { UPDATE_LLM_PROXY_CONFIG } from './backend'
import { UPDATE_CODY_GATEWAY_CONFIG } from './backend'
import { ModelBadges } from './ModelBadges'
import { prettyInterval } from './utils'
export interface LLMProxyRateLimitModalProps {
export interface CodyGatewayRateLimitModalProps {
onCancel: () => void
afterSave: () => void
productSubscriptionID: Scalars['ID']
current: LLMProxyRateLimitFields | null
current: CodyGatewayRateLimitFields | null
mode: 'chat' | 'code'
}
export const LLMProxyRateLimitModal: React.FunctionComponent<React.PropsWithChildren<LLMProxyRateLimitModalProps>> = ({
onCancel,
afterSave,
productSubscriptionID,
current,
mode,
}) => {
const labelId = 'llmProxyRateLimit'
export const CodyGatewayRateLimitModal: React.FunctionComponent<
React.PropsWithChildren<CodyGatewayRateLimitModalProps>
> = ({ onCancel, afterSave, productSubscriptionID, current, mode }) => {
const labelId = 'codyGatewayRateLimit'
const [limit, setLimit] = useState<number>(current?.limit ?? 100)
const onChangeLimit = useCallback<React.ChangeEventHandler<HTMLInputElement>>(event => {
@ -48,20 +44,20 @@ export const LLMProxyRateLimitModal: React.FunctionComponent<React.PropsWithChil
setAllowedModels(event.target.value)
}, [])
const [updateLLMProxyConfig, { loading, error }] = useMutation<
UpdateLLMProxyConfigResult,
UpdateLLMProxyConfigVariables
>(UPDATE_LLM_PROXY_CONFIG)
const [updateCodyGatewayConfig, { loading, error }] = useMutation<
UpdateCodyGatewayConfigResult,
UpdateCodyGatewayConfigVariables
>(UPDATE_CODY_GATEWAY_CONFIG)
const onSubmit = useCallback<React.FormEventHandler>(
async event => {
event.preventDefault()
try {
await updateLLMProxyConfig({
await updateCodyGatewayConfig({
variables: {
productSubscriptionID,
llmProxyAccess: {
access: {
chatCompletionsRateLimit: mode === 'chat' ? limit : undefined,
chatCompletionsRateLimitIntervalSeconds: mode === 'chat' ? limitInterval : undefined,
chatCompletionsAllowedModels: mode === 'chat' ? splitModels(allowedModels) : undefined,
@ -79,17 +75,17 @@ export const LLMProxyRateLimitModal: React.FunctionComponent<React.PropsWithChil
logger.error(error)
}
},
[updateLLMProxyConfig, productSubscriptionID, limit, limitInterval, afterSave, allowedModels, mode]
[updateCodyGatewayConfig, productSubscriptionID, limit, limitInterval, afterSave, allowedModels, mode]
)
return (
<Modal onDismiss={onCancel} aria-labelledby={labelId}>
<H3 id={labelId}>
Configure {mode === 'chat' ? 'chat request' : 'code completion request'} rate limit for LLM proxy
Configure {mode === 'chat' ? 'chat request' : 'code completion request'} rate limit for Cody Gateway
</H3>
<Text>
LLM proxy is a Sourcegraph managed service that allows customer instances to talk to upstream LLMs under
our negotiated terms in a safe manner.
Cody Gateway is a Sourcegraph managed service that allows customer instances to talk to upstream LLMs
under our negotiated terms in a safe manner.
</Text>
{error && <ErrorAlert error={error} />}

View File

@ -6,7 +6,7 @@ import { parseISO } from 'date-fns'
import { Toggle } from '@sourcegraph/branded/src/components/Toggle'
import { logger } from '@sourcegraph/common'
import { useMutation, useQuery } from '@sourcegraph/http-client'
import { LLMProxyRateLimitSource } from '@sourcegraph/shared/src/graphql-operations'
import { CodyGatewayRateLimitSource } from '@sourcegraph/shared/src/graphql-operations'
import {
H3,
ProductStatusBadge,
@ -27,19 +27,19 @@ import {
import { CopyableText } from '../../../../components/CopyableText'
import {
LLMProxyAccessFields,
CodyGatewayAccessFields,
Scalars,
UpdateLLMProxyConfigResult,
UpdateLLMProxyConfigVariables,
LLMProxyRateLimitUsageDatapoint,
LLMProxyRateLimitFields,
DotComProductSubscriptionLLMUsageResult,
DotComProductSubscriptionLLMUsageVariables,
UpdateCodyGatewayConfigResult,
UpdateCodyGatewayConfigVariables,
CodyGatewayRateLimitUsageDatapoint,
CodyGatewayRateLimitFields,
DotComProductSubscriptionCodyGatewayUsageResult,
DotComProductSubscriptionCodyGatewayUsageVariables,
} from '../../../../graphql-operations'
import { ChartContainer } from '../../../../site-admin/analytics/components/ChartContainer'
import { DOTCOM_PRODUCT_SUBSCRIPTION_LLM_USAGE, UPDATE_LLM_PROXY_CONFIG } from './backend'
import { LLMProxyRateLimitModal } from './LlmProxyRateLimitModal'
import { DOTCOM_PRODUCT_SUBSCRIPTION_CODY_GATEWAY_USAGE, UPDATE_CODY_GATEWAY_CONFIG } from './backend'
import { CodyGatewayRateLimitModal } from './CodyGatewayRateLimitModal'
import { ModelBadges } from './ModelBadges'
import { prettyInterval } from './utils'
@ -52,7 +52,7 @@ interface Props {
accessTokenError?: Error
viewerCanAdminister: boolean
refetchSubscription: () => Promise<any>
llmProxyAccess: LLMProxyAccessFields
codyGatewayAccess: CodyGatewayAccessFields
}
export const CodyServicesSection: React.FunctionComponent<Props> = ({
@ -62,18 +62,18 @@ export const CodyServicesSection: React.FunctionComponent<Props> = ({
currentSourcegraphAccessToken,
accessTokenError,
refetchSubscription,
llmProxyAccess,
codyGatewayAccess,
}) => {
const [updateLLMProxyConfig, { loading: updateLLMProxyConfigLoading, error: updateLLMProxyConfigError }] =
useMutation<UpdateLLMProxyConfigResult, UpdateLLMProxyConfigVariables>(UPDATE_LLM_PROXY_CONFIG)
const [updateCodyGatewayConfig, { loading: updateCodyGatewayConfigLoading, error: updateCodyGatewayConfigError }] =
useMutation<UpdateCodyGatewayConfigResult, UpdateCodyGatewayConfigVariables>(UPDATE_CODY_GATEWAY_CONFIG)
const onToggleCompletions = useCallback(
async (value: boolean) => {
try {
await updateLLMProxyConfig({
await updateCodyGatewayConfig({
variables: {
productSubscriptionID,
llmProxyAccess: { enabled: value },
access: { enabled: value },
},
})
await refetchSubscription()
@ -81,7 +81,7 @@ export const CodyServicesSection: React.FunctionComponent<Props> = ({
logger.error(error)
}
},
[productSubscriptionID, refetchSubscription, updateLLMProxyConfig]
[productSubscriptionID, refetchSubscription, updateCodyGatewayConfig]
)
return (
@ -91,7 +91,7 @@ export const CodyServicesSection: React.FunctionComponent<Props> = ({
</H3>
<Container className="mb-3">
<H4>Access token</H4>
<Text className="mb-2">Access tokens can be used for LLM-proxy access</Text>
<Text className="mb-2">Access tokens can be used for Cody Gateway access</Text>
{currentSourcegraphAccessToken && (
<CopyableText
label="Access token"
@ -108,17 +108,17 @@ export const CodyServicesSection: React.FunctionComponent<Props> = ({
<H4>Completions</H4>
<div className="form-group mb-2">
{updateLLMProxyConfigError && <ErrorAlert error={updateLLMProxyConfigError} />}
{updateCodyGatewayConfigError && <ErrorAlert error={updateCodyGatewayConfigError} />}
<Label className="mb-0">
<Toggle
id="cody-gateway-enabled"
value={llmProxyAccess.enabled}
disabled={updateLLMProxyConfigLoading || !viewerCanAdminister}
value={codyGatewayAccess.enabled}
disabled={updateCodyGatewayConfigLoading || !viewerCanAdminister}
onToggle={onToggleCompletions}
className="mr-1 align-text-bottom"
/>
Access to hosted Cody services
{updateLLMProxyConfigLoading && (
{updateCodyGatewayConfigLoading && (
<>
{' '}
<LoadingSpinner />
@ -127,7 +127,7 @@ export const CodyServicesSection: React.FunctionComponent<Props> = ({
</Label>
</div>
{llmProxyAccess.enabled && (
{codyGatewayAccess.enabled && (
<>
<Label className="mb-2">Rate limits</Label>
<table className={styles.limitsTable}>
@ -144,7 +144,7 @@ export const CodyServicesSection: React.FunctionComponent<Props> = ({
<RateLimitRow
mode="chat"
productSubscriptionID={productSubscriptionID}
rateLimit={llmProxyAccess.chatCompletionsRateLimit}
rateLimit={codyGatewayAccess.chatCompletionsRateLimit}
refetchSubscription={refetchSubscription}
title="Chat rate limit"
viewerCanAdminister={viewerCanAdminister}
@ -152,7 +152,7 @@ export const CodyServicesSection: React.FunctionComponent<Props> = ({
<RateLimitRow
mode="code"
productSubscriptionID={productSubscriptionID}
rateLimit={llmProxyAccess.codeCompletionsRateLimit}
rateLimit={codyGatewayAccess.codeCompletionsRateLimit}
refetchSubscription={refetchSubscription}
title="Code completions rate limit"
viewerCanAdminister={viewerCanAdminister}
@ -169,12 +169,12 @@ export const CodyServicesSection: React.FunctionComponent<Props> = ({
)
}
export const LLMProxyRateLimitSourceBadge: React.FunctionComponent<{
source: LLMProxyRateLimitSource
export const CodyGatewayRateLimitSourceBadge: React.FunctionComponent<{
source: CodyGatewayRateLimitSource
className?: string
}> = ({ source, className }) => {
switch (source) {
case LLMProxyRateLimitSource.OVERRIDE:
case CodyGatewayRateLimitSource.OVERRIDE:
return (
<Tooltip content="The limit has been specified by a custom override">
<Badge variant="primary" className={className}>
@ -182,7 +182,7 @@ export const LLMProxyRateLimitSourceBadge: React.FunctionComponent<{
</Badge>
</Tooltip>
)
case LLMProxyRateLimitSource.PLAN:
case CodyGatewayRateLimitSource.PLAN:
return (
<Tooltip content="The limit is derived from the current subscription plan">
<Badge variant="primary" className={className}>
@ -193,8 +193,8 @@ export const LLMProxyRateLimitSourceBadge: React.FunctionComponent<{
}
}
function generateSeries(data: LLMProxyRateLimitUsageDatapoint[]): LLMProxyRateLimitUsageDatapoint[][] {
const series: Record<string, LLMProxyRateLimitUsageDatapoint[]> = {}
function generateSeries(data: CodyGatewayRateLimitUsageDatapoint[]): CodyGatewayRateLimitUsageDatapoint[][] {
const series: Record<string, CodyGatewayRateLimitUsageDatapoint[]> = {}
for (const entry of data) {
if (!series[entry.model]) {
series[entry.model] = []
@ -210,7 +210,7 @@ interface RateLimitRowProps {
viewerCanAdminister: boolean
refetchSubscription: () => Promise<any>
mode: 'chat' | 'code'
rateLimit: LLMProxyRateLimitFields | null
rateLimit: CodyGatewayRateLimitFields | null
}
const RateLimitRow: React.FunctionComponent<RateLimitRowProps> = ({
@ -223,15 +223,15 @@ const RateLimitRow: React.FunctionComponent<RateLimitRowProps> = ({
}) => {
const [showConfigModal, setShowConfigModal] = useState<boolean>(false)
const [updateLLMProxyConfig, { loading: updateLLMProxyConfigLoading, error: updateLLMProxyConfigError }] =
useMutation<UpdateLLMProxyConfigResult, UpdateLLMProxyConfigVariables>(UPDATE_LLM_PROXY_CONFIG)
const [updateCodyGatewayConfig, { loading: updateCodyGatewayConfigLoading, error: updateCodyGatewayConfigError }] =
useMutation<UpdateCodyGatewayConfigResult, UpdateCodyGatewayConfigVariables>(UPDATE_CODY_GATEWAY_CONFIG)
const onRemoveRateLimitOverride = useCallback(async () => {
try {
await updateLLMProxyConfig({
await updateCodyGatewayConfig({
variables: {
productSubscriptionID,
llmProxyAccess:
access:
mode === 'chat'
? {
chatCompletionsRateLimit: 0,
@ -249,7 +249,7 @@ const RateLimitRow: React.FunctionComponent<RateLimitRowProps> = ({
} catch (error) {
logger.error(error)
}
}, [productSubscriptionID, refetchSubscription, updateLLMProxyConfig, mode])
}, [productSubscriptionID, refetchSubscription, updateCodyGatewayConfig, mode])
const afterSaveRateLimit = useCallback(async () => {
try {
@ -269,7 +269,7 @@ const RateLimitRow: React.FunctionComponent<RateLimitRowProps> = ({
{rateLimit !== null && (
<>
<td>
<LLMProxyRateLimitSourceBadge source={rateLimit.source} />
<CodyGatewayRateLimitSourceBadge source={rateLimit.source} />
</td>
<td>
{rateLimit.limit} requests / {prettyInterval(rateLimit.intervalSeconds)}
@ -288,28 +288,28 @@ const RateLimitRow: React.FunctionComponent<RateLimitRowProps> = ({
>
<Icon aria-hidden={true} svgPath={mdiPencil} />
</Button>
{rateLimit.source === LLMProxyRateLimitSource.OVERRIDE && (
{rateLimit.source === CodyGatewayRateLimitSource.OVERRIDE && (
<Tooltip content="Remove rate limit override">
<Button
size="sm"
variant="link"
aria-label="Remove rate limit override"
className="ml-1"
disabled={updateLLMProxyConfigLoading}
disabled={updateCodyGatewayConfigLoading}
onClick={onRemoveRateLimitOverride}
>
<Icon aria-hidden={true} svgPath={mdiTrashCan} className="text-danger" />
</Button>
</Tooltip>
)}
{updateLLMProxyConfigError && <ErrorAlert error={updateLLMProxyConfigError} />}
{updateCodyGatewayConfigError && <ErrorAlert error={updateCodyGatewayConfigError} />}
</td>
)}
</>
)}
</tr>
{showConfigModal && (
<LLMProxyRateLimitModal
<CodyGatewayRateLimitModal
productSubscriptionID={productSubscriptionID}
afterSave={afterSaveRateLimit}
current={rateLimit}
@ -327,9 +327,9 @@ interface RateLimitUsageProps {
const RateLimitUsage: React.FunctionComponent<RateLimitUsageProps> = ({ productSubscriptionUUID }) => {
const { data, loading, error } = useQuery<
DotComProductSubscriptionLLMUsageResult,
DotComProductSubscriptionLLMUsageVariables
>(DOTCOM_PRODUCT_SUBSCRIPTION_LLM_USAGE, { variables: { uuid: productSubscriptionUUID } })
DotComProductSubscriptionCodyGatewayUsageResult,
DotComProductSubscriptionCodyGatewayUsageVariables
>(DOTCOM_PRODUCT_SUBSCRIPTION_CODY_GATEWAY_USAGE, { variables: { uuid: productSubscriptionUUID } })
if (loading && !data) {
return (
@ -349,7 +349,7 @@ const RateLimitUsage: React.FunctionComponent<RateLimitUsageProps> = ({ productS
)
}
const llmProxyAccess = data!.dotcom.productSubscription.llmProxyAccess
const { codyGatewayAccess } = data!.dotcom.productSubscription
return (
<>
@ -360,8 +360,8 @@ const RateLimitUsage: React.FunctionComponent<RateLimitUsageProps> = ({ productS
width={width}
height={200}
series={[
...generateSeries(llmProxyAccess.chatCompletionsRateLimit?.usage ?? []).map(
(data): Series<LLMProxyRateLimitUsageDatapoint> => ({
...generateSeries(codyGatewayAccess.chatCompletionsRateLimit?.usage ?? []).map(
(data): Series<CodyGatewayRateLimitUsageDatapoint> => ({
data,
getXValue(datum) {
return parseISO(datum.date)
@ -370,12 +370,12 @@ const RateLimitUsage: React.FunctionComponent<RateLimitUsageProps> = ({ productS
return datum.count
},
id: 'chat-usage',
name: 'LLM Proxy chat completions usage',
name: 'Cody Gateway chat completions usage',
color: 'var(--purple)',
})
),
...generateSeries(llmProxyAccess.codeCompletionsRateLimit?.usage ?? []).map(
(data): Series<LLMProxyRateLimitUsageDatapoint> => ({
...generateSeries(codyGatewayAccess.codeCompletionsRateLimit?.usage ?? []).map(
(data): Series<CodyGatewayRateLimitUsageDatapoint> => ({
data,
getXValue(datum) {
return parseISO(datum.date)
@ -384,7 +384,7 @@ const RateLimitUsage: React.FunctionComponent<RateLimitUsageProps> = ({ productS
return datum.count
},
id: 'code-completions-usage',
name: 'LLM Proxy code completions usage',
name: 'Cody Gateway code completions usage',
color: 'var(--orange)',
})
),

View File

@ -16,7 +16,7 @@ function modelBadgeVariant(model: string): 'secondary' | 'danger' {
switch (model) {
// See here: https://console.anthropic.com/docs/api/reference
// for currently available Anthropic models. Note that we also need to
// allow list the models on the LLM Proxy side.
// allow list the models on the Cody Gateway side.
case 'claude-v1':
case 'claude-v1.0':
case 'claude-v1.2':
@ -25,7 +25,7 @@ function modelBadgeVariant(model: string): 'secondary' | 'danger' {
case 'claude-instant-v1.0':
// See here: https://platform.openai.com/docs/models/model-endpoint-compatibility
// for currently available Anthropic models. Note that we also need to
// allow list the models on the LLM Proxy side.
// allow list the models on the Cody Gateway side.
case 'gpt-4':
case 'gpt-3.5-turbo':
return 'secondary'

View File

@ -178,7 +178,7 @@ export const SiteAdminProductSubscriptionPage: React.FunctionComponent<React.Pro
viewerCanAdminister={true}
currentSourcegraphAccessToken={productSubscription.currentSourcegraphAccessToken}
accessTokenError={errorForPath(error, accessTokenPath)}
llmProxyAccess={productSubscription.llmProxyAccess}
codyGatewayAccess={productSubscription.codyGatewayAccess}
productSubscriptionID={productSubscription.id}
productSubscriptionUUID={subscriptionUUID}
refetchSubscription={refetch}

View File

@ -49,18 +49,18 @@ const siteAdminProductSubscriptionFragment = gql`
}
`
export const LLM_PROXY_ACCESS_FIELDS_FRAGMENT = gql`
fragment LLMProxyAccessFields on LLMProxyAccess {
export const CODY_GATEWAY_ACCESS_FIELDS_FRAGMENT = gql`
fragment CodyGatewayAccessFields on CodyGatewayAccess {
enabled
codeCompletionsRateLimit {
...LLMProxyRateLimitFields
...CodyGatewayRateLimitFields
}
chatCompletionsRateLimit {
...LLMProxyRateLimitFields
...CodyGatewayRateLimitFields
}
}
fragment LLMProxyRateLimitFields on LLMProxyRateLimit {
fragment CodyGatewayRateLimitFields on CodyGatewayRateLimit {
allowedModels
source
limit
@ -68,42 +68,42 @@ export const LLM_PROXY_ACCESS_FIELDS_FRAGMENT = gql`
}
`
export const LLM_PROXY_ACCESS_USAGE_FIELDS_FRAGMENT = gql`
fragment LLMProxyAccessUsageFields on LLMProxyAccess {
export const CODY_GATEWAY_ACCESS_USAGE_FIELDS_FRAGMENT = gql`
fragment CodyGatewayAccessUsageFields on CodyGatewayAccess {
codeCompletionsRateLimit {
...LLMProxyRateLimitUsageFields
...CodyGatewayRateLimitUsageFields
}
chatCompletionsRateLimit {
...LLMProxyRateLimitUsageFields
...CodyGatewayRateLimitUsageFields
}
}
fragment LLMProxyRateLimitUsageFields on LLMProxyRateLimit {
fragment CodyGatewayRateLimitUsageFields on CodyGatewayRateLimit {
usage {
...LLMProxyRateLimitUsageDatapoint
...CodyGatewayRateLimitUsageDatapoint
}
}
fragment LLMProxyRateLimitUsageDatapoint on LLMProxyUsageDatapoint {
fragment CodyGatewayRateLimitUsageDatapoint on CodyGatewayUsageDatapoint {
date
count
model
}
`
export const DOTCOM_PRODUCT_SUBSCRIPTION_LLM_USAGE = gql`
query DotComProductSubscriptionLLMUsage($uuid: String!) {
export const DOTCOM_PRODUCT_SUBSCRIPTION_CODY_GATEWAY_USAGE = gql`
query DotComProductSubscriptionCodyGatewayUsage($uuid: String!) {
dotcom {
productSubscription(uuid: $uuid) {
id
llmProxyAccess {
...LLMProxyAccessUsageFields
codyGatewayAccess {
...CodyGatewayAccessUsageFields
}
}
}
}
${LLM_PROXY_ACCESS_USAGE_FIELDS_FRAGMENT}
${CODY_GATEWAY_ACCESS_USAGE_FIELDS_FRAGMENT}
`
export const DOTCOM_PRODUCT_SUBSCRIPTION = gql`
@ -143,8 +143,8 @@ export const DOTCOM_PRODUCT_SUBSCRIPTION = gql`
createdAt
}
currentSourcegraphAccessToken
llmProxyAccess {
...LLMProxyAccessFields
codyGatewayAccess {
...CodyGatewayAccessFields
}
createdAt
isArchived
@ -163,7 +163,7 @@ export const DOTCOM_PRODUCT_SUBSCRIPTION = gql`
}
}
${LLM_PROXY_ACCESS_FIELDS_FRAGMENT}
${CODY_GATEWAY_ACCESS_FIELDS_FRAGMENT}
`
export const ARCHIVE_PRODUCT_SUBSCRIPTION = gql`
@ -176,10 +176,10 @@ export const ARCHIVE_PRODUCT_SUBSCRIPTION = gql`
}
`
export const UPDATE_LLM_PROXY_CONFIG = gql`
mutation UpdateLLMProxyConfig($productSubscriptionID: ID!, $llmProxyAccess: UpdateLLMProxyAccessInput!) {
export const UPDATE_CODY_GATEWAY_CONFIG = gql`
mutation UpdateCodyGatewayConfig($productSubscriptionID: ID!, $access: UpdateCodyGatewayAccessInput!) {
dotcom {
updateProductSubscription(id: $productSubscriptionID, update: { llmProxyAccess: $llmProxyAccess }) {
updateProductSubscription(id: $productSubscriptionID, update: { codyGatewayAccess: $access }) {
alwaysNil
}
}

View File

@ -113,7 +113,7 @@ export const UserSubscriptionsProductSubscriptionPage: React.FunctionComponent<R
viewerCanAdminister={false}
currentSourcegraphAccessToken={productSubscription.currentSourcegraphAccessToken}
accessTokenError={errorForPath(error, accessTokenPath)}
llmProxyAccess={productSubscription.llmProxyAccess}
codyGatewayAccess={productSubscription.codyGatewayAccess}
productSubscriptionID={productSubscription.id}
productSubscriptionUUID={subscriptionUUID}
refetchSubscription={refetch}

View File

@ -1,6 +1,6 @@
import { gql } from '@sourcegraph/http-client'
import { LLM_PROXY_ACCESS_FIELDS_FRAGMENT } from '../../site-admin/dotcom/productSubscriptions/backend'
import { CODY_GATEWAY_ACCESS_FIELDS_FRAGMENT } from '../../site-admin/dotcom/productSubscriptions/backend'
export const USER_PRODUCT_SUBSCRIPTION = gql`
query UserProductSubscription($uuid: String!) {
@ -37,10 +37,10 @@ export const USER_PRODUCT_SUBSCRIPTION = gql`
url
urlForSiteAdmin
currentSourcegraphAccessToken
llmProxyAccess {
...LLMProxyAccessFields
codyGatewayAccess {
...CodyGatewayAccessFields
}
}
${LLM_PROXY_ACCESS_FIELDS_FRAGMENT}
${CODY_GATEWAY_ACCESS_FIELDS_FRAGMENT}
`

View File

@ -40,7 +40,7 @@ type ProductSubscription interface {
Account(context.Context) (*UserResolver, error)
ActiveLicense(context.Context) (ProductLicense, error)
ProductLicenses(context.Context, *graphqlutil.ConnectionArgs) (ProductLicenseConnection, error)
LLMProxyAccess() LLMProxyAccess
CodyGatewayAccess() CodyGatewayAccess
CreatedAt() gqlutil.DateTime
IsArchived() bool
URL(context.Context) (string, error)
@ -126,10 +126,10 @@ type UpdateProductSubscriptionArgs struct {
}
type UpdateProductSubscriptionInput struct {
LLMProxyAccess *UpdateLLMProxyAccessInput
CodyGatewayAccess *UpdateCodyGatewayAccessInput
}
type UpdateLLMProxyAccessInput struct {
type UpdateCodyGatewayAccessInput struct {
Enabled *bool
ChatCompletionsRateLimit *int32
ChatCompletionsRateLimitIntervalSeconds *int32
@ -139,29 +139,29 @@ type UpdateLLMProxyAccessInput struct {
CodeCompletionsAllowedModels *[]string
}
type LLMProxyAccess interface {
type CodyGatewayAccess interface {
Enabled() bool
ChatCompletionsRateLimit(context.Context) (LLMProxyRateLimit, error)
CodeCompletionsRateLimit(context.Context) (LLMProxyRateLimit, error)
ChatCompletionsRateLimit(context.Context) (CodyGatewayRateLimit, error)
CodeCompletionsRateLimit(context.Context) (CodyGatewayRateLimit, error)
}
type LLMProxyUsageDatapoint interface {
type CodyGatewayUsageDatapoint interface {
Date() gqlutil.DateTime
Model() string
Count() int32
}
type LLMProxyRateLimitSource string
type CodyGatewayRateLimitSource string
const (
LLMProxyRateLimitSourceOverride LLMProxyRateLimitSource = "OVERRIDE"
LLMProxyRateLimitSourcePlan LLMProxyRateLimitSource = "PLAN"
CodyGatewayRateLimitSourceOverride CodyGatewayRateLimitSource = "OVERRIDE"
CodyGatewayRateLimitSourcePlan CodyGatewayRateLimitSource = "PLAN"
)
type LLMProxyRateLimit interface {
Source() LLMProxyRateLimitSource
type CodyGatewayRateLimit interface {
Source() CodyGatewayRateLimitSource
AllowedModels() []string
Limit() int32
IntervalSeconds() int32
Usage(context.Context) ([]LLMProxyUsageDatapoint, error)
Usage(context.Context) ([]CodyGatewayUsageDatapoint, error)
}

View File

@ -276,9 +276,9 @@ type ProductSubscription implements Node {
"""
sourcegraphAccessTokens: [String!]!
"""
LLM-proxy access granted to this subscription. Properties may be inferred from the active license, or be defined in overrides.
Cody Gateway access granted to this subscription. Properties may be inferred from the active license, or be defined in overrides.
"""
llmProxyAccess: LLMProxyAccess!
codyGatewayAccess: CodyGatewayAccess!
"""
The date when this product subscription was created.
"""
@ -299,9 +299,9 @@ type ProductSubscription implements Node {
}
"""
A usage data point of LLM proxy use of a subscription.
A usage data point of Cody Gateway usage of a subscription.
"""
type LLMProxyUsageDatapoint {
type CodyGatewayUsageDatapoint {
"""
The day the usage occurred.
"""
@ -317,29 +317,29 @@ type LLMProxyUsageDatapoint {
}
"""
LLM-proxy access granted to a subscription.
Cody Gateway access granted to a subscription.
FOR INTERNAL USE ONLY.
"""
type LLMProxyAccess {
type CodyGatewayAccess {
"""
Whether or not a subscription has LLM-proxy access.
Whether or not a subscription has Cody Gateway access.
"""
enabled: Boolean!
"""
Rate limit for chat completions access, or null if not enabled.
"""
chatCompletionsRateLimit: LLMProxyRateLimit
chatCompletionsRateLimit: CodyGatewayRateLimit
"""
Rate limit for code completions access, or null if not enabled.
"""
codeCompletionsRateLimit: LLMProxyRateLimit
codeCompletionsRateLimit: CodyGatewayRateLimit
}
"""
The source of the rate limit returned.
FOR INTERNAL USE ONLY.
"""
enum LLMProxyRateLimitSource {
enum CodyGatewayRateLimitSource {
"""
Indicates that a custom override for the rate limit has been stored.
"""
@ -352,14 +352,14 @@ enum LLMProxyRateLimitSource {
}
"""
LLM-proxy access rate limits for a subscription.
Cody Gateway access rate limits for a subscription.
FOR INTERNAL USE ONLY.
"""
type LLMProxyRateLimit {
type CodyGatewayRateLimit {
"""
The source of the rate limit configuration.
"""
source: LLMProxyRateLimitSource!
source: CodyGatewayRateLimitSource!
"""
The models that are allowed for this rate limit bucket.
Usually, customers will have two separate rate limits, one
@ -376,9 +376,9 @@ type LLMProxyRateLimit {
"""
intervalSeconds: Int!
"""
Recent usage data of LLM proxy for the subscription.
Recent usage data of Cody Gateway for the subscription.
"""
usage: [LLMProxyUsageDatapoint!]!
usage: [CodyGatewayUsageDatapoint!]!
}
"""
@ -386,17 +386,17 @@ Partial update to apply to a subscription. Omitted fields are not applied.
"""
input UpdateProductSubscriptionInput {
"""
Partial update to LLM-proxy access granted to this subscription.
Partial update to Cody Gateway access granted to this subscription.
"""
llmProxyAccess: UpdateLLMProxyAccessInput
codyGatewayAccess: UpdateCodyGatewayAccessInput
}
"""
Partial update to apply to a subscription's LLM-proxy access. Omitted fields are not applied.
Partial update to apply to a subscription's Cody Gateway access. Omitted fields are not applied.
"""
input UpdateLLMProxyAccessInput {
input UpdateCodyGatewayAccessInput {
"""
Enable or disable LLM-proxy access.
Enable or disable Cody Gateway access.
"""
enabled: Boolean
"""

View File

@ -42,4 +42,6 @@ You have to configure the model used for Cody completions via the `completionMod
> NOTE: Self-hosted customers need to update to a minimum of version 5.0.4 to use completions.
> NOTE: Cody completions currently only work with Claude Instant or our LLMProxy configured with Claude Instant. Support for other models will be coming later.
<br />
> NOTE: Cody completions currently only work with Claude Instant or our Cody Gateway configured with Claude Instant. Support for other models will be coming later.

View File

@ -34,13 +34,13 @@ type Actor struct {
// For example, for product subscriptions this is the subscription UUID. For
// Sourcegraph.com users, this is the string representation of the user ID.
ID string `json:"id"`
// AccessEnabled is an evaluated field that summarizes whether or not LLM-proxy access
// AccessEnabled is an evaluated field that summarizes whether or not Cody Gateway access
// is enabled.
//
// For example, for product subscriptions it is based on whether the subscription is
// archived, if access is enabled, and if any rate limits are set.
AccessEnabled bool `json:"accessEnabled"`
// RateLimits holds the rate limits for LLM-proxy access for this actor.
// RateLimits holds the rate limits for Cody Gateway access for this actor.
RateLimits map[types.CompletionsFeature]RateLimit `json:"rateLimits"`
// LastUpdated indicates when this actor's state was last updated.
LastUpdated *time.Time `json:"lastUpdated"`

View File

@ -36,7 +36,7 @@ type Source struct {
dotcom graphql.Client
// internalMode, if true, indicates only dev and internal licenses may use
// this LLM-proxy instance.
// this Cody Gateway instance.
internalMode bool
}
@ -170,25 +170,25 @@ func NewActor(source *Source, token string, s dotcom.ProductSubscriptionState, i
a := &actor.Actor{
Key: token,
ID: s.Uuid,
AccessEnabled: !disallowedLicense && !s.IsArchived && s.LlmProxyAccess.Enabled,
AccessEnabled: !disallowedLicense && !s.IsArchived && s.CodyGatewayAccess.Enabled,
RateLimits: map[types.CompletionsFeature]actor.RateLimit{},
LastUpdated: &now,
Source: source,
}
if s.LlmProxyAccess.ChatCompletionsRateLimit != nil {
if s.CodyGatewayAccess.ChatCompletionsRateLimit != nil {
a.RateLimits[types.CompletionsFeatureChat] = actor.RateLimit{
AllowedModels: s.LlmProxyAccess.ChatCompletionsRateLimit.AllowedModels,
Limit: s.LlmProxyAccess.ChatCompletionsRateLimit.Limit,
Interval: time.Duration(s.LlmProxyAccess.ChatCompletionsRateLimit.IntervalSeconds) * time.Second,
AllowedModels: s.CodyGatewayAccess.ChatCompletionsRateLimit.AllowedModels,
Limit: s.CodyGatewayAccess.ChatCompletionsRateLimit.Limit,
Interval: time.Duration(s.CodyGatewayAccess.ChatCompletionsRateLimit.IntervalSeconds) * time.Second,
}
}
if s.LlmProxyAccess.CodeCompletionsRateLimit != nil {
if s.CodyGatewayAccess.CodeCompletionsRateLimit != nil {
a.RateLimits[types.CompletionsFeatureCode] = actor.RateLimit{
AllowedModels: s.LlmProxyAccess.CodeCompletionsRateLimit.AllowedModels,
Limit: s.LlmProxyAccess.CodeCompletionsRateLimit.Limit,
Interval: time.Duration(s.LlmProxyAccess.CodeCompletionsRateLimit.IntervalSeconds) * time.Second,
AllowedModels: s.CodyGatewayAccess.CodeCompletionsRateLimit.AllowedModels,
Limit: s.CodyGatewayAccess.CodeCompletionsRateLimit.Limit,
Interval: time.Duration(s.CodyGatewayAccess.CodeCompletionsRateLimit.IntervalSeconds) * time.Second,
}
}

View File

@ -22,16 +22,16 @@ func TestNewActor(t *testing.T) {
name: "not dev only",
args: args{
dotcom.ProductSubscriptionState{
LlmProxyAccess: dotcom.ProductSubscriptionStateLlmProxyAccessLLMProxyAccess{
LLMProxyAccessFields: dotcom.LLMProxyAccessFields{
CodyGatewayAccess: dotcom.ProductSubscriptionStateCodyGatewayAccess{
CodyGatewayAccessFields: dotcom.CodyGatewayAccessFields{
Enabled: true,
ChatCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit{
ChatCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,
},
},
CodeCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit{
CodeCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,
@ -48,16 +48,16 @@ func TestNewActor(t *testing.T) {
name: "dev only, not a dev license",
args: args{
dotcom.ProductSubscriptionState{
LlmProxyAccess: dotcom.ProductSubscriptionStateLlmProxyAccessLLMProxyAccess{
LLMProxyAccessFields: dotcom.LLMProxyAccessFields{
CodyGatewayAccess: dotcom.ProductSubscriptionStateCodyGatewayAccess{
CodyGatewayAccessFields: dotcom.CodyGatewayAccessFields{
Enabled: true,
ChatCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit{
ChatCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,
},
},
CodeCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit{
CodeCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,
@ -74,16 +74,16 @@ func TestNewActor(t *testing.T) {
name: "dev only, is a dev license",
args: args{
dotcom.ProductSubscriptionState{
LlmProxyAccess: dotcom.ProductSubscriptionStateLlmProxyAccessLLMProxyAccess{
LLMProxyAccessFields: dotcom.LLMProxyAccessFields{
CodyGatewayAccess: dotcom.ProductSubscriptionStateCodyGatewayAccess{
CodyGatewayAccessFields: dotcom.CodyGatewayAccessFields{
Enabled: true,
ChatCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit{
ChatCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,
},
},
CodeCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit{
CodeCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,

View File

@ -51,7 +51,7 @@ func (a *Authenticator) Middleware(next http.Handler) http.Handler {
logger,
w,
http.StatusForbidden,
errors.New("LLM proxy access not enabled"),
errors.New("Cody Gateway access not enabled"),
)
err := a.EventLogger.LogEvent(

View File

@ -58,16 +58,16 @@ func TestAuthenticatorMiddleware(t *testing.T) {
Id: "UHJvZHVjdFN1YnNjcmlwdGlvbjoiNjQ1MmE4ZmMtZTY1MC00NWE3LWEwYTItMzU3Zjc3NmIzYjQ2Ig==",
Uuid: "6452a8fc-e650-45a7-a0a2-357f776b3b46",
IsArchived: false,
LlmProxyAccess: dotcom.ProductSubscriptionStateLlmProxyAccessLLMProxyAccess{
LLMProxyAccessFields: dotcom.LLMProxyAccessFields{
CodyGatewayAccess: dotcom.ProductSubscriptionStateCodyGatewayAccess{
CodyGatewayAccessFields: dotcom.CodyGatewayAccessFields{
Enabled: true,
ChatCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit{
ChatCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,
},
},
CodeCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit{
CodeCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,
@ -150,16 +150,16 @@ func TestAuthenticatorMiddleware(t *testing.T) {
Id: "UHJvZHVjdFN1YnNjcmlwdGlvbjoiNjQ1MmE4ZmMtZTY1MC00NWE3LWEwYTItMzU3Zjc3NmIzYjQ2Ig==",
Uuid: "6452a8fc-e650-45a7-a0a2-357f776b3b46",
IsArchived: false,
LlmProxyAccess: dotcom.ProductSubscriptionStateLlmProxyAccessLLMProxyAccess{
LLMProxyAccessFields: dotcom.LLMProxyAccessFields{
CodyGatewayAccess: dotcom.ProductSubscriptionStateCodyGatewayAccess{
CodyGatewayAccessFields: dotcom.CodyGatewayAccessFields{
Enabled: true,
ChatCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit{
ChatCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,
},
},
CodeCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit{
CodeCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,
@ -199,16 +199,16 @@ func TestAuthenticatorMiddleware(t *testing.T) {
Id: "UHJvZHVjdFN1YnNjcmlwdGlvbjoiNjQ1MmE4ZmMtZTY1MC00NWE3LWEwYTItMzU3Zjc3NmIzYjQ2Ig==",
Uuid: "6452a8fc-e650-45a7-a0a2-357f776b3b46",
IsArchived: false,
LlmProxyAccess: dotcom.ProductSubscriptionStateLlmProxyAccessLLMProxyAccess{
LLMProxyAccessFields: dotcom.LLMProxyAccessFields{
CodyGatewayAccess: dotcom.ProductSubscriptionStateCodyGatewayAccess{
CodyGatewayAccessFields: dotcom.CodyGatewayAccessFields{
Enabled: true,
ChatCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit{
ChatCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,
},
},
CodeCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit{
CodeCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,
@ -248,16 +248,16 @@ func TestAuthenticatorMiddleware(t *testing.T) {
Id: "UHJvZHVjdFN1YnNjcmlwdGlvbjoiNjQ1MmE4ZmMtZTY1MC00NWE3LWEwYTItMzU3Zjc3NmIzYjQ2Ig==",
Uuid: "6452a8fc-e650-45a7-a0a2-357f776b3b46",
IsArchived: false,
LlmProxyAccess: dotcom.ProductSubscriptionStateLlmProxyAccessLLMProxyAccess{
LLMProxyAccessFields: dotcom.LLMProxyAccessFields{
CodyGatewayAccess: dotcom.ProductSubscriptionStateCodyGatewayAccess{
CodyGatewayAccessFields: dotcom.CodyGatewayAccessFields{
Enabled: true,
ChatCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit{
ChatCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,
},
},
CodeCompletionsRateLimit: &dotcom.LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit{
CodeCompletionsRateLimit: &dotcom.CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit{
RateLimitFields: dotcom.RateLimitFields{
Limit: 10,
IntervalSeconds: 10,

View File

@ -53,9 +53,9 @@ func (v *CheckAccessTokenDotcomDotcomQueryProductSubscriptionByAccessTokenProduc
return v.ProductSubscriptionState.IsArchived
}
// GetLlmProxyAccess returns CheckAccessTokenDotcomDotcomQueryProductSubscriptionByAccessTokenProductSubscription.LlmProxyAccess, and is useful for accessing the field via an interface.
func (v *CheckAccessTokenDotcomDotcomQueryProductSubscriptionByAccessTokenProductSubscription) GetLlmProxyAccess() ProductSubscriptionStateLlmProxyAccessLLMProxyAccess {
return v.ProductSubscriptionState.LlmProxyAccess
// GetCodyGatewayAccess returns CheckAccessTokenDotcomDotcomQueryProductSubscriptionByAccessTokenProductSubscription.CodyGatewayAccess, and is useful for accessing the field via an interface.
func (v *CheckAccessTokenDotcomDotcomQueryProductSubscriptionByAccessTokenProductSubscription) GetCodyGatewayAccess() ProductSubscriptionStateCodyGatewayAccess {
return v.ProductSubscriptionState.CodyGatewayAccess
}
// GetActiveLicense returns CheckAccessTokenDotcomDotcomQueryProductSubscriptionByAccessTokenProductSubscription.ActiveLicense, and is useful for accessing the field via an interface.
@ -95,7 +95,7 @@ type __premarshalCheckAccessTokenDotcomDotcomQueryProductSubscriptionByAccessTok
IsArchived bool `json:"isArchived"`
LlmProxyAccess ProductSubscriptionStateLlmProxyAccessLLMProxyAccess `json:"llmProxyAccess"`
CodyGatewayAccess ProductSubscriptionStateCodyGatewayAccess `json:"codyGatewayAccess"`
ActiveLicense *ProductSubscriptionStateActiveLicenseProductLicense `json:"activeLicense"`
}
@ -114,7 +114,7 @@ func (v *CheckAccessTokenDotcomDotcomQueryProductSubscriptionByAccessTokenProduc
retval.Id = v.ProductSubscriptionState.Id
retval.Uuid = v.ProductSubscriptionState.Uuid
retval.IsArchived = v.ProductSubscriptionState.IsArchived
retval.LlmProxyAccess = v.ProductSubscriptionState.LlmProxyAccess
retval.CodyGatewayAccess = v.ProductSubscriptionState.CodyGatewayAccess
retval.ActiveLicense = v.ProductSubscriptionState.ActiveLicense
return &retval, nil
}
@ -130,73 +130,73 @@ type CheckAccessTokenResponse struct {
// GetDotcom returns CheckAccessTokenResponse.Dotcom, and is useful for accessing the field via an interface.
func (v *CheckAccessTokenResponse) GetDotcom() CheckAccessTokenDotcomDotcomQuery { return v.Dotcom }
// LLMProxyAccessFields includes the GraphQL fields of LLMProxyAccess requested by the fragment LLMProxyAccessFields.
// CodyGatewayAccessFields includes the GraphQL fields of CodyGatewayAccess requested by the fragment CodyGatewayAccessFields.
// The GraphQL type's documentation follows.
//
// LLM-proxy access granted to a subscription.
// Cody Gateway access granted to a subscription.
// FOR INTERNAL USE ONLY.
type LLMProxyAccessFields struct {
// Whether or not a subscription has LLM-proxy access.
type CodyGatewayAccessFields struct {
// Whether or not a subscription has Cody Gateway access.
Enabled bool `json:"enabled"`
// Rate limit for chat completions access, or null if not enabled.
ChatCompletionsRateLimit *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit `json:"chatCompletionsRateLimit"`
ChatCompletionsRateLimit *CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit `json:"chatCompletionsRateLimit"`
// Rate limit for code completions access, or null if not enabled.
CodeCompletionsRateLimit *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit `json:"codeCompletionsRateLimit"`
CodeCompletionsRateLimit *CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit `json:"codeCompletionsRateLimit"`
}
// GetEnabled returns LLMProxyAccessFields.Enabled, and is useful for accessing the field via an interface.
func (v *LLMProxyAccessFields) GetEnabled() bool { return v.Enabled }
// GetEnabled returns CodyGatewayAccessFields.Enabled, and is useful for accessing the field via an interface.
func (v *CodyGatewayAccessFields) GetEnabled() bool { return v.Enabled }
// GetChatCompletionsRateLimit returns LLMProxyAccessFields.ChatCompletionsRateLimit, and is useful for accessing the field via an interface.
func (v *LLMProxyAccessFields) GetChatCompletionsRateLimit() *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit {
// GetChatCompletionsRateLimit returns CodyGatewayAccessFields.ChatCompletionsRateLimit, and is useful for accessing the field via an interface.
func (v *CodyGatewayAccessFields) GetChatCompletionsRateLimit() *CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit {
return v.ChatCompletionsRateLimit
}
// GetCodeCompletionsRateLimit returns LLMProxyAccessFields.CodeCompletionsRateLimit, and is useful for accessing the field via an interface.
func (v *LLMProxyAccessFields) GetCodeCompletionsRateLimit() *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit {
// GetCodeCompletionsRateLimit returns CodyGatewayAccessFields.CodeCompletionsRateLimit, and is useful for accessing the field via an interface.
func (v *CodyGatewayAccessFields) GetCodeCompletionsRateLimit() *CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit {
return v.CodeCompletionsRateLimit
}
// LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit includes the requested fields of the GraphQL type LLMProxyRateLimit.
// CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit includes the requested fields of the GraphQL type CodyGatewayRateLimit.
// The GraphQL type's documentation follows.
//
// LLM-proxy access rate limits for a subscription.
// Cody Gateway access rate limits for a subscription.
// FOR INTERNAL USE ONLY.
type LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit struct {
type CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit struct {
RateLimitFields `json:"-"`
}
// GetAllowedModels returns LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit.AllowedModels, and is useful for accessing the field via an interface.
func (v *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit) GetAllowedModels() []string {
// GetAllowedModels returns CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit.AllowedModels, and is useful for accessing the field via an interface.
func (v *CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit) GetAllowedModels() []string {
return v.RateLimitFields.AllowedModels
}
// GetSource returns LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit.Source, and is useful for accessing the field via an interface.
func (v *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit) GetSource() LLMProxyRateLimitSource {
// GetSource returns CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit.Source, and is useful for accessing the field via an interface.
func (v *CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit) GetSource() CodyGatewayRateLimitSource {
return v.RateLimitFields.Source
}
// GetLimit returns LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit.Limit, and is useful for accessing the field via an interface.
func (v *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit) GetLimit() int {
// GetLimit returns CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit.Limit, and is useful for accessing the field via an interface.
func (v *CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit) GetLimit() int {
return v.RateLimitFields.Limit
}
// GetIntervalSeconds returns LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit.IntervalSeconds, and is useful for accessing the field via an interface.
func (v *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit) GetIntervalSeconds() int {
// GetIntervalSeconds returns CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit.IntervalSeconds, and is useful for accessing the field via an interface.
func (v *CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit) GetIntervalSeconds() int {
return v.RateLimitFields.IntervalSeconds
}
func (v *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit) UnmarshalJSON(b []byte) error {
func (v *CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit
*CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit
graphql.NoUnmarshalJSON
}
firstPass.LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit = v
firstPass.CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
@ -211,17 +211,17 @@ func (v *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit) Unmarsha
return nil
}
type __premarshalLLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit struct {
type __premarshalCodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit struct {
AllowedModels []string `json:"allowedModels"`
Source LLMProxyRateLimitSource `json:"source"`
Source CodyGatewayRateLimitSource `json:"source"`
Limit int `json:"limit"`
IntervalSeconds int `json:"intervalSeconds"`
}
func (v *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit) MarshalJSON() ([]byte, error) {
func (v *CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
@ -229,8 +229,8 @@ func (v *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit) MarshalJ
return json.Marshal(premarshaled)
}
func (v *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit) __premarshalJSON() (*__premarshalLLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit, error) {
var retval __premarshalLLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit
func (v *CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit) __premarshalJSON() (*__premarshalCodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit, error) {
var retval __premarshalCodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit
retval.AllowedModels = v.RateLimitFields.AllowedModels
retval.Source = v.RateLimitFields.Source
@ -239,46 +239,46 @@ func (v *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit) __premar
return &retval, nil
}
// LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit includes the requested fields of the GraphQL type LLMProxyRateLimit.
// CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit includes the requested fields of the GraphQL type CodyGatewayRateLimit.
// The GraphQL type's documentation follows.
//
// LLM-proxy access rate limits for a subscription.
// Cody Gateway access rate limits for a subscription.
// FOR INTERNAL USE ONLY.
type LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit struct {
type CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit struct {
RateLimitFields `json:"-"`
}
// GetAllowedModels returns LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit.AllowedModels, and is useful for accessing the field via an interface.
func (v *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit) GetAllowedModels() []string {
// GetAllowedModels returns CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit.AllowedModels, and is useful for accessing the field via an interface.
func (v *CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit) GetAllowedModels() []string {
return v.RateLimitFields.AllowedModels
}
// GetSource returns LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit.Source, and is useful for accessing the field via an interface.
func (v *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit) GetSource() LLMProxyRateLimitSource {
// GetSource returns CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit.Source, and is useful for accessing the field via an interface.
func (v *CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit) GetSource() CodyGatewayRateLimitSource {
return v.RateLimitFields.Source
}
// GetLimit returns LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit.Limit, and is useful for accessing the field via an interface.
func (v *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit) GetLimit() int {
// GetLimit returns CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit.Limit, and is useful for accessing the field via an interface.
func (v *CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit) GetLimit() int {
return v.RateLimitFields.Limit
}
// GetIntervalSeconds returns LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit.IntervalSeconds, and is useful for accessing the field via an interface.
func (v *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit) GetIntervalSeconds() int {
// GetIntervalSeconds returns CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit.IntervalSeconds, and is useful for accessing the field via an interface.
func (v *CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit) GetIntervalSeconds() int {
return v.RateLimitFields.IntervalSeconds
}
func (v *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit) UnmarshalJSON(b []byte) error {
func (v *CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit
*CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit
graphql.NoUnmarshalJSON
}
firstPass.LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit = v
firstPass.CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
@ -293,17 +293,17 @@ func (v *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit) Unmarsha
return nil
}
type __premarshalLLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit struct {
type __premarshalCodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit struct {
AllowedModels []string `json:"allowedModels"`
Source LLMProxyRateLimitSource `json:"source"`
Source CodyGatewayRateLimitSource `json:"source"`
Limit int `json:"limit"`
IntervalSeconds int `json:"intervalSeconds"`
}
func (v *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit) MarshalJSON() ([]byte, error) {
func (v *CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
@ -311,8 +311,8 @@ func (v *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit) MarshalJ
return json.Marshal(premarshaled)
}
func (v *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit) __premarshalJSON() (*__premarshalLLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit, error) {
var retval __premarshalLLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit
func (v *CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit) __premarshalJSON() (*__premarshalCodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit, error) {
var retval __premarshalCodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit
retval.AllowedModels = v.RateLimitFields.AllowedModels
retval.Source = v.RateLimitFields.Source
@ -323,13 +323,13 @@ func (v *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit) __premar
// The source of the rate limit returned.
// FOR INTERNAL USE ONLY.
type LLMProxyRateLimitSource string
type CodyGatewayRateLimitSource string
const (
// Indicates that a custom override for the rate limit has been stored.
LLMProxyRateLimitSourceOverride LLMProxyRateLimitSource = "OVERRIDE"
CodyGatewayRateLimitSourceOverride CodyGatewayRateLimitSource = "OVERRIDE"
// Indicates that the rate limit is inferred by the subscriptions active plan.
LLMProxyRateLimitSourcePlan LLMProxyRateLimitSource = "PLAN"
CodyGatewayRateLimitSourcePlan CodyGatewayRateLimitSource = "PLAN"
)
// ListProductSubscriptionFields includes the GraphQL fields of ProductSubscription requested by the fragment ListProductSubscriptionFields.
@ -360,9 +360,9 @@ func (v *ListProductSubscriptionFields) GetIsArchived() bool {
return v.ProductSubscriptionState.IsArchived
}
// GetLlmProxyAccess returns ListProductSubscriptionFields.LlmProxyAccess, and is useful for accessing the field via an interface.
func (v *ListProductSubscriptionFields) GetLlmProxyAccess() ProductSubscriptionStateLlmProxyAccessLLMProxyAccess {
return v.ProductSubscriptionState.LlmProxyAccess
// GetCodyGatewayAccess returns ListProductSubscriptionFields.CodyGatewayAccess, and is useful for accessing the field via an interface.
func (v *ListProductSubscriptionFields) GetCodyGatewayAccess() ProductSubscriptionStateCodyGatewayAccess {
return v.ProductSubscriptionState.CodyGatewayAccess
}
// GetActiveLicense returns ListProductSubscriptionFields.ActiveLicense, and is useful for accessing the field via an interface.
@ -404,7 +404,7 @@ type __premarshalListProductSubscriptionFields struct {
IsArchived bool `json:"isArchived"`
LlmProxyAccess ProductSubscriptionStateLlmProxyAccessLLMProxyAccess `json:"llmProxyAccess"`
CodyGatewayAccess ProductSubscriptionStateCodyGatewayAccess `json:"codyGatewayAccess"`
ActiveLicense *ProductSubscriptionStateActiveLicenseProductLicense `json:"activeLicense"`
}
@ -424,7 +424,7 @@ func (v *ListProductSubscriptionFields) __premarshalJSON() (*__premarshalListPro
retval.Id = v.ProductSubscriptionState.Id
retval.Uuid = v.ProductSubscriptionState.Uuid
retval.IsArchived = v.ProductSubscriptionState.IsArchived
retval.LlmProxyAccess = v.ProductSubscriptionState.LlmProxyAccess
retval.CodyGatewayAccess = v.ProductSubscriptionState.CodyGatewayAccess
retval.ActiveLicense = v.ProductSubscriptionState.ActiveLicense
return &retval, nil
}
@ -504,9 +504,9 @@ func (v *ListProductSubscriptionsDotcomDotcomQueryProductSubscriptionsProductSub
return v.ListProductSubscriptionFields.ProductSubscriptionState.IsArchived
}
// GetLlmProxyAccess returns ListProductSubscriptionsDotcomDotcomQueryProductSubscriptionsProductSubscriptionConnectionNodesProductSubscription.LlmProxyAccess, and is useful for accessing the field via an interface.
func (v *ListProductSubscriptionsDotcomDotcomQueryProductSubscriptionsProductSubscriptionConnectionNodesProductSubscription) GetLlmProxyAccess() ProductSubscriptionStateLlmProxyAccessLLMProxyAccess {
return v.ListProductSubscriptionFields.ProductSubscriptionState.LlmProxyAccess
// GetCodyGatewayAccess returns ListProductSubscriptionsDotcomDotcomQueryProductSubscriptionsProductSubscriptionConnectionNodesProductSubscription.CodyGatewayAccess, and is useful for accessing the field via an interface.
func (v *ListProductSubscriptionsDotcomDotcomQueryProductSubscriptionsProductSubscriptionConnectionNodesProductSubscription) GetCodyGatewayAccess() ProductSubscriptionStateCodyGatewayAccess {
return v.ListProductSubscriptionFields.ProductSubscriptionState.CodyGatewayAccess
}
// GetActiveLicense returns ListProductSubscriptionsDotcomDotcomQueryProductSubscriptionsProductSubscriptionConnectionNodesProductSubscription.ActiveLicense, and is useful for accessing the field via an interface.
@ -548,7 +548,7 @@ type __premarshalListProductSubscriptionsDotcomDotcomQueryProductSubscriptionsPr
IsArchived bool `json:"isArchived"`
LlmProxyAccess ProductSubscriptionStateLlmProxyAccessLLMProxyAccess `json:"llmProxyAccess"`
CodyGatewayAccess ProductSubscriptionStateCodyGatewayAccess `json:"codyGatewayAccess"`
ActiveLicense *ProductSubscriptionStateActiveLicenseProductLicense `json:"activeLicense"`
}
@ -568,7 +568,7 @@ func (v *ListProductSubscriptionsDotcomDotcomQueryProductSubscriptionsProductSub
retval.Id = v.ListProductSubscriptionFields.ProductSubscriptionState.Id
retval.Uuid = v.ListProductSubscriptionFields.ProductSubscriptionState.Uuid
retval.IsArchived = v.ListProductSubscriptionFields.ProductSubscriptionState.IsArchived
retval.LlmProxyAccess = v.ListProductSubscriptionFields.ProductSubscriptionState.LlmProxyAccess
retval.CodyGatewayAccess = v.ListProductSubscriptionFields.ProductSubscriptionState.CodyGatewayAccess
retval.ActiveLicense = v.ListProductSubscriptionFields.ProductSubscriptionState.ActiveLicense
return &retval, nil
}
@ -620,8 +620,8 @@ type ProductSubscriptionState struct {
Uuid string `json:"uuid"`
// Whether this product subscription was archived.
IsArchived bool `json:"isArchived"`
// LLM-proxy access granted to this subscription. Properties may be inferred from the active license, or be defined in overrides.
LlmProxyAccess ProductSubscriptionStateLlmProxyAccessLLMProxyAccess `json:"llmProxyAccess"`
// Cody Gateway access granted to this subscription. Properties may be inferred from the active license, or be defined in overrides.
CodyGatewayAccess ProductSubscriptionStateCodyGatewayAccess `json:"codyGatewayAccess"`
// The currently active product license associated with this product subscription, if any.
ActiveLicense *ProductSubscriptionStateActiveLicenseProductLicense `json:"activeLicense"`
}
@ -635,9 +635,9 @@ func (v *ProductSubscriptionState) GetUuid() string { return v.Uuid }
// GetIsArchived returns ProductSubscriptionState.IsArchived, and is useful for accessing the field via an interface.
func (v *ProductSubscriptionState) GetIsArchived() bool { return v.IsArchived }
// GetLlmProxyAccess returns ProductSubscriptionState.LlmProxyAccess, and is useful for accessing the field via an interface.
func (v *ProductSubscriptionState) GetLlmProxyAccess() ProductSubscriptionStateLlmProxyAccessLLMProxyAccess {
return v.LlmProxyAccess
// GetCodyGatewayAccess returns ProductSubscriptionState.CodyGatewayAccess, and is useful for accessing the field via an interface.
func (v *ProductSubscriptionState) GetCodyGatewayAccess() ProductSubscriptionStateCodyGatewayAccess {
return v.CodyGatewayAccess
}
// GetActiveLicense returns ProductSubscriptionState.ActiveLicense, and is useful for accessing the field via an interface.
@ -672,41 +672,41 @@ type ProductSubscriptionStateActiveLicenseProductLicenseInfo struct {
// GetTags returns ProductSubscriptionStateActiveLicenseProductLicenseInfo.Tags, and is useful for accessing the field via an interface.
func (v *ProductSubscriptionStateActiveLicenseProductLicenseInfo) GetTags() []string { return v.Tags }
// ProductSubscriptionStateLlmProxyAccessLLMProxyAccess includes the requested fields of the GraphQL type LLMProxyAccess.
// ProductSubscriptionStateCodyGatewayAccess includes the requested fields of the GraphQL type CodyGatewayAccess.
// The GraphQL type's documentation follows.
//
// LLM-proxy access granted to a subscription.
// Cody Gateway access granted to a subscription.
// FOR INTERNAL USE ONLY.
type ProductSubscriptionStateLlmProxyAccessLLMProxyAccess struct {
LLMProxyAccessFields `json:"-"`
type ProductSubscriptionStateCodyGatewayAccess struct {
CodyGatewayAccessFields `json:"-"`
}
// GetEnabled returns ProductSubscriptionStateLlmProxyAccessLLMProxyAccess.Enabled, and is useful for accessing the field via an interface.
func (v *ProductSubscriptionStateLlmProxyAccessLLMProxyAccess) GetEnabled() bool {
return v.LLMProxyAccessFields.Enabled
// GetEnabled returns ProductSubscriptionStateCodyGatewayAccess.Enabled, and is useful for accessing the field via an interface.
func (v *ProductSubscriptionStateCodyGatewayAccess) GetEnabled() bool {
return v.CodyGatewayAccessFields.Enabled
}
// GetChatCompletionsRateLimit returns ProductSubscriptionStateLlmProxyAccessLLMProxyAccess.ChatCompletionsRateLimit, and is useful for accessing the field via an interface.
func (v *ProductSubscriptionStateLlmProxyAccessLLMProxyAccess) GetChatCompletionsRateLimit() *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit {
return v.LLMProxyAccessFields.ChatCompletionsRateLimit
// GetChatCompletionsRateLimit returns ProductSubscriptionStateCodyGatewayAccess.ChatCompletionsRateLimit, and is useful for accessing the field via an interface.
func (v *ProductSubscriptionStateCodyGatewayAccess) GetChatCompletionsRateLimit() *CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit {
return v.CodyGatewayAccessFields.ChatCompletionsRateLimit
}
// GetCodeCompletionsRateLimit returns ProductSubscriptionStateLlmProxyAccessLLMProxyAccess.CodeCompletionsRateLimit, and is useful for accessing the field via an interface.
func (v *ProductSubscriptionStateLlmProxyAccessLLMProxyAccess) GetCodeCompletionsRateLimit() *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit {
return v.LLMProxyAccessFields.CodeCompletionsRateLimit
// GetCodeCompletionsRateLimit returns ProductSubscriptionStateCodyGatewayAccess.CodeCompletionsRateLimit, and is useful for accessing the field via an interface.
func (v *ProductSubscriptionStateCodyGatewayAccess) GetCodeCompletionsRateLimit() *CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit {
return v.CodyGatewayAccessFields.CodeCompletionsRateLimit
}
func (v *ProductSubscriptionStateLlmProxyAccessLLMProxyAccess) UnmarshalJSON(b []byte) error {
func (v *ProductSubscriptionStateCodyGatewayAccess) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*ProductSubscriptionStateLlmProxyAccessLLMProxyAccess
*ProductSubscriptionStateCodyGatewayAccess
graphql.NoUnmarshalJSON
}
firstPass.ProductSubscriptionStateLlmProxyAccessLLMProxyAccess = v
firstPass.ProductSubscriptionStateCodyGatewayAccess = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
@ -714,22 +714,22 @@ func (v *ProductSubscriptionStateLlmProxyAccessLLMProxyAccess) UnmarshalJSON(b [
}
err = json.Unmarshal(
b, &v.LLMProxyAccessFields)
b, &v.CodyGatewayAccessFields)
if err != nil {
return err
}
return nil
}
type __premarshalProductSubscriptionStateLlmProxyAccessLLMProxyAccess struct {
type __premarshalProductSubscriptionStateCodyGatewayAccess struct {
Enabled bool `json:"enabled"`
ChatCompletionsRateLimit *LLMProxyAccessFieldsChatCompletionsRateLimitLLMProxyRateLimit `json:"chatCompletionsRateLimit"`
ChatCompletionsRateLimit *CodyGatewayAccessFieldsChatCompletionsRateLimitCodyGatewayRateLimit `json:"chatCompletionsRateLimit"`
CodeCompletionsRateLimit *LLMProxyAccessFieldsCodeCompletionsRateLimitLLMProxyRateLimit `json:"codeCompletionsRateLimit"`
CodeCompletionsRateLimit *CodyGatewayAccessFieldsCodeCompletionsRateLimitCodyGatewayRateLimit `json:"codeCompletionsRateLimit"`
}
func (v *ProductSubscriptionStateLlmProxyAccessLLMProxyAccess) MarshalJSON() ([]byte, error) {
func (v *ProductSubscriptionStateCodyGatewayAccess) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
@ -737,19 +737,19 @@ func (v *ProductSubscriptionStateLlmProxyAccessLLMProxyAccess) MarshalJSON() ([]
return json.Marshal(premarshaled)
}
func (v *ProductSubscriptionStateLlmProxyAccessLLMProxyAccess) __premarshalJSON() (*__premarshalProductSubscriptionStateLlmProxyAccessLLMProxyAccess, error) {
var retval __premarshalProductSubscriptionStateLlmProxyAccessLLMProxyAccess
func (v *ProductSubscriptionStateCodyGatewayAccess) __premarshalJSON() (*__premarshalProductSubscriptionStateCodyGatewayAccess, error) {
var retval __premarshalProductSubscriptionStateCodyGatewayAccess
retval.Enabled = v.LLMProxyAccessFields.Enabled
retval.ChatCompletionsRateLimit = v.LLMProxyAccessFields.ChatCompletionsRateLimit
retval.CodeCompletionsRateLimit = v.LLMProxyAccessFields.CodeCompletionsRateLimit
retval.Enabled = v.CodyGatewayAccessFields.Enabled
retval.ChatCompletionsRateLimit = v.CodyGatewayAccessFields.ChatCompletionsRateLimit
retval.CodeCompletionsRateLimit = v.CodyGatewayAccessFields.CodeCompletionsRateLimit
return &retval, nil
}
// RateLimitFields includes the GraphQL fields of LLMProxyRateLimit requested by the fragment RateLimitFields.
// RateLimitFields includes the GraphQL fields of CodyGatewayRateLimit requested by the fragment RateLimitFields.
// The GraphQL type's documentation follows.
//
// LLM-proxy access rate limits for a subscription.
// Cody Gateway access rate limits for a subscription.
// FOR INTERNAL USE ONLY.
type RateLimitFields struct {
// The models that are allowed for this rate limit bucket.
@ -758,7 +758,7 @@ type RateLimitFields struct {
// config could include [{claude-v1, claude-v1.3},{claude-instant-v1}].
AllowedModels []string `json:"allowedModels"`
// The source of the rate limit configuration.
Source LLMProxyRateLimitSource `json:"source"`
Source CodyGatewayRateLimitSource `json:"source"`
// Requests per time interval.
Limit int `json:"limit"`
// Interval for rate limiting.
@ -769,7 +769,7 @@ type RateLimitFields struct {
func (v *RateLimitFields) GetAllowedModels() []string { return v.AllowedModels }
// GetSource returns RateLimitFields.Source, and is useful for accessing the field via an interface.
func (v *RateLimitFields) GetSource() LLMProxyRateLimitSource { return v.Source }
func (v *RateLimitFields) GetSource() CodyGatewayRateLimitSource { return v.Source }
// GetLimit returns RateLimitFields.Limit, and is useful for accessing the field via an interface.
func (v *RateLimitFields) GetLimit() int { return v.Limit }
@ -806,8 +806,8 @@ fragment ProductSubscriptionState on ProductSubscription {
id
uuid
isArchived
llmProxyAccess {
... LLMProxyAccessFields
codyGatewayAccess {
... CodyGatewayAccessFields
}
activeLicense {
info {
@ -815,7 +815,7 @@ fragment ProductSubscriptionState on ProductSubscription {
}
}
}
fragment LLMProxyAccessFields on LLMProxyAccess {
fragment CodyGatewayAccessFields on CodyGatewayAccess {
enabled
chatCompletionsRateLimit {
... RateLimitFields
@ -824,7 +824,7 @@ fragment LLMProxyAccessFields on LLMProxyAccess {
... RateLimitFields
}
}
fragment RateLimitFields on LLMProxyRateLimit {
fragment RateLimitFields on CodyGatewayRateLimit {
allowedModels
source
limit
@ -878,8 +878,8 @@ fragment ProductSubscriptionState on ProductSubscription {
id
uuid
isArchived
llmProxyAccess {
... LLMProxyAccessFields
codyGatewayAccess {
... CodyGatewayAccessFields
}
activeLicense {
info {
@ -887,7 +887,7 @@ fragment ProductSubscriptionState on ProductSubscription {
}
}
}
fragment LLMProxyAccessFields on LLMProxyAccess {
fragment CodyGatewayAccessFields on CodyGatewayAccess {
enabled
chatCompletionsRateLimit {
... RateLimitFields
@ -896,7 +896,7 @@ fragment LLMProxyAccessFields on LLMProxyAccess {
... RateLimitFields
}
}
fragment RateLimitFields on LLMProxyRateLimit {
fragment RateLimitFields on CodyGatewayRateLimit {
allowedModels
source
limit

View File

@ -1,11 +1,11 @@
fragment RateLimitFields on LLMProxyRateLimit {
fragment RateLimitFields on CodyGatewayRateLimit {
allowedModels
source
limit
intervalSeconds
}
fragment LLMProxyAccessFields on LLMProxyAccess {
fragment CodyGatewayAccessFields on CodyGatewayAccess {
enabled
chatCompletionsRateLimit {
...RateLimitFields
@ -19,8 +19,8 @@ fragment ProductSubscriptionState on ProductSubscription {
id
uuid
isArchived
llmProxyAccess {
...LLMProxyAccessFields
codyGatewayAccess {
...CodyGatewayAccessFields
}
activeLicense {
info {

View File

@ -57,7 +57,7 @@ type TraceConfig struct {
func (c *Config) Load() {
c.InsecureDev = env.InsecureDev
c.Address = c.Get("CODY_GATEWAY_ADDR", ":9992", "Address to serve LLM proxy on.")
c.Address = c.Get("CODY_GATEWAY_ADDR", ":9992", "Address to serve Cody Gateway on.")
c.DiagnosticsSecret = c.GetOptional("CODY_GATEWAY_DIAGNOSTICS_SECRET", "Secret for accessing diagnostics - "+
"should be used as 'Authorization: Bearer $secret' header when accessing diagnostics endpoints.")
@ -73,7 +73,7 @@ func (c *Config) Load() {
c.OpenAI.OrgID = c.GetOptional("CODY_GATEWAY_OPENAI_ORG_ID", "The OpenAI organization to count billing towards. Setting this ensures we always use the correct negotiated terms.")
c.OpenAI.AllowedModels = splitMaybe(c.Get("CODY_GATEWAY_OPENAI_ALLOWED_MODELS", "gpt-4,gpt-3.5-turbo", "The Anthropic access token to be used."))
c.AllowAnonymous = c.GetBool("CODY_GATEWAY_ALLOW_ANONYMOUS", "false", "Allow anonymous access to LLM proxy.")
c.AllowAnonymous = c.GetBool("CODY_GATEWAY_ALLOW_ANONYMOUS", "false", "Allow anonymous access to Cody Gateway.")
c.SourcesSyncInterval = c.GetInterval("CODY_GATEWAY_SOURCES_SYNC_INTERVAL", "2m", "The interval at which to sync actor sources.")
c.BigQuery.ProjectID = c.Get("CODY_GATEWAY_BIGQUERY_PROJECT_ID", os.Getenv("GOOGLE_CLOUD_PROJECT"), "The project ID for the BigQuery events.")

View File

@ -34,7 +34,7 @@ import (
func Main(ctx context.Context, obctx *observation.Context, ready service.ReadyFunc, config *Config) error {
// Enable tracing, at this point tracing wouldn't have been enabled yet because
// we run LLM-proxy without conf which means Sourcegraph tracing is not enabled.
// we run Cody Gateway without conf which means Sourcegraph tracing is not enabled.
shutdownTracing, err := maybeEnableTracing(ctx,
obctx.Logger.Scoped("tracing", "tracing configuration"),
config.Trace)
@ -95,7 +95,7 @@ func Main(ctx context.Context, obctx *observation.Context, ready service.ReadyFu
handler = instrumentation.HTTPMiddleware("cody-gateway", handler, otelhttpOpts...)
// Collect request client for downstream handlers. Outside of dev, we always set up
// Cloudflare in from of LLM-proxy. This comes first.
// Cloudflare in from of Cody Gateway. This comes first.
hasCloudflare := !config.InsecureDev
handler = requestclient.ExternalHTTPMiddleware(handler, hasCloudflare)

View File

@ -3,13 +3,13 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "productsubscription",
srcs = [
"codygateway_graphql.go",
"codygateway_service.go",
"doc.go",
"graphql.go",
"license_expiration.go",
"licenses_db.go",
"licenses_graphql.go",
"llmproxy_graphql.go",
"llmproxyservice.go",
"mock_db.go",
"service_account.go",
"subscriptions_db.go",
@ -56,9 +56,9 @@ go_library(
go_test(
name = "productsubscription_test",
srcs = [
"codygateway_graphql_test.go",
"license_expiration_test.go",
"licenses_db_test.go",
"llmproxy_graphql_test.go",
"service_account_test.go",
"subscriptions_db_test.go",
"subscriptions_graphql_test.go",

View File

@ -11,13 +11,13 @@ import (
"github.com/sourcegraph/sourcegraph/lib/errors"
)
type llmProxyAccessResolver struct {
type codyGatewayAccessResolver struct {
sub *productSubscription
}
func (r llmProxyAccessResolver) Enabled() bool { return r.sub.v.LLMProxyAccess.Enabled }
func (r codyGatewayAccessResolver) Enabled() bool { return r.sub.v.LLMProxyAccess.Enabled }
func (r llmProxyAccessResolver) ChatCompletionsRateLimit(ctx context.Context) (graphqlbackend.LLMProxyRateLimit, error) {
func (r codyGatewayAccessResolver) ChatCompletionsRateLimit(ctx context.Context) (graphqlbackend.CodyGatewayRateLimit, error) {
if !r.Enabled() {
return nil, nil
}
@ -31,28 +31,28 @@ func (r llmProxyAccessResolver) ChatCompletionsRateLimit(ctx context.Context) (g
if err != nil {
return nil, errors.Wrap(err, "could not get active license")
}
var source graphqlbackend.LLMProxyRateLimitSource
var source graphqlbackend.CodyGatewayRateLimitSource
if activeLicense != nil {
source = graphqlbackend.LLMProxyRateLimitSourcePlan
source = graphqlbackend.CodyGatewayRateLimitSourcePlan
rateLimit = licensing.NewCodyGatewayChatRateLimit(licensing.PlanFromTags(activeLicense.LicenseTags), activeLicense.LicenseUserCount, activeLicense.LicenseTags)
}
// Apply overrides
rateLimitOverrides := r.sub.v.LLMProxyAccess
if rateLimitOverrides.ChatRateLimit.RateLimit != nil {
source = graphqlbackend.LLMProxyRateLimitSourceOverride
source = graphqlbackend.CodyGatewayRateLimitSourceOverride
rateLimit.Limit = *rateLimitOverrides.ChatRateLimit.RateLimit
}
if rateLimitOverrides.ChatRateLimit.RateIntervalSeconds != nil {
source = graphqlbackend.LLMProxyRateLimitSourceOverride
source = graphqlbackend.CodyGatewayRateLimitSourceOverride
rateLimit.IntervalSeconds = *rateLimitOverrides.ChatRateLimit.RateIntervalSeconds
}
if rateLimitOverrides.ChatRateLimit.AllowedModels != nil {
source = graphqlbackend.LLMProxyRateLimitSourceOverride
source = graphqlbackend.CodyGatewayRateLimitSourceOverride
rateLimit.AllowedModels = rateLimitOverrides.ChatRateLimit.AllowedModels
}
return &llmProxyRateLimitResolver{
return &codyGatewayRateLimitResolver{
feature: types.CompletionsFeatureChat,
subUUID: r.sub.UUID(),
v: rateLimit,
@ -60,7 +60,7 @@ func (r llmProxyAccessResolver) ChatCompletionsRateLimit(ctx context.Context) (g
}, nil
}
func (r llmProxyAccessResolver) CodeCompletionsRateLimit(ctx context.Context) (graphqlbackend.LLMProxyRateLimit, error) {
func (r codyGatewayAccessResolver) CodeCompletionsRateLimit(ctx context.Context) (graphqlbackend.CodyGatewayRateLimit, error) {
if !r.Enabled() {
return nil, nil
}
@ -74,28 +74,28 @@ func (r llmProxyAccessResolver) CodeCompletionsRateLimit(ctx context.Context) (g
if err != nil {
return nil, errors.Wrap(err, "could not get active license")
}
var source graphqlbackend.LLMProxyRateLimitSource
var source graphqlbackend.CodyGatewayRateLimitSource
if activeLicense != nil {
source = graphqlbackend.LLMProxyRateLimitSourcePlan
source = graphqlbackend.CodyGatewayRateLimitSourcePlan
rateLimit = licensing.NewCodyGatewayCodeRateLimit(licensing.PlanFromTags(activeLicense.LicenseTags), activeLicense.LicenseUserCount, activeLicense.LicenseTags)
}
// Apply overrides
rateLimitOverrides := r.sub.v.LLMProxyAccess
if rateLimitOverrides.CodeRateLimit.RateLimit != nil {
source = graphqlbackend.LLMProxyRateLimitSourceOverride
source = graphqlbackend.CodyGatewayRateLimitSourceOverride
rateLimit.Limit = *rateLimitOverrides.CodeRateLimit.RateLimit
}
if rateLimitOverrides.CodeRateLimit.RateIntervalSeconds != nil {
source = graphqlbackend.LLMProxyRateLimitSourceOverride
source = graphqlbackend.CodyGatewayRateLimitSourceOverride
rateLimit.IntervalSeconds = *rateLimitOverrides.CodeRateLimit.RateIntervalSeconds
}
if rateLimitOverrides.CodeRateLimit.AllowedModels != nil {
source = graphqlbackend.LLMProxyRateLimitSourceOverride
source = graphqlbackend.CodyGatewayRateLimitSourceOverride
rateLimit.AllowedModels = rateLimitOverrides.CodeRateLimit.AllowedModels
}
return &llmProxyRateLimitResolver{
return &codyGatewayRateLimitResolver{
feature: types.CompletionsFeatureCode,
subUUID: r.sub.UUID(),
v: rateLimit,
@ -103,30 +103,32 @@ func (r llmProxyAccessResolver) CodeCompletionsRateLimit(ctx context.Context) (g
}, nil
}
type llmProxyRateLimitResolver struct {
type codyGatewayRateLimitResolver struct {
subUUID string
feature types.CompletionsFeature
source graphqlbackend.LLMProxyRateLimitSource
source graphqlbackend.CodyGatewayRateLimitSource
v licensing.CodyGatewayRateLimit
}
func (r *llmProxyRateLimitResolver) Source() graphqlbackend.LLMProxyRateLimitSource { return r.source }
func (r *codyGatewayRateLimitResolver) Source() graphqlbackend.CodyGatewayRateLimitSource {
return r.source
}
func (r *llmProxyRateLimitResolver) AllowedModels() []string { return r.v.AllowedModels }
func (r *codyGatewayRateLimitResolver) AllowedModels() []string { return r.v.AllowedModels }
func (r *llmProxyRateLimitResolver) Limit() int32 { return r.v.Limit }
func (r *codyGatewayRateLimitResolver) Limit() int32 { return r.v.Limit }
func (r *llmProxyRateLimitResolver) IntervalSeconds() int32 { return r.v.IntervalSeconds }
func (r *codyGatewayRateLimitResolver) IntervalSeconds() int32 { return r.v.IntervalSeconds }
func (r llmProxyRateLimitResolver) Usage(ctx context.Context) ([]graphqlbackend.LLMProxyUsageDatapoint, error) {
usage, err := NewLLMProxyService().UsageForSubscription(ctx, r.feature, r.subUUID)
func (r codyGatewayRateLimitResolver) Usage(ctx context.Context) ([]graphqlbackend.CodyGatewayUsageDatapoint, error) {
usage, err := NewCodyGatewayService().UsageForSubscription(ctx, r.feature, r.subUUID)
if err != nil {
return nil, err
}
resolvers := make([]graphqlbackend.LLMProxyUsageDatapoint, 0, len(usage))
resolvers := make([]graphqlbackend.CodyGatewayUsageDatapoint, 0, len(usage))
for _, u := range usage {
resolvers = append(resolvers, &llmProxyUsageDatapoint{
resolvers = append(resolvers, &codyGatewayUsageDatapoint{
date: u.Date,
model: u.Model,
count: u.Count,
@ -136,20 +138,20 @@ func (r llmProxyRateLimitResolver) Usage(ctx context.Context) ([]graphqlbackend.
return resolvers, nil
}
type llmProxyUsageDatapoint struct {
type codyGatewayUsageDatapoint struct {
date time.Time
model string
count int
}
func (r *llmProxyUsageDatapoint) Date() gqlutil.DateTime {
func (r *codyGatewayUsageDatapoint) Date() gqlutil.DateTime {
return gqlutil.DateTime{Time: r.date}
}
func (r *llmProxyUsageDatapoint) Model() string {
func (r *codyGatewayUsageDatapoint) Model() string {
return r.model
}
func (r *llmProxyUsageDatapoint) Count() int32 {
func (r *codyGatewayUsageDatapoint) Count() int32 {
return int32(r.count)
}

View File

@ -18,7 +18,7 @@ import (
"github.com/sourcegraph/sourcegraph/internal/timeutil"
)
func TestLLMProxyAccessResolverRateLimit(t *testing.T) {
func TestCodeGatewayAccessResolverRateLimit(t *testing.T) {
logger := logtest.Scoped(t)
db := database.NewDB(logger, dbtest.NewDB(logger, t))
ctx := context.Background()
@ -36,27 +36,27 @@ func TestLLMProxyAccessResolverRateLimit(t *testing.T) {
_, err = dbLicenses{db: db}.Create(ctx, subID, "k2", 1, info)
require.NoError(t, err)
// Enable access to LLM proxy.
// Enable access to Cody Gateway.
tru := true
err = dbSubscriptions{db: db}.Update(ctx, subID, dbSubscriptionUpdate{llmProxyAccess: &graphqlbackend.UpdateLLMProxyAccessInput{Enabled: &tru}})
err = dbSubscriptions{db: db}.Update(ctx, subID, dbSubscriptionUpdate{codyGatewayAccess: &graphqlbackend.UpdateCodyGatewayAccessInput{Enabled: &tru}})
require.NoError(t, err)
t.Run("default rate limit for a plan", func(t *testing.T) {
sub, err := dbSubscriptions{db: db}.GetByID(ctx, subID)
require.NoError(t, err)
r := llmProxyAccessResolver{sub: &productSubscription{v: sub, db: db}}
wantRateLimit := licensing.NewCodyGatewayChatRateLimit(licensing.PlanEnterprise1, pointify(int(info.UserCount)), []string{})
r := codyGatewayAccessResolver{sub: &productSubscription{v: sub, db: db}}
rateLimit, err := r.ChatCompletionsRateLimit(ctx)
require.NoError(t, err)
wantRateLimit := licensing.NewCodyGatewayChatRateLimit(licensing.PlanEnterprise1, pointify(int(info.UserCount)), []string{})
assert.Equal(t, wantRateLimit.Limit, rateLimit.Limit())
assert.Equal(t, wantRateLimit.IntervalSeconds, rateLimit.IntervalSeconds())
})
t.Run("override default rate limit for a plan", func(t *testing.T) {
err := (dbSubscriptions{db: db}.Update(ctx, subID, dbSubscriptionUpdate{
llmProxyAccess: &graphqlbackend.UpdateLLMProxyAccessInput{
codyGatewayAccess: &graphqlbackend.UpdateCodyGatewayAccessInput{
ChatCompletionsRateLimit: pointify(int32(10)),
},
}))
@ -65,11 +65,11 @@ func TestLLMProxyAccessResolverRateLimit(t *testing.T) {
sub, err := dbSubscriptions{db: db}.GetByID(ctx, subID)
require.NoError(t, err)
r := llmProxyAccessResolver{sub: &productSubscription{v: sub, db: db}}
defaultRateLimit := licensing.NewCodyGatewayChatRateLimit(licensing.PlanEnterprise1, pointify(10), []string{})
r := codyGatewayAccessResolver{sub: &productSubscription{v: sub, db: db}}
rateLimit, err := r.ChatCompletionsRateLimit(ctx)
require.NoError(t, err)
defaultRateLimit := licensing.NewCodyGatewayChatRateLimit(licensing.PlanEnterprise1, pointify(10), []string{})
assert.Equal(t, int32(10), rateLimit.Limit())
assert.Equal(t, defaultRateLimit.IntervalSeconds, rateLimit.IntervalSeconds())
})

View File

@ -16,13 +16,18 @@ import (
"github.com/sourcegraph/sourcegraph/lib/errors"
)
var llmProxySACredentialFilePath = env.Get("LLM_PROXY_BIGQUERY_ACCESS_CREDENTIALS_FILE", "", "")
var codyGatewaySACredentialFilePath = func() string {
if v := env.Get("CODY_GATEWAY_BIGQUERY_ACCESS_CREDENTIALS_FILE", "", "BigQuery credentials for the Cody Gateway service"); v != "" {
return v
}
return env.Get("LLM_PROXY_BIGQUERY_ACCESS_CREDENTIALS_FILE", "", "DEPRECATED: Use CODY_GATEWAY_BIGQUERY_ACCESS_CREDENTIALS_FILE instead")
}()
type LLMProxyService interface {
type CodyGatewayService interface {
UsageForSubscription(ctx context.Context, uuid string) ([]SubscriptionUsage, error)
}
type LLMProxyServiceOptions struct {
type CodyGatewayServiceOptions struct {
BigQuery ServiceBigQueryOptions
}
@ -37,22 +42,22 @@ func (o ServiceBigQueryOptions) IsConfigured() bool {
return o.ProjectID != "" && o.Dataset != "" && o.EventsTable != ""
}
func NewLLMProxyService() *llmProxyService {
opts := LLMProxyServiceOptions{}
func NewCodyGatewayService() *codyGatewayService {
opts := CodyGatewayServiceOptions{}
d := conf.Get().Dotcom
if d != nil && d.LlmProxy != nil {
opts.BigQuery.CredentialFilePath = llmProxySACredentialFilePath
opts.BigQuery.ProjectID = d.LlmProxy.BigQueryGoogleProjectID
opts.BigQuery.Dataset = d.LlmProxy.BigQueryDataset
opts.BigQuery.EventsTable = d.LlmProxy.BigQueryTable
if d != nil && d.CodyGateway != nil {
opts.BigQuery.CredentialFilePath = codyGatewaySACredentialFilePath
opts.BigQuery.ProjectID = d.CodyGateway.BigQueryGoogleProjectID
opts.BigQuery.Dataset = d.CodyGateway.BigQueryDataset
opts.BigQuery.EventsTable = d.CodyGateway.BigQueryTable
}
return NewLLMProxyServiceWithOptions(opts)
return NewCodyGatewayServiceWithOptions(opts)
}
func NewLLMProxyServiceWithOptions(opts LLMProxyServiceOptions) *llmProxyService {
return &llmProxyService{
func NewCodyGatewayServiceWithOptions(opts CodyGatewayServiceOptions) *codyGatewayService {
return &codyGatewayService{
opts: opts,
}
}
@ -63,11 +68,11 @@ type SubscriptionUsage struct {
Count int
}
type llmProxyService struct {
opts LLMProxyServiceOptions
type codyGatewayService struct {
opts CodyGatewayServiceOptions
}
func (s *llmProxyService) UsageForSubscription(ctx context.Context, feature types.CompletionsFeature, uuid string) ([]SubscriptionUsage, error) {
func (s *codyGatewayService) UsageForSubscription(ctx context.Context, feature types.CompletionsFeature, uuid string) ([]SubscriptionUsage, error) {
if !s.opts.BigQuery.IsConfigured() {
// Not configured, nothing we can do.
return nil, nil

View File

@ -23,6 +23,7 @@ type dbRateLimit struct {
RateIntervalSeconds *int32
}
// TODO(@bobheadxi): Rename when DB columns are renamed.
type dbLLMProxyAccess struct {
Enabled bool
ChatRateLimit dbRateLimit
@ -38,7 +39,9 @@ type dbSubscription struct {
CreatedAt time.Time
ArchivedAt *time.Time
AccountNumber *string
LLMProxyAccess dbLLMProxyAccess
// TODO(@bobheadxi): Rename when DB columns are renamed.
LLMProxyAccess dbLLMProxyAccess
}
var emailQueries = sqlf.Sprintf(`all_primary_emails AS (
@ -212,7 +215,7 @@ WHERE (%s)`, emailQueries, sqlf.Join(opt.sqlConditions(), ") AND ("))
// value is nil, the field remains unchanged in the database.
type dbSubscriptionUpdate struct {
billingSubscriptionID *sql.NullString
llmProxyAccess *graphqlbackend.UpdateLLMProxyAccessInput
codyGatewayAccess *graphqlbackend.UpdateCodyGatewayAccessInput
}
// Update updates a product subscription.
@ -223,7 +226,7 @@ func (s dbSubscriptions) Update(ctx context.Context, id string, update dbSubscri
if v := update.billingSubscriptionID; v != nil {
fieldUpdates = append(fieldUpdates, sqlf.Sprintf("billing_subscription_id=%s", *v))
}
if access := update.llmProxyAccess; access != nil {
if access := update.codyGatewayAccess; access != nil {
if v := access.Enabled; v != nil {
fieldUpdates = append(fieldUpdates, sqlf.Sprintf("llm_proxy_enabled=%s", *v))
}

View File

@ -155,10 +155,10 @@ func TestProductSubscriptions_Update(t *testing.T) {
})
})
t.Run("llmProxyAccess", func(t *testing.T) {
t.Run("codyGatewayAccess", func(t *testing.T) {
t.Run("set non-null values", func(t *testing.T) {
err := subscriptions.Update(ctx, sub0, dbSubscriptionUpdate{
llmProxyAccess: &graphqlbackend.UpdateLLMProxyAccessInput{
codyGatewayAccess: &graphqlbackend.UpdateCodyGatewayAccessInput{
Enabled: pointify(true),
ChatCompletionsRateLimit: pointify(int32(12)),
ChatCompletionsRateLimitIntervalSeconds: pointify(int32(time.Hour.Seconds())),
@ -178,7 +178,7 @@ func TestProductSubscriptions_Update(t *testing.T) {
t.Run("set to zero/null values", func(t *testing.T) {
err := subscriptions.Update(ctx, sub0, dbSubscriptionUpdate{
llmProxyAccess: &graphqlbackend.UpdateLLMProxyAccessInput{
codyGatewayAccess: &graphqlbackend.UpdateCodyGatewayAccessInput{
Enabled: pointify(false),
ChatCompletionsRateLimit: pointify(int32(0)),
ChatCompletionsRateLimitIntervalSeconds: pointify(int32(0)),

View File

@ -133,8 +133,8 @@ func (r *productSubscription) ProductLicenses(ctx context.Context, args *graphql
return &productLicenseConnection{db: r.db, opt: opt}, nil
}
func (r *productSubscription) LLMProxyAccess() graphqlbackend.LLMProxyAccess {
return llmProxyAccessResolver{sub: r}
func (r *productSubscription) CodyGatewayAccess() graphqlbackend.CodyGatewayAccess {
return codyGatewayAccessResolver{sub: r}
}
func (r *productSubscription) CurrentSourcegraphAccessToken(ctx context.Context) (*string, error) {
@ -236,7 +236,7 @@ func (r ProductSubscriptionLicensingResolver) UpdateProductSubscription(ctx cont
return nil, err
}
if err := (dbSubscriptions{db: r.DB}).Update(ctx, sub.v.ID, dbSubscriptionUpdate{
llmProxyAccess: args.Update.LLMProxyAccess,
codyGatewayAccess: args.Update.CodyGatewayAccess,
}); err != nil {
return nil, err
}

View File

@ -70,7 +70,7 @@ func GetCompletionsConfig() *schema.Completions {
Enabled: len(appConfig.DotcomAuthToken) > 0,
Provider: dotcom.ProviderName,
// TODO: These are not required right now as upstream overwrites this,
// but should we switch to LLM Proxy they will be.
// but should we switch to Cody Gateway they will be.
ChatModel: "claude-v1",
CompletionModel: "claude-instant-v1",
}

View File

@ -17,7 +17,7 @@ const (
// DevTag denotes licenses used in development environments
DevTag = "dev"
// GPTLLMAccessTag is the license tag that indicates that the licensed instance
// should be allowed by default to use GPT models in LLM Proxy.
// should be allowed by default to use GPT models in Cody Gateway.
GPTLLMAccessTag = "gpt"
// AllowAnonymousUsageTag denotes licenses that allow anonymous usage, a.k.a public access to the instance
// Warning: This should be used with care and only at special, probably trial/poc stages with customers

View File

@ -540,6 +540,16 @@ type CloudKMSEncryptionKey struct {
Type string `json:"type"`
}
// CodyGateway description: Configuration related to the Cody Gateway service management. This should only be used on sourcegraph.com.
type CodyGateway struct {
// BigQueryDataset description: The dataset to pull BigQuery Cody Gateway related events from.
BigQueryDataset string `json:"bigQueryDataset,omitempty"`
// BigQueryGoogleProjectID description: The project ID to pull BigQuery Cody Gatewayrelated events from.
BigQueryGoogleProjectID string `json:"bigQueryGoogleProjectID,omitempty"`
// BigQueryTable description: The table in the dataset to pull BigQuery Cody Gateway related events from.
BigQueryTable string `json:"bigQueryTable,omitempty"`
}
// Completions description: Configuration for the completions service.
type Completions struct {
// AccessToken description: The access token used to authenticate with the external completions provider.
@ -580,8 +590,8 @@ type DebugLog struct {
type Dotcom struct {
// AppNotifications description: Notifications to display in the Sourcegraph app.
AppNotifications []*AppNotifications `json:"app.notifications,omitempty"`
// LlmProxy description: Configuration related to the LLM Proxy service management. This should only be used on sourcegraph.com.
LlmProxy *LlmProxy `json:"llmProxy,omitempty"`
// CodyGateway description: Configuration related to the Cody Gateway service management. This should only be used on sourcegraph.com.
CodyGateway *CodyGateway `json:"codyGateway,omitempty"`
// SlackLicenseExpirationWebhook description: Slack webhook for upcoming license expiration notifications.
SlackLicenseExpirationWebhook string `json:"slackLicenseExpirationWebhook,omitempty"`
// SrcCliVersionCache description: Configuration related to the src-cli version cache. This should only be used on sourcegraph.com.
@ -1352,16 +1362,6 @@ type JVMPackagesConnection struct {
Maven Maven `json:"maven"`
}
// LlmProxy description: Configuration related to the LLM Proxy service management. This should only be used on sourcegraph.com.
type LlmProxy struct {
// BigQueryDataset description: The dataset to pull BigQuery LLM Proxy related events from.
BigQueryDataset string `json:"bigQueryDataset,omitempty"`
// BigQueryGoogleProjectID description: The project ID to pull BigQuery LLM Proxy related events from.
BigQueryGoogleProjectID string `json:"bigQueryGoogleProjectID,omitempty"`
// BigQueryTable description: The table in the dataset to pull BigQuery LLM Proxy related events from.
BigQueryTable string `json:"bigQueryTable,omitempty"`
}
// Log description: Configuration for logging and alerting, including to external services.
type Log struct {
// AuditLog description: EXPERIMENTAL: Configuration for audit logging (specially formatted log entries for tracking sensitive events)

View File

@ -1954,21 +1954,21 @@
}
}
},
"llmProxy": {
"description": "Configuration related to the LLM Proxy service management. This should only be used on sourcegraph.com.",
"codyGateway": {
"description": "Configuration related to the Cody Gateway service management. This should only be used on sourcegraph.com.",
"type": "object",
"group": "Sourcegraph.com",
"properties": {
"bigQueryGoogleProjectID": {
"description": "The project ID to pull BigQuery LLM Proxy related events from.",
"description": "The project ID to pull BigQuery Cody Gatewayrelated events from.",
"type": "string"
},
"bigQueryDataset": {
"description": "The dataset to pull BigQuery LLM Proxy related events from.",
"description": "The dataset to pull BigQuery Cody Gateway related events from.",
"type": "string"
},
"bigQueryTable": {
"description": "The table in the dataset to pull BigQuery LLM Proxy related events from.",
"description": "The table in the dataset to pull BigQuery Cody Gateway related events from.",
"type": "string"
}
}

View File

@ -1196,7 +1196,7 @@ commandsets:
EXTSVC_CONFIG_FILE: ""
dotcom:
# This is 95% the enterprise runset, with the addition of LLM-proxy.
# This is 95% the enterprise runset, with the addition of Cody Gateway.
requiresDevPrivate: true
checks:
- docker