Skip to content

Commit

Permalink
Deep Cody: skip query rewrite for search tool (#6082)
Browse files Browse the repository at this point in the history
  • Loading branch information
abeatrix authored Nov 7, 2024
1 parent 6ccbb36 commit bc8b14e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
4 changes: 3 additions & 1 deletion vscode/src/chat/agentic/CodyTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ class SearchTool extends CodyTool {
const context = await this.contextRetriever.retrieveContext(
toStructuredMentions([repo]),
PromptString.unsafe_fromLLMResponse(query),
span
span,
undefined,
true
)
// Store the search query to avoid running the same query again.
this.performedSearch.add(query)
Expand Down
6 changes: 1 addition & 5 deletions vscode/src/chat/agentic/DeepCody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
PromptString,
isDefined,
logDebug,
modelsService,
ps,
telemetryRecorder,
} from '@sourcegraph/cody-shared'
Expand Down Expand Up @@ -45,10 +44,7 @@ export class DeepCodyAgent extends CodyChatAgent {
chatAbortSignal: AbortSignal,
maxLoops = 2
): Promise<ContextItem[]> {
const fastChatModel = modelsService.getModelByID(
'anthropic::2024-10-22::claude-3-5-haiku-latest'
)
this.models.review = fastChatModel?.id ?? this.chatBuilder.selectedModel
this.models.review = this.chatBuilder.selectedModel

const startTime = performance.now()
const count = await this.reviewLoop(span, chatAbortSignal, maxLoops)
Expand Down
4 changes: 3 additions & 1 deletion vscode/src/chat/agentic/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ In this environment you have access to this set of tools you can use to fetch co
4. The user is working in the VS Code editor on ${getOSPromptString()}.
[GOAL]
Determine if you can answer the question with the given context, or if you need more information. The output will be processed by a bot to gather the necessary context for the user's question, so skip answering the question directly or comments.`
- Determine if you can answer the question with the given context, or if you need more information.
- Do not provide the actual answer or comments in this step. This is an auto-generated message.
- Your response should only contains the word "CONTEXT_SUFFICIENT" or the appropriate <TOOL*> tag(s) and nothing else.`

export const CODYAGENT_PROMPTS = {
review: REVIEW_PROMPT,
Expand Down
18 changes: 14 additions & 4 deletions vscode/src/chat/chat-view/ContextRetriever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,32 @@ export class ContextRetriever implements vscode.Disposable {
mentions: StructuredMentions,
inputTextWithoutContextChips: PromptString,
span: Span,
signal?: AbortSignal
signal?: AbortSignal,
skipQueryRewrite = false
): Promise<ContextItem[]> {
const roots = await codebaseRootsFromMentions(mentions, signal)
return await this._retrieveContext(roots, inputTextWithoutContextChips, span, signal)
return await this._retrieveContext(
roots,
inputTextWithoutContextChips,
span,
signal,
skipQueryRewrite
)
}

private async _retrieveContext(
roots: Root[],
query: PromptString,
span: Span,
signal?: AbortSignal
signal?: AbortSignal,
skipQueryRewrite = false
): Promise<ContextItem[]> {
if (roots.length === 0) {
return []
}
const rewritten = await rewriteKeywordQuery(this.llms, query, signal)
const rewritten = skipQueryRewrite
? query.toString()
: await rewriteKeywordQuery(this.llms, query, signal)
const rewrittenQuery = {
...query,
rewritten,
Expand Down

0 comments on commit bc8b14e

Please sign in to comment.