@@ -86,7 +86,7 @@ export abstract class AiProvider {
8686 const commands = [
8787 {
8888 cmd : 'ai.ask' ,
89- desc : 'ask questions' ,
89+ desc : 'ask MongoDB questions' ,
9090 example : 'ai.ask how do I run queries in mongosh?' ,
9191 } ,
9292 {
@@ -111,9 +111,14 @@ export abstract class AiProvider {
111111 } ,
112112 {
113113 cmd : 'ai.shell' ,
114- desc : 'generate general mongosh commands' ,
114+ desc : 'generate administrative mongosh commands' ,
115115 example : 'ai.shell get sharding info' ,
116116 } ,
117+ {
118+ cmd : 'ai.general' ,
119+ desc : 'use your model for general questions' ,
120+ example : 'ai.general what is the meaning of life?' ,
121+ } ,
117122 {
118123 cmd : 'ai.config' ,
119124 desc : 'configure the AI commands' ,
@@ -209,7 +214,7 @@ export abstract class AiProvider {
209214
210215 this . thinking . stop ( ) ;
211216 this . setInput (
212- this . cleanUpResponse ( response , { expectedOutput : 'mongoshCommand' } ) ,
217+ this . formatResponse ( response , { expectedOutput : 'mongoshCommand' } ) ,
213218 ) ;
214219 }
215220
@@ -230,10 +235,24 @@ export abstract class AiProvider {
230235
231236 this . thinking . stop ( ) ;
232237 this . setInput (
233- this . cleanUpResponse ( response , { expectedOutput : 'mongoshCommand' } ) ,
238+ this . formatResponse ( response , { expectedOutput : 'mongoshCommand' } ) ,
234239 ) ;
235240 }
236241
242+ async general ( prompt : string ) : Promise < void > {
243+ const signal = AbortSignal . timeout ( 30_000 ) ;
244+ this . thinking . start ( signal ) ;
245+
246+ const response = await this . getResponse ( prompt , {
247+ systemPrompt : 'Give brief answers without any formatting or markdown.' ,
248+ signal,
249+ expectedOutput : 'text' ,
250+ } ) ;
251+
252+ this . thinking . stop ( ) ;
253+ this . respond ( this . formatResponse ( response , { expectedOutput : 'text' } ) ) ;
254+ }
255+
237256 async data ( prompt : string ) : Promise < void > {
238257 await this . ensureCollectionName ( prompt ) ;
239258 const signal = AbortSignal . timeout ( 30_000 ) ;
@@ -252,7 +271,7 @@ export abstract class AiProvider {
252271
253272 this . thinking . stop ( ) ;
254273 this . setInput (
255- this . cleanUpResponse ( response , { expectedOutput : 'mongoshCommand' } ) ,
274+ this . formatResponse ( response , { expectedOutput : 'mongoshCommand' } ) ,
256275 ) ;
257276 }
258277
@@ -274,11 +293,11 @@ export abstract class AiProvider {
274293
275294 this . thinking . stop ( ) ;
276295 this . setInput (
277- this . cleanUpResponse ( response , { expectedOutput : 'mongoshCommand' } ) ,
296+ this . formatResponse ( response , { expectedOutput : 'mongoshCommand' } ) ,
278297 ) ;
279298 }
280299
281- cleanUpResponse (
300+ formatResponse (
282301 text : string ,
283302 {
284303 expectedOutput,
@@ -322,7 +341,7 @@ export abstract class AiProvider {
322341 } ) ;
323342
324343 this . thinking . stop ( ) ;
325- this . respond ( this . cleanUpResponse ( response , { expectedOutput : 'text' } ) ) ;
344+ this . respond ( this . formatResponse ( response , { expectedOutput : 'text' } ) ) ;
326345 }
327346
328347 public clear ( ) {
0 commit comments