diff --git a/questions.ts b/questions.ts index c3f5e696d4bab00ca8b94882f10df32a78cad37c..5b0f098ad85a88854477a42fda9fd4c2afda9181 100644 --- a/questions.ts +++ b/questions.ts @@ -189,7 +189,7 @@ export const askQuestions = async ( } } - if (program.framework === "nextjs") { + if (program.framework === "express" || program.framework === "nextjs") { if (!program.model) { if (ciInfo.isCI) { program.model = getPrefOrDefault("model"); diff --git a/templates/index.ts b/templates/index.ts index 79746b62d67c79167f629d45972bc6072f9554ab..30007876816ba1ccd2893bf7fc40e045c97018d0 100644 --- a/templates/index.ts +++ b/templates/index.ts @@ -176,7 +176,7 @@ const installTSTemplate = async ({ }); } - if (framework === "nextjs") { + if (framework === "nextjs" || framework === "express") { await fs.writeFile( path.join(root, "constants.ts"), `export const MODEL = "${model || "gpt-3.5-turbo"}";\n`, diff --git a/templates/types/simple/express/constants.ts b/templates/types/simple/express/constants.ts new file mode 100644 index 0000000000000000000000000000000000000000..908949251c708651be6d0ae6b09c2982e65b0a1a --- /dev/null +++ b/templates/types/simple/express/constants.ts @@ -0,0 +1 @@ +export const MODEL = "gpt-3.5-turbo"; diff --git a/templates/types/simple/express/src/controllers/chat.controller.ts b/templates/types/simple/express/src/controllers/chat.controller.ts index dd4532ffde1f611545a0b406899eb73c657ca11b..6612971ac5c445bce4dee0d961e8b04e74633597 100644 --- a/templates/types/simple/express/src/controllers/chat.controller.ts +++ b/templates/types/simple/express/src/controllers/chat.controller.ts @@ -1,5 +1,6 @@ import { NextFunction, Request, Response } from "express"; import { ChatMessage, OpenAI } from "llamaindex"; +import { MODEL } from "../../constants"; import { createChatEngine } from "./engine"; export const chat = async (req: Request, res: Response, next: NextFunction) => { @@ -14,7 +15,7 @@ export const chat = async (req: Request, res: Response, next: NextFunction) => { } const llm = new OpenAI({ - model: "gpt-3.5-turbo", + model: MODEL, }); const chatEngine = await createChatEngine(llm); diff --git a/templates/types/streaming/express/constants.ts b/templates/types/streaming/express/constants.ts new file mode 100644 index 0000000000000000000000000000000000000000..908949251c708651be6d0ae6b09c2982e65b0a1a --- /dev/null +++ b/templates/types/streaming/express/constants.ts @@ -0,0 +1 @@ +export const MODEL = "gpt-3.5-turbo"; diff --git a/templates/types/streaming/express/src/controllers/chat.controller.ts b/templates/types/streaming/express/src/controllers/chat.controller.ts index efa05479614fcb36de52e90fa47a0026b73db468..76b8fafdb14adbf79099dd302fe78ccc4cdd119a 100644 --- a/templates/types/streaming/express/src/controllers/chat.controller.ts +++ b/templates/types/streaming/express/src/controllers/chat.controller.ts @@ -1,6 +1,7 @@ import { streamToResponse } from "ai"; import { NextFunction, Request, Response } from "express"; import { ChatMessage, OpenAI } from "llamaindex"; +import { MODEL } from "../../constants"; import { createChatEngine } from "./engine"; import { LlamaIndexStream } from "./llamaindex-stream"; @@ -16,7 +17,7 @@ export const chat = async (req: Request, res: Response, next: NextFunction) => { } const llm = new OpenAI({ - model: "gpt-3.5-turbo", + model: MODEL, }); const chatEngine = await createChatEngine(llm);