@@ -5,11 +5,13 @@ import chalk from "chalk";
55import withOra from "../../utils/withOra.js" ;
66import { defaultChatSystemPrompt } from "../../config.js" ;
77import { LlamaChatPromptWrapper } from "../../chatWrappers/LlamaChatPromptWrapper.js" ;
8+ import { GeneralChatPromptWrapper } from "../../chatWrappers/GeneralChatPromptWrapper.js" ;
89
910type ChatCommand = {
1011 model : string ,
1112 systemInfo : boolean ,
12- systemPrompt : string
13+ systemPrompt : string ,
14+ wrapper : string
1315} ;
1416
1517export const ChatCommand : CommandModule < object , ChatCommand > = {
@@ -37,11 +39,18 @@ export const ChatCommand: CommandModule<object, ChatCommand> = {
3739 "System prompt to use against the model. " +
3840 "[default value: " + defaultChatSystemPrompt . split ( "\n" ) . join ( " " ) + "]" ,
3941 group : "Optional:"
42+ } )
43+ . option ( "wrapper" , {
44+ type : "string" ,
45+ default : "general" ,
46+ choices : [ "general" , "llama" ] ,
47+ description : "Chat wrapper to use" ,
48+ group : "Optional:"
4049 } ) ;
4150 } ,
42- async handler ( { model, systemInfo, systemPrompt} ) {
51+ async handler ( { model, systemInfo, systemPrompt, wrapper } ) {
4352 try {
44- await RunChat ( { model, systemInfo, systemPrompt} ) ;
53+ await RunChat ( { model, systemInfo, systemPrompt, wrapper } ) ;
4554 } catch ( err ) {
4655 console . error ( err ) ;
4756 process . exit ( 1 ) ;
@@ -50,7 +59,7 @@ export const ChatCommand: CommandModule<object, ChatCommand> = {
5059} ;
5160
5261
53- async function RunChat ( { model : modelArg , systemInfo, systemPrompt} : ChatCommand ) {
62+ async function RunChat ( { model : modelArg , systemInfo, systemPrompt, wrapper } : ChatCommand ) {
5463 const { LlamaChatSession} = await import ( "../../LlamaChatSession.js" ) ;
5564 const { LlamaModel} = await import ( "../../LlamaModel.js" ) ;
5665
@@ -61,7 +70,7 @@ async function RunChat({model: modelArg, systemInfo, systemPrompt}: ChatCommand)
6170 model,
6271 printLLamaSystemInfo : systemInfo ,
6372 systemPrompt,
64- promptWrapper : new LlamaChatPromptWrapper ( )
73+ promptWrapper : createChatWrapper ( wrapper )
6574 } ) ;
6675
6776 await withOra ( {
@@ -99,3 +108,13 @@ async function RunChat({model: modelArg, systemInfo, systemPrompt}: ChatCommand)
99108 console . log ( ) ;
100109 }
101110}
111+
112+ function createChatWrapper ( wrapper : string ) {
113+ switch ( wrapper ) {
114+ case "general" :
115+ return new GeneralChatPromptWrapper ( ) ;
116+ case "llama" :
117+ return new LlamaChatPromptWrapper ( ) ;
118+ }
119+ throw new Error ( "Unknown wrapper: " + wrapper ) ;
120+ }
0 commit comments