Skip to content

Commit

Permalink
Hitesh/1.30.1 patch release (#5148)
Browse files Browse the repository at this point in the history
VS Code v1.30.1 patch release. This is a patch release branch PR. Will
create a separate one for the main branch.
- Autocomplete: Add a feature flag for DeepSeek-coder-v2 lite base
model. [pull/5151](#5079)

## Test plan
Updated changelog and package.json.

## Changelog
Autocomplete: Add a feature flag for DeepSeek-coder-v2 lite base model.
[pull/5151](#5079)
  • Loading branch information
hitesh-1997 authored Aug 8, 2024
1 parent 2a6f77b commit 0e1e825
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 19 deletions.
2 changes: 2 additions & 0 deletions lib/shared/src/experimentation/FeatureFlagProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export enum FeatureFlag {
CodyAutocompleteStarCoder2Hybrid = 'cody-autocomplete-starcoder2-hybrid',
// Enable the FineTuned model as the default model via Fireworks
CodyAutocompleteFIMFineTunedModelHybrid = 'cody-autocomplete-fim-fine-tuned-model-hybrid',
// Enable the deepseek-v2 as the default model via Fireworks
CodyAutocompleteDeepseekV2LiteBase = 'cody-autocomplete-deepseek-v2-lite-base',

// Enable various feature flags to experiment with FIM trained fine-tuned models via Fireworks
CodyAutocompleteFIMModelExperimentBaseFeatureFlag = 'cody-autocomplete-fim-model-experiment-flag',
Expand Down
12 changes: 12 additions & 0 deletions vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ This is a log of all notable changes to Cody for VS Code. [Unreleased] changes a

### Changed


## 1.30.1

### Added

Autocomplete: Add a feature flag for DeepSeek-coder-v2 lite base model. [pull/5151](https://github.com/sourcegraph/cody/pull/5079)

### Fixed

### Changed


## 1.30.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "cody-ai",
"private": true,
"displayName": "Cody: AI Coding Assistant with Autocomplete & Chat",
"version": "1.30.0",
"version": "1.30.1",
"publisher": "sourcegraph",
"license": "Apache-2.0",
"icon": "resources/cody.png",
Expand Down
17 changes: 12 additions & 5 deletions vscode/src/completions/providers/create-provider.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { describe, expect, it } from 'vitest'

import {
type AuthStatus,
type CodeCompletionsClient,
Expand All @@ -10,7 +8,9 @@ import {
defaultAuthStatus,
graphqlClient,
} from '@sourcegraph/cody-shared'

import { beforeAll, describe, expect, it } from 'vitest'
import type * as vscode from 'vscode'
import { localStorage } from '../../services/LocalStorageProvider'
import { DEFAULT_VSCODE_SETTINGS } from '../../testutils/mocks'

import { createProviderConfig } from './create-provider'
Expand Down Expand Up @@ -53,6 +53,13 @@ describe('createProviderConfig', () => {
})

describe('if completions provider field is not defined in VSCode settings', () => {
beforeAll(async () => {
localStorage.setStorage({
get: () => null,
update: () => {},
} as any as vscode.Memento)
})

it('returns "anthropic" if completions provider is not configured', async () => {
const provider = await createProviderConfig(
getVSCodeConfigurationWithAccessToken({
Expand Down Expand Up @@ -85,7 +92,7 @@ describe('createProviderConfig', () => {
dummyAuthStatus
)
expect(provider?.identifier).toBe('fireworks')
expect(provider?.model).toBe('starcoder-hybrid')
expect(provider?.model).toBe('deepseek-coder-v2-lite-base')
})

it('returns "experimental-openaicompatible" provider config and corresponding model if specified', async () => {
Expand Down Expand Up @@ -241,7 +248,7 @@ describe('createProviderConfig', () => {
},
{
codyLLMConfig: { provider: 'fireworks' },
expected: { provider: 'fireworks', model: 'starcoder-hybrid' },
expected: { provider: 'fireworks', model: 'deepseek-coder-v2-lite-base' },
},

// unknown-provider
Expand Down
40 changes: 29 additions & 11 deletions vscode/src/completions/providers/create-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {

import * as vscode from 'vscode'
import { logError } from '../../log'
import { localStorage } from '../../services/LocalStorageProvider'
import {
type AnthropicOptions,
DEFAULT_PLG_ANTHROPIC_MODEL,
Expand Down Expand Up @@ -48,12 +49,14 @@ export async function createProviderConfigFromVSCodeConfig(
})
}
case 'fireworks': {
const { anonymousUserID } = await localStorage.anonymousUserID()
return createFireworksProviderConfig({
client,
model: config.autocompleteAdvancedModel ?? model ?? null,
timeouts: config.autocompleteTimeouts,
authStatus,
config,
anonymousUserID,
})
}
case 'anthropic': {
Expand Down Expand Up @@ -98,6 +101,7 @@ export async function createProviderConfig(
/**
* Look for the autocomplete provider in VSCode settings and return matching provider config.
*/

const providerAndModelFromVSCodeConfig = await resolveDefaultModelFromVSCodeConfigOrFeatureFlags(
config.autocompleteAdvancedProvider,
authStatus.isDotCom
Expand Down Expand Up @@ -133,14 +137,17 @@ export async function createProviderConfig(
model: provider === 'azure-openai' && modelId ? '' : modelId,
})

case 'fireworks':
case 'fireworks': {
const { anonymousUserID } = await localStorage.anonymousUserID()
return createFireworksProviderConfig({
client,
timeouts: config.autocompleteTimeouts,
model: modelId ?? null,
authStatus,
config,
anonymousUserID,
})
}
case 'experimental-openaicompatible':
// TODO(slimsag): self-hosted-models: deprecate and remove this once customers are upgraded
// to non-experimental version
Expand Down Expand Up @@ -251,16 +258,23 @@ async function resolveDefaultModelFromVSCodeConfigOrFeatureFlags(
return { provider: configuredProvider }
}

const [starCoder2Hybrid, starCoderHybrid, claude3, finetunedFIMModelHybrid, fimModelExperimentFlag] =
await Promise.all([
featureFlagProvider.evaluateFeatureFlag(FeatureFlag.CodyAutocompleteStarCoder2Hybrid),
featureFlagProvider.evaluateFeatureFlag(FeatureFlag.CodyAutocompleteStarCoderHybrid),
featureFlagProvider.evaluateFeatureFlag(FeatureFlag.CodyAutocompleteClaude3),
featureFlagProvider.evaluateFeatureFlag(FeatureFlag.CodyAutocompleteFIMFineTunedModelHybrid),
featureFlagProvider.evaluateFeatureFlag(
FeatureFlag.CodyAutocompleteFIMModelExperimentBaseFeatureFlag
),
])
const [
starCoder2Hybrid,
starCoderHybrid,
claude3,
finetunedFIMModelHybrid,
fimModelExperimentFlag,
deepseekV2LiteBase,
] = await Promise.all([
featureFlagProvider.evaluateFeatureFlag(FeatureFlag.CodyAutocompleteStarCoder2Hybrid),
featureFlagProvider.evaluateFeatureFlag(FeatureFlag.CodyAutocompleteStarCoderHybrid),
featureFlagProvider.evaluateFeatureFlag(FeatureFlag.CodyAutocompleteClaude3),
featureFlagProvider.evaluateFeatureFlag(FeatureFlag.CodyAutocompleteFIMFineTunedModelHybrid),
featureFlagProvider.evaluateFeatureFlag(
FeatureFlag.CodyAutocompleteFIMModelExperimentBaseFeatureFlag
),
featureFlagProvider.evaluateFeatureFlag(FeatureFlag.CodyAutocompleteDeepseekV2LiteBase),
])

// We run fine tuning experiment for VSC client only.
// We disable for all agent clients like the JetBrains plugin.
Expand All @@ -273,6 +287,10 @@ async function resolveDefaultModelFromVSCodeConfigOrFeatureFlags(
return resolveFIMModelExperimentFromFeatureFlags()
}

if (isDotCom && deepseekV2LiteBase) {
return { provider: 'fireworks', model: DEEPSEEK_CODER_V2_LITE_BASE }
}

if (finetunedFIMModelHybrid) {
return { provider: 'fireworks', model: FIREWORKS_FIM_FINE_TUNED_MODEL_HYBRID }
}
Expand Down
18 changes: 16 additions & 2 deletions vscode/src/completions/providers/fireworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface FireworksOptions {
model: FireworksModel
maxContextTokens?: number
client: CodeCompletionsClient
anonymousUserID?: string
timeouts: AutocompleteTimeouts
config: Pick<
ConfigurationWithAccessToken,
Expand Down Expand Up @@ -182,10 +183,19 @@ class FireworksProvider extends Provider {
// Todo: This variable is used to introduce an additional delay to collect the data on impact of latency on user experience.
// Todo: Delete this variable once the data is collected.
private shouldAddArtificialDelayForExperiment = false
private anonymousUserID: string | undefined

constructor(
options: ProviderOptions,
{ model, maxContextTokens, client, timeouts, config, authStatus }: Required<FireworksOptions>
{
model,
maxContextTokens,
client,
timeouts,
config,
authStatus,
anonymousUserID,
}: Required<Omit<FireworksOptions, 'anonymousUserID'>> & { anonymousUserID?: string }
) {
super(options)
this.timeouts = timeouts
Expand All @@ -197,6 +207,7 @@ class FireworksProvider extends Provider {
this.promptChars = tokensToChars(maxContextTokens - MAX_RESPONSE_TOKENS)
this.client = client
this.authStatus = authStatus
this.anonymousUserID = anonymousUserID
this.isLocalInstance = Boolean(
this.authStatus.endpoint?.includes('sourcegraph.test') ||
this.authStatus.endpoint?.includes('localhost')
Expand Down Expand Up @@ -537,6 +548,7 @@ class FireworksProvider extends Provider {
],
stream: true,
languageId: self.options.document.languageId,
anonymousUserID: self.anonymousUserID,
}

const headers = new Headers(self.getCustomHeaders())
Expand Down Expand Up @@ -722,7 +734,9 @@ export function createProviderConfig({
}): ProviderConfig {
const clientModel =
model === null || model === ''
? 'starcoder-hybrid'
? otherOptions.authStatus.isDotCom
? DEEPSEEK_CODER_V2_LITE_BASE
: 'starcoder-hybrid'
: ['starcoder-hybrid', 'starcoder2-hybrid'].includes(model)
? (model as FireworksModel)
: Object.prototype.hasOwnProperty.call(MODEL_MAP, model)
Expand Down

0 comments on commit 0e1e825

Please sign in to comment.