-
Notifications
You must be signed in to change notification settings - Fork 62
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
feat(participant): route generic prompt by intent and update generic prompt VSCODE-572 #830
Changes from all commits
6edcdd9
ceb8a01
314ae29
617bbb3
af64f9a
9e835b4
d805bcb
1fde75c
2d1a5d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import type { PromptArgsBase } from './promptBase'; | ||
import { PromptBase } from './promptBase'; | ||
|
||
export type PromptIntent = 'Query' | 'Schema' | 'Docs' | 'Default'; | ||
|
||
export class IntentPrompt extends PromptBase<PromptArgsBase> { | ||
protected getAssistantPrompt(): string { | ||
return `You are a MongoDB expert. | ||
Your task is to help guide a conversation with a user to the correct handler. | ||
You will be provided a conversation and your task is to determine the intent of the user. | ||
The intent handlers are: | ||
- Query | ||
- Schema | ||
- Docs | ||
- Default | ||
Rules: | ||
1. Respond only with the intent handler. | ||
2. Use the "Query" intent handler when the user is asking for code that relates to a specific collection. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the user has not specified a namespace? We don't have information about a specific collection, but it still can be a query generation request. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good question, and raises a tradeoff we have to take. Some users may ask a question that would result in code for a database, like how can I create a user with specific database permissions or what's the size of X database. In that case the /query handler would be forcing them to choose a collection which doesn't really make sense. I was aiming to make this prompt fairly intentionally selective so we don't restrict the user capabilities. The generic prompt has a lot of the capabilities of the /query resolver. |
||
3. Use the "Docs" intent handler when the user is asking a question that involves MongoDB documentation. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you try this out? I am wondering how the model interprets this instruction. Should users explicitly say find in the documentation? Or they can just ask "How to..." questions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The model did successfully route a fairly docs related question to the docs handler in my manual testing. Haven't been that extensive to give a good answer on when it does and when it doesn't. We'd need more accuracy tests. |
||
4. Use the "Schema" intent handler when the user is asking for the schema or shape of documents of a specific collection. | ||
5. Use the "Default" intent handler when a user is asking for code that does NOT relate to a specific collection. | ||
6. Use the "Default" intent handler for everything that may not be handled by another handler. | ||
7. If you are uncertain of the intent, use the "Default" intent handler. | ||
|
||
Example: | ||
User: How do I create an index in my pineapples collection? | ||
Response: | ||
Query | ||
|
||
Example: | ||
User: | ||
What is $vectorSearch? | ||
Response: | ||
Docs`; | ||
} | ||
|
||
static getIntentFromModelResponse(response: string): PromptIntent { | ||
response = response.trim(); | ||
switch (response) { | ||
case 'Query': | ||
return 'Query'; | ||
case 'Schema': | ||
return 'Schema'; | ||
case 'Docs': | ||
return 'Docs'; | ||
default: | ||
return 'Default'; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a reminder that code blocks should be aligned with
codeBlockIdentifier
from #835