Skip to content

Commit 0a7dfcf

Browse files
feat: Generate NEXT_PUBLIC_CHAT_API for NextJS backend to specify alternative backend (#445)
1 parent 6e70e32 commit 0a7dfcf

File tree

6 files changed

+13
-15
lines changed

6 files changed

+13
-15
lines changed

.changeset/perfect-days-smoke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-llama": patch
3+
---
4+
5+
Generate NEXT_PUBLIC_CHAT_API for NextJS backend to specify alternative backend

create-app.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { configVSCode } from "./helpers/vscode";
1616

1717
export type InstallAppArgs = Omit<
1818
InstallTemplateArgs,
19-
"appName" | "root" | "isOnline" | "customApiPath"
19+
"appName" | "root" | "isOnline" | "port"
2020
> & {
2121
appPath: string;
2222
frontend: boolean;
@@ -34,7 +34,6 @@ export async function createApp({
3434
communityProjectConfig,
3535
llamapack,
3636
vectorDb,
37-
port,
3837
postInstallAction,
3938
dataSources,
4039
tools,
@@ -80,7 +79,6 @@ export async function createApp({
8079
communityProjectConfig,
8180
llamapack,
8281
vectorDb,
83-
port,
8482
postInstallAction,
8583
dataSources,
8684
tools,
@@ -100,7 +98,6 @@ export async function createApp({
10098
...args,
10199
root: frontendRoot,
102100
framework: "nextjs",
103-
customApiPath: `http://localhost:${port ?? 8000}/api/chat`,
104101
backend: false,
105102
});
106103
}

helpers/env-variables.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,13 @@ const getFrameworkEnvs = (
407407
],
408408
);
409409
}
410+
if (framework === "nextjs") {
411+
result.push({
412+
name: "NEXT_PUBLIC_CHAT_API",
413+
description:
414+
"The API for the chat endpoint. Set when using a custom backend (e.g. Express). Use full URL like http://localhost:8000/api/chat",
415+
});
416+
}
410417
return result;
411418
};
412419

@@ -585,18 +592,10 @@ export const createBackendEnvFile = async (
585592
export const createFrontendEnvFile = async (
586593
root: string,
587594
opts: {
588-
customApiPath?: string;
589595
vectorDb?: TemplateVectorDB;
590596
},
591597
) => {
592598
const defaultFrontendEnvs = [
593-
{
594-
name: "NEXT_PUBLIC_CHAT_API",
595-
description: "The backend API for chat endpoint.",
596-
value: opts.customApiPath
597-
? opts.customApiPath
598-
: "http://localhost:8000/api/chat",
599-
},
600599
{
601600
name: "NEXT_PUBLIC_USE_LLAMACLOUD",
602601
description: "Let's the user change indexes in LlamaCloud projects",

helpers/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ export const installTemplate = async (
225225
} else {
226226
// this is a frontend for a full-stack app, create .env file with model information
227227
await createFrontendEnvFile(props.root, {
228-
customApiPath: props.customApiPath,
229228
vectorDb: props.vectorDb,
230229
});
231230
}

helpers/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export interface InstallTemplateArgs {
8989
framework: TemplateFramework;
9090
ui: TemplateUI;
9191
dataSources: TemplateDataSource[];
92-
customApiPath?: string;
9392
modelConfig: ModelConfig;
9493
llamaCloudKey?: string;
9594
useLlamaParse?: boolean;

index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ async function run(): Promise<void> {
326326
...answers,
327327
appPath: resolvedProjectPath,
328328
packageManager,
329-
port: options.port,
330329
});
331330

332331
if (answers.postInstallAction === "VSCode") {

0 commit comments

Comments
 (0)