-
Notifications
You must be signed in to change notification settings - Fork 24
feat: add ai snippets #12
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
base: main
Are you sure you want to change the base?
Conversation
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.
Keep in mind that this package-lock file has no practical effect 🙂
|
This isn't ready to merged, pending better alignment with product, but feel free to try it out! |
| return text; | ||
| } | ||
|
|
||
| async processResponse( |
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.
might be worth adding a basic "locking" mechanism to prevent something like
for (var i = 0; i < 10; i++) { ai.ask("what is mongosh?") }
That said I also find the idea of something like const a = ai.generate("sample document") function quite cool, albeit as thing stands pretty wasteful
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.
I wouldn't fully discount this as an option, with a local model this would actually be pretty much just fine, right?
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.
yeah, that said if they're using their own API key, it also poses a risk of accidentally getting them to spend a lot of money.
I can turn this into a configurable option and have it set to only 1 request at a time by default.
| # AI Snippets for mongosh | ||
|
|
||
| > [!CAUTION] | ||
| > This is an experimental, early-stage snippet that is not meant for production use. |
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.
For now, this is kind of true for all snippets we have
| /** @internal */ | ||
| respond(text: string) { | ||
| this.thinking.stop(); | ||
| process.stdout.write(text); |
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.
Can we have a ticket in mongosh to provide stdin, stdout, stderr streams in mongosh instead of having snippets work with process.* directly? mongosh is generally built in a way where it's not necessarily true that the streams that mongosh reads from and writes to are the process-wide stdio streams, and I'd prefer not to hardcode that expectation in snippets if we don't need to
| return text; | ||
| } | ||
|
|
||
| async processResponse( |
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.
I wouldn't fully discount this as an option, with a local model this would actually be pretty much just fine, right?
One can install this snippet using the
snippetcommand in mongosh: