Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom starter message configuration #963

Merged
merged 6 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/shared/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface Configuration {
telemetryLevel: 'all' | 'off'
useContext: ConfigurationUseContext
customHeaders: Record<string, string>
chatPreInstruction: string
autocomplete: boolean
experimentalChatPredictions: boolean
inlineChat: boolean
Expand Down
1 change: 1 addition & 0 deletions vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Starting from `0.2.0`, Cody is using `major.EVEN_NUMBER.patch` for release versi
- Add a UI indicator when you're not signed in. [pull/970](https://github.com/sourcegraph/cody/pull/970)
- Added a completion statistics summary to the autocomplete trace view. [pull/973](https://github.com/sourcegraph/cody/pull/973)
- Add experimental option `claude-instant-infill` to the `cody.autocomplete.advanced.model` config option that enables users using the Claude Instant model to get suggestions with context awareness (infill). [pull/974](https://github.com/sourcegraph/cody/pull/974)
- New `cody.chat.preInstruction` configuration option for adding custom message at the start of all chat messages sent to Cody. Extension reload required. [pull/963](https://github.com/sourcegraph/cody/pull/963)

### Fixed

Expand Down
8 changes: 8 additions & 0 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,14 @@
"default": false,
"markdownDescription": "Experimental feature for internal use."
},
"cody.chat.preInstruction": {
"order": 10,
"type": "string",
"markdownDescription": "An instruction to be included at the start of all chat messages sent to Cody. Extension reload required.",
"examples": [
"Answer all my questions in Spanish."
]
},
"cody.experimental.symf.path": {
"order": 99,
"type": "string",
Expand Down
4 changes: 4 additions & 0 deletions vscode/src/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('getConfiguration', () => {
serverEndpoint: DOTCOM_URL.href,
codebase: '',
customHeaders: {},
chatPreInstruction: undefined,
useContext: 'embeddings',
autocomplete: true,
experimentalCommandLenses: false,
Expand Down Expand Up @@ -84,6 +85,8 @@ describe('getConfiguration', () => {
return /.*/
case 'cody.telemetry.level':
return 'off'
case 'cody.chat.preInstruction':
return 'My name is Jeff.'
case 'cody.autocomplete.advanced.provider':
return 'unstable-codegen'
case 'cody.autocomplete.advanced.serverEndpoint':
Expand Down Expand Up @@ -115,6 +118,7 @@ describe('getConfiguration', () => {
'Cache-Control': 'no-cache',
'Proxy-Authenticate': 'Basic',
},
chatPreInstruction: 'My name is Jeff.',
autocomplete: false,
experimentalChatPredictions: true,
experimentalCommandLenses: true,
Expand Down
1 change: 1 addition & 0 deletions vscode/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function getConfiguration(config: ConfigGetter = vscode.workspace.getConf
autocomplete: config.get(CONFIG_KEY.autocompleteEnabled, true),
experimentalChatPredictions: config.get(CONFIG_KEY.experimentalChatPredictions, isTesting),
inlineChat: config.get(CONFIG_KEY.inlineChatEnabled, true),
chatPreInstruction: config.get(CONFIG_KEY.chatPreInstruction),
experimentalGuardrails: config.get(CONFIG_KEY.experimentalGuardrails, isTesting),
experimentalNonStop: config.get(CONFIG_KEY.experimentalNonStop, isTesting),
experimentalLocalSymbols: config.get(CONFIG_KEY.experimentalLocalSymbols, false),
Expand Down
5 changes: 5 additions & 0 deletions vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as vscode from 'vscode'
import { commandRegex } from '@sourcegraph/cody-shared/src/chat/recipes/helpers'
import { RecipeID } from '@sourcegraph/cody-shared/src/chat/recipes/recipe'
import { ConfigurationWithAccessToken } from '@sourcegraph/cody-shared/src/configuration'
import { newPromptMixin, PromptMixin } from '@sourcegraph/cody-shared/src/prompt/prompt-mixin'

import { ChatViewProvider } from './chat/ChatViewProvider'
import { ContextProvider } from './chat/ContextProvider'
Expand Down Expand Up @@ -94,6 +95,10 @@ const register = async (
const workspaceConfig = vscode.workspace.getConfiguration()
const config = getConfiguration(workspaceConfig)

if (config.chatPreInstruction) {
PromptMixin.addCustom(newPromptMixin(config.chatPreInstruction))
}

if (config.autocompleteExperimentalSyntacticPostProcessing) {
parseAllVisibleDocuments()

Expand Down