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

chore: Remove hard-coded 'deep-cody' and replace with constant #6958

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions vscode/src/chat/agentic/CodyToolProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { ContextRetriever } from '../chat-view/ContextRetriever'
import { CodyTool, type CodyToolConfig } from './CodyTool'
import { CodyToolProvider, TestToolFactory, type ToolConfiguration } from './CodyToolProvider'
import { toolboxManager } from './ToolboxManager'
import { DeepCodyAgent } from './DeepCody'

const localStorageData: { [key: string]: unknown } = {}
mockLocalStorage({
Expand Down Expand Up @@ -91,7 +92,7 @@ describe('CodyToolProvider', () => {

it('should not include CLI tool if shell is disabled', () => {
vi.spyOn(toolboxManager, 'getSettings').mockReturnValue({
agent: { name: 'deep-cody' },
agent: { name: DeepCodyAgent.id },
shell: { enabled: false },
})
const tools = CodyToolProvider.getTools()
Expand All @@ -100,7 +101,7 @@ describe('CodyToolProvider', () => {

it('should include CLI tool if shell is enabled', () => {
vi.spyOn(toolboxManager, 'getSettings').mockReturnValue({
agent: { name: 'deep-cody' },
agent: { name: DeepCodyAgent.id },
shell: { enabled: true },
})
const tools = CodyToolProvider.getTools()
Expand Down
2 changes: 1 addition & 1 deletion vscode/src/chat/agentic/DeepCody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class DeepCodyAgent {
requestID,
model: DeepCodyAgent.model,
traceId: span.spanContext().traceId,
chatAgent: 'deep-cody',
chatAgent: DeepCodyAgent.id,
},
metadata: {
loop: this.stats.loop, // Number of loops run.
Expand Down
2 changes: 1 addition & 1 deletion vscode/src/chat/agentic/ToolboxManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ToolboxManager {
const shellError = this.getFeatureError('shell')
// TODO: Remove hard-coded agent once we have a proper agentic chat selection UI
return {
agent: { name: this.isRateLimited ? undefined : 'deep-cody' },
agent: { name: this.isRateLimited ? undefined : DeepCodyAgent.id },
shell: {
enabled: shellError === undefined,
error: shellError,
Expand Down
5 changes: 3 additions & 2 deletions vscode/src/chat/chat-view/ChatController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import { getChatPanelTitle } from './chat-helpers'
import { OmniboxTelemetry } from './handlers/OmniboxTelemetry'
import { getAgent } from './handlers/registry'
import { getPromptsMigrationInfo, startPromptsMigration } from './prompts-migration'
import { DeepCodyAgent } from '../agentic/DeepCody'

export interface ChatControllerOptions {
extensionUri: vscode.Uri
Expand Down Expand Up @@ -667,7 +668,7 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv
firstResultFromOperation(ChatBuilder.resolvedModelForChat(this.chatBuilder))
)
this.chatBuilder.setSelectedModel(model)
const selectedAgent = model?.includes('deep-cody') ? 'deep-cody' : undefined
const selectedAgent = model?.includes(DeepCodyAgent.id) ? DeepCodyAgent.id : undefined

this.chatBuilder.addHumanMessage({
text: inputText,
Expand Down Expand Up @@ -792,7 +793,7 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv
}

this.chatBuilder.setSelectedModel(model)
const chatAgent = model.includes('deep-cody') ? 'deep-cody' : undefined
const chatAgent = model.includes(DeepCodyAgent.id) ? DeepCodyAgent.id : undefined

const recorder = await OmniboxTelemetry.create({
requestID,
Expand Down
3 changes: 2 additions & 1 deletion vscode/webviews/chat/Transcript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import ApprovalCell from './cells/agenticCell/ApprovalCell'
import { DidYouMeanNotice } from './cells/messageCell/assistant/DidYouMean'
import { SwitchIntent } from './cells/messageCell/assistant/SwitchIntent'
import { LastEditorContext } from './context'
import { DeepCodyAgent } from '../../src/chat/agentic/DeepCody'

interface TranscriptProps {
activeChatContext?: Context
Expand Down Expand Up @@ -759,7 +760,7 @@ const TranscriptInteraction: FC<TranscriptInteractionProps> = memo(props => {
? EditContextButtonSearch
: EditContextButtonChat
}
defaultOpen={isContextLoading && humanMessage.agent === 'deep-cody'}
defaultOpen={isContextLoading && humanMessage.agent === DeepCodyAgent.id}
processes={humanMessage?.processes ?? undefined}
agent={humanMessage?.agent ?? undefined}
/>
Expand Down
3 changes: 2 additions & 1 deletion vscode/webviews/chat/cells/contextCell/ContextCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { LoadingDots } from '../../components/LoadingDots'
import { Cell } from '../Cell'
import { NON_HUMAN_CELL_AVATAR_SIZE } from '../messageCell/assistant/AssistantMessageCell'
import styles from './ContextCell.module.css'
import { DeepCodyAgent } from '../../../../src/chat/agentic/DeepCody'

export const __ContextCellStorybookContext = createContext<{ initialOpen: boolean } | null>(null)

Expand Down Expand Up @@ -133,7 +134,7 @@ export const ContextCell: FunctionComponent<{

const telemetryRecorder = useTelemetryRecorder()

const isAgenticChat = model?.includes('deep-cody') || agent === 'deep-cody'
const isAgenticChat = model?.includes(DeepCodyAgent.id) || agent === DeepCodyAgent.id

// Text for top header text
const headerText: { main: string; sub?: string } = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { BaseMessageCell, MESSAGE_CELL_AVATAR_SIZE } from '../BaseMessageCell'
import { ContextFocusActions } from './ContextFocusActions'
import { SearchResults } from './SearchResults'
import { SubMessageCell } from './SubMessageCell'
import { DeepCodyAgent } from '../../../../../src/chat/agentic/DeepCody'

/**
* A component that displays a chat message from the assistant.
Expand Down Expand Up @@ -103,7 +104,7 @@ export const AssistantMessageCell: FunctionComponent<{
isSearchIntent ? undefined : (
<span data-testid="chat-model">
{chatModel
? chatModel.id.includes('deep-cody')
? chatModel.id.includes(DeepCodyAgent.id)
? 'Claude 3.5 Sonnet (New)'
: chatModel.title ?? `Model ${chatModel.id} by ${chatModel.provider}`
: 'Model'}
Expand Down Expand Up @@ -284,7 +285,7 @@ function useChatModelByID(
(model
? {
id: model,
title: model?.includes('deep-cody') ? 'Deep Cody (Experimental)' : model,
title: model?.includes(DeepCodyAgent.id) ? 'Deep Cody (Experimental)' : model,
provider: 'unknown',
tags: [],
}
Expand Down
3 changes: 2 additions & 1 deletion vscode/webviews/components/ChatModelIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
OllamaLogo,
OpenAILogo,
} from '../icons/LLMProviderIcons'
import { DeepCodyAgent } from '../../src/chat/agentic/DeepCody'

export function chatModelIconComponent(
model: string
Expand All @@ -15,7 +16,7 @@ export function chatModelIconComponent(
if (model.startsWith('openai') || model.includes('gpt')) {
return OpenAILogo
}
if (model.includes('anthropic') || model.includes('deep-cody')) {
if (model.includes('anthropic') || model.includes(DeepCodyAgent.id)) {
return AnthropicLogo
}
if (model.startsWith('google') || model.includes('gemini')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { VSCodeStandaloneComponent } from '../../storybook/VSCodeStoryDecorator'
import { type Model, ModelTag, ModelUsage, getMockedDotComClientModels } from '@sourcegraph/cody-shared'
import { useArgs } from '@storybook/preview-api'
import { ModelSelectField } from './ModelSelectField'
import { DeepCodyAgent } from '../../../src/chat/agentic/DeepCody'
mrnugget marked this conversation as resolved.
Show resolved Hide resolved

const MODELS: Model[] = [
...getMockedDotComClientModels(),
Expand All @@ -19,7 +20,7 @@ const MODELS: Model[] = [
{
title: 'Deep Cody',
provider: 'sourcegraph',
id: 'deep-cody',
id: DeepCodyAgent.id,
contextWindow: { input: 100, output: 100 },
usage: [ModelUsage.Chat],
tags: [ModelTag.Pro, ModelTag.Experimental],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { type Model, ModelTag, isCodyProModel, isWaitlistModel } from '@sourcegr
import { clsx } from 'clsx'
import { BookOpenIcon, BrainIcon, BuildingIcon, ExternalLinkIcon } from 'lucide-react'
import { type FunctionComponent, type ReactNode, useCallback, useMemo } from 'react'
import { DeepCodyAgent } from '../../../src/chat/agentic/DeepCody'
import type { UserAccountInfo } from '../../Chat'
import { getVSCodeAPI } from '../../utils/VSCodeApi'
import { useTelemetryRecorder } from '../../utils/telemetry'
Expand Down Expand Up @@ -303,7 +304,7 @@ function modelAvailability(
}

function getTooltip(model: Model, availability: string): string {
if (model.id.includes('deep-cody')) {
if (model.id.includes(DeepCodyAgent.id)) {
return 'Agentic chat reflects on your request and uses tools to dynamically retrieve relevant context, improving accuracy and response quality.'
}

Expand Down Expand Up @@ -358,7 +359,7 @@ const ModelTitleWithIcon: React.FC<{
return (
<span className={clsx(styles.modelTitleWithIcon, { [styles.disabled]: isDisabled })}>
{showIcon ? (
model.id.includes('deep-cody') ? (
model.id.includes(DeepCodyAgent.id) ? (
<BrainIcon size={16} className={styles.modelIcon} />
) : (
<ChatModelIcon model={model.provider} className={styles.modelIcon} />
Expand Down Expand Up @@ -398,7 +399,7 @@ const ModelUIGroup: Record<string, string> = {
}

const getModelDropDownUIGroup = (model: Model): string => {
if (['deep-cody', 'tool-cody'].some(id => model.id.includes(id))) return ModelUIGroup.Agents
if ([DeepCodyAgent.id, 'tool-cody'].some(id => model.id.includes(id))) return ModelUIGroup.Agents
if (model.tags.includes(ModelTag.Power)) return ModelUIGroup.Power
if (model.tags.includes(ModelTag.Balanced)) return ModelUIGroup.Balanced
if (model.tags.includes(ModelTag.Speed)) return ModelUIGroup.Speed
Expand Down
Loading