Skip to content

Commit 3cb49e1

Browse files
committed
Improves model steering for better search queries
1 parent fbd1ad2 commit 3cb49e1

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

src/plus/ai/aiProviderService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ export class AIProviderService implements Disposable {
955955
model,
956956
{
957957
query: search.query,
958+
date: new Date().toISOString().split('T')[0],
958959
context: search.context,
959960
instructions: configuration.get('ai.generateSearchQuery.customInstructions'),
960961
},

src/plus/ai/models/promptTemplates.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ interface RebasePromptTemplateContext {
4444

4545
interface SearchQueryPromptTemplateContext {
4646
query: string;
47+
date: string;
4748
context?: string;
4849
instructions?: string;
4950
}

src/plus/ai/prompts.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ Based on the provided commit messages and associated issues, create a set of mar
340340
};
341341

342342
export const generateSearchQuery: PromptTemplate<'generate-searchQuery'> = {
343-
id: 'generate-searchQuery',
344-
variables: ['query', 'context', 'instructions'],
343+
id: 'generate-searchQuery_v2',
344+
variables: ['query', 'date', 'context', 'instructions'],
345345
template: `You are an advanced AI assistant that converts natural language queries into structured Git search operators. Your task is to analyze a user's natural language query about their Git repository history and convert it into the appropriate search operators.
346346
347347
Available search operators:
@@ -351,26 +351,23 @@ Available search operators:
351351
- 'file:' - Search by file path (e.g. 'file:"package.json"', 'file:"*.ts"'); maps to \`git log -- <value>\`
352352
- 'change:' - Search by specific code changes using regular expressions (e.g. 'change:"function.*auth"', 'change:"import.*react"'); maps to \`git log -G<value>\`
353353
- 'type:' - Search by type -- only stash is currently supported (e.g. 'type:stash')
354-
- 'after:' - Search for commits after a certain date or range (e.g. 'after:2023-01-01', 'after:"6 months ago"'); maps to \`git log --since=<value>\`
355-
- 'before:' - Search for commits before a certain date or range (e.g. 'before:2023-01-01', 'before:"6 months ago"'); maps to \`git log --until=<value>\`
354+
- 'after:' - Search for commits after a certain date or range (e.g. 'after:2023-01-01', 'after:"6 months ago"', 'after:"last Tuesday"', 'after:"noon"', 'after:"1 month 2 days ago"'); maps to \`git log --since=<value>\`
355+
- 'before:' - Search for commits before a certain date or range (e.g. 'before:2023-01-01', 'before:"6 months ago"', 'before:"yesterday"', 'before:"3PM GMT"'); maps to \`git log --until=<value>\`
356356
357-
File and change values should be double-quoted. Time-based searches should be converted to appropriate after or before operators. You can use multiple message, author, file, and change operators at the same time if needed.
357+
File and change values should be double-quoted. You can use multiple message, author, file, and change operators at the same time if needed.
358358
359-
Examples:
360-
- 'Show me all commits from the last six months that touched the authentication system' → 'message:"auth" file:"*auth*" after:"6 months ago"'
361-
- 'Find commits by John from last week' → 'author:"john" after:"1 week ago"'
362-
- 'Show me all commits that modified package.json in the last month' → 'file:"package.json" after:"1 month ago"'
363-
- 'Find my recent commits about fixing bugs' → 'author:"@me" message:"fix" message:"bug" after:"2 weeks ago"'
364-
- 'Show commits that added React imports' → 'change:"import.*react"'
365-
- 'Find the PR where react-query dependency was first introduced' → 'change:"react-query" file:"package.json"'
366-
367-
User Query: \${query}
359+
Temporal queries should be converted to appropriate after and/or before operators, leveraging Git's powerful 'approxidate' parser, which understands a wide array of human-centric relative date expressions, including simple terms ("yesterday", "5 minutes ago"), combinations of time units ("1 month 2 days ago"), days of the week ("last Tuesday"), named times ("noon"), and explicit timezones ("3PM GMT").
360+
For specific temporal ranges, e.g. commits made last week, or commits in the last month, use the 'after:' and 'before:' operators with appropriate relative values or calculate absolute dates, using the current date provided below.
361+
For ambiguous time periods like "this week" or "this month", prefer simple relative expressions like "1 week ago" or absolute dates using the current date provided below.
368362
363+
The current date is \${date}
369364
\${context}
370365
366+
User Query: \${query}
367+
371368
\${instructions}
372369
373-
Convert the user's natural language query into the appropriate search operators. Return only the search query string without any explanatory text. If the query cannot be converted to search operators, return the original query as a message search.`,
370+
Convert the user's natural language query into the appropriate search operators. Return only the search query string without any explanatory text. If the query cannot be converted to search operators, return the original query as a message search. For complex temporal expressions that might be ambiguous, prefer simpler, more reliable relative date formats.`,
374371
};
375372

376373
export const generateRebase: PromptTemplate<'generate-rebase'> = {

0 commit comments

Comments
 (0)