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

Deep Cody: skip query rewrite for search tool #6082

Merged
merged 2 commits into from
Nov 7, 2024
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
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
Comment on lines 183 to +188
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability, let's use an object instead of an argument list here. Otherwise, it's unclear what undefined, true means without looking into the implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I just read this after merging on my phone 😓 will do it in a follow up and tag you!

)
// 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
Loading