Skip to content

Commit

Permalink
update copies by aravind(${process.content})
Browse files Browse the repository at this point in the history
  • Loading branch information
abeatrix committed Jan 15, 2025
1 parent d754ee0 commit 4a74f9d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 39 deletions.
38 changes: 18 additions & 20 deletions vscode/src/chat/agentic/DeepCody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,13 @@ export class DeepCodyAgent {
* Register the tools with the multiplexer.
*/
protected initializeMultiplexer(tools: CodyTool[]): void {
const calledTools = new Set<string>()
for (const tool of tools) {
const { tags, title } = tool.config
const { tags } = tool.config
this.multiplexer.sub(tags.tag.toString(), {
onResponse: async (content: string) => {
tool.stream(content)
if (!calledTools.has(title)) {
calledTools.add(title)
const toolCount = calledTools.size
const suffix = toolCount > 1 ? 'tools' : 'tool'
this.statusCallback.onStream({
title: `Retrieving context from ${toolCount} ${suffix}`,
})
}
},
onTurnComplete: async () => calledTools.clear(),
onTurnComplete: async () => {},
})
}
}
Expand Down Expand Up @@ -197,9 +188,8 @@ export class DeepCodyAgent {
span.addEvent('reviewLoop')
for (let i = 0; i < maxLoops && !chatAbortSignal.aborted; i++) {
this.stats.loop++
const step = this.stepsManager.addStep({ title: 'Agentic context reflection' })
const step = this.stepsManager.addStep({ title: 'Reflecting' })
const newContext = await this.review(requestID, span, chatAbortSignal)
this.statusCallback.onUpdate(step.id, ` (${newContext.length} context fetched)`)
this.statusCallback.onComplete(step.id)
if (!newContext.length) break
// Filter and add new context items in one pass
Expand Down Expand Up @@ -235,6 +225,9 @@ export class DeepCodyAgent {
if (!res || isReadyToAnswer(res)) {
return []
}

const step = this.stepsManager.addStep({ title: 'Retrieving additional context' })

const results = await Promise.all(
this.tools.map(async tool => {
try {
Expand All @@ -254,6 +247,12 @@ export class DeepCodyAgent {
})
)

const newContext = results.flat().filter(isDefined)
if (newContext.length > 0) {
this.stats.context = this.stats.context + newContext.length
this.statusCallback.onUpdate(step.id, `fetched ${toPlural(newContext.length, 'item')}`)
}

const reviewed = []
const currentContext = [
...this.context,
Expand Down Expand Up @@ -281,18 +280,16 @@ export class DeepCodyAgent {
// items are not removed from the updated context list. We will let the prompt builder
// at the final stage to do the unique context check.
if (reviewed.length > 0) {
this.statusCallback.onStream({
title: 'Optimizing context',
content: `selected ${toPlural(reviewed.length, 'item')}`,
})
const userAdded = this.context.filter(c => isUserAddedItem(c))
reviewed.push(...userAdded)
this.context = reviewed
this.statusCallback.onStream({
title: 'Filtering',
content: `selected ${contextNames.length} context`,
})
}

const newContextFetched = results.flat().filter(isDefined)
this.stats.context = this.stats.context + newContextFetched.length
return newContextFetched
return newContext
} catch (error) {
await this.multiplexer.notifyTurnComplete()
logDebug('Deep Cody', `context review failed: ${error}`, { verbose: { prompt, error } })
Expand Down Expand Up @@ -389,3 +386,4 @@ export class RawTextProcessor {
const answerTag = ACTIONS_TAGS.ANSWER.toString()
const contextTag = ACTIONS_TAGS.CONTEXT.toString()
const isReadyToAnswer = (text: string) => text === `<${answerTag}>`
const toPlural = (num: number, text: string) => `${num} ${text}${num > 1 ? 's' : ''}`
24 changes: 12 additions & 12 deletions vscode/webviews/chat/cells/agenticCell/AgenticContextCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { NON_HUMAN_CELL_AVATAR_SIZE } from '../messageCell/assistant/AssistantMe

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

const CELL_NAME = 'agentic-context-items'
const CELL_NAME = 'agentic-chat-items'
/**
* A component displaying the agentic chat status.
*/
Expand All @@ -29,11 +29,13 @@ export const AgenticContextCell: FunctionComponent<{
})
}, [])

const subHeader = !isContextLoading
? 'reviewed'
const hasError = processes?.some(p => p.error)
const status = !isContextLoading
? hasError
? 'failed'
: 'completed'
: processes?.findLast(p => p.type !== 'tool' && p.type !== 'confirmation')?.title || 'reviewing'

const statusClassName = processes?.some(p => p.error) ? 'tw-text-yellow-500' : 'tw-text-green-500'
const statusClassName = hasError ? 'tw-text-yellow-500' : 'tw-text-green-500'

return (
<div>
Expand All @@ -49,7 +51,7 @@ export const AgenticContextCell: FunctionComponent<{
header={
<AccordionTrigger
onClick={() => triggerAccordion()}
title="Agentic context"
title="Agentic chat"
className="tw-flex tw-items-center tw-gap-4"
disabled={!processes?.some(p => p.id)}
>
Expand All @@ -65,9 +67,9 @@ export const AgenticContextCell: FunctionComponent<{
/>
)}
<span className="tw-flex tw-items-baseline">
Agentic context
Agentic chat
<span className="tw-opacity-60 tw-text-sm tw-ml-2">
&mdash; {subHeader.toLowerCase()}
&mdash; {status.toLowerCase()}
</span>
</span>
</AccordionTrigger>
Expand Down Expand Up @@ -137,11 +139,9 @@ const ProcessItem: FC<{
{process.content && (
<span
className="tw-ml-2 tw-truncate tw-max-w-full tw-text-xs tw-muted-foreground tw-opacity-60"
title={
process.type === 'tool' ? 'agentic query' : process.title ?? process.id
}
title={process.type === 'tool' ? 'agentic chat query' : process.content}
>
{process.type === 'tool' ? `(${process.content})` : process.content}
({process.content})
</span>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion vscode/webviews/chat/cells/agenticCell/ApprovalCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const ApprovalCell: FC<{ vscodeAPI: VSCodeWrapper }> = ({ vscodeAPI }) => {
className="tw-w-1/4"
onClick={() => handleClick(a.id, true)}
>
Run
Allow
</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface ToolboxButtonProps {

/**
* A button component that provides a UI for managing agent context settings.
* Displays a popover with toggles for agentic context and terminal access.
* Displays a popover with toggles for agentic chat and terminal access.
* Includes experimental features with appropriate warnings and documentation links.
*
* @param settings - The current agent toolbox settings
Expand Down Expand Up @@ -96,7 +96,7 @@ export const ToolboxButton: FC<ToolboxButtonProps> = memo(({ settings, api, isFi
title="Agentic Chat Context"
>
<span className="tw-flex tw-gap-2 tw-items-center">
<span className="tw-font-semibold tw-text-md">Agentic context</span>
<span className="tw-font-semibold tw-text-md">Agentic chat</span>
<Badge variant="secondary" className="tw-text-xs">
Experimental
</Badge>
Expand All @@ -121,9 +121,9 @@ export const ToolboxButton: FC<ToolboxButtonProps> = memo(({ settings, api, isFi
>
<div className="tw-text-xs">
<span>
Agentic context can search your codebase, browse the web, execute
shell commands (when enabled), and utilize configured tools to
retrieve necessary context.
Agentic chat optimizes the context fetched by reflecting and
utilizing configured tools to retrieve necessary context and improve
responses.
{/* TODO: Uncomment this when the docs is available */}
{/* <a href={AGENTIC_CONTEXT_DOCS}>Read the docs</a> to learn more. */}
</span>
Expand Down Expand Up @@ -198,7 +198,7 @@ export const ToolboxButton: FC<ToolboxButtonProps> = memo(({ settings, api, isFi
className="tw-w-8 tw-h-8 tw-text-muted-foreground"
/>
)}
{isFirstMessage && <span className="tw-font-semibold">agentic context</span>}
{isFirstMessage && <span className="tw-font-semibold">agentic chat</span>}
</Button>
</ToolbarPopoverItem>
</div>
Expand Down

0 comments on commit 4a74f9d

Please sign in to comment.