Skip to content
Snippets Groups Projects
Unverified Commit 0a7dfcf8 authored by Marcus Schiesser's avatar Marcus Schiesser Committed by GitHub
Browse files

feat: Generate NEXT_PUBLIC_CHAT_API for NextJS backend to specify alternative backend (#445)

parent 6e70e327
No related branches found
No related tags found
No related merge requests found
---
"create-llama": patch
---
Generate NEXT_PUBLIC_CHAT_API for NextJS backend to specify alternative backend
...@@ -16,7 +16,7 @@ import { configVSCode } from "./helpers/vscode"; ...@@ -16,7 +16,7 @@ import { configVSCode } from "./helpers/vscode";
export type InstallAppArgs = Omit< export type InstallAppArgs = Omit<
InstallTemplateArgs, InstallTemplateArgs,
"appName" | "root" | "isOnline" | "customApiPath" "appName" | "root" | "isOnline" | "port"
> & { > & {
appPath: string; appPath: string;
frontend: boolean; frontend: boolean;
...@@ -34,7 +34,6 @@ export async function createApp({ ...@@ -34,7 +34,6 @@ export async function createApp({
communityProjectConfig, communityProjectConfig,
llamapack, llamapack,
vectorDb, vectorDb,
port,
postInstallAction, postInstallAction,
dataSources, dataSources,
tools, tools,
...@@ -80,7 +79,6 @@ export async function createApp({ ...@@ -80,7 +79,6 @@ export async function createApp({
communityProjectConfig, communityProjectConfig,
llamapack, llamapack,
vectorDb, vectorDb,
port,
postInstallAction, postInstallAction,
dataSources, dataSources,
tools, tools,
...@@ -100,7 +98,6 @@ export async function createApp({ ...@@ -100,7 +98,6 @@ export async function createApp({
...args, ...args,
root: frontendRoot, root: frontendRoot,
framework: "nextjs", framework: "nextjs",
customApiPath: `http://localhost:${port ?? 8000}/api/chat`,
backend: false, backend: false,
}); });
} }
......
...@@ -407,6 +407,13 @@ const getFrameworkEnvs = ( ...@@ -407,6 +407,13 @@ const getFrameworkEnvs = (
], ],
); );
} }
if (framework === "nextjs") {
result.push({
name: "NEXT_PUBLIC_CHAT_API",
description:
"The API for the chat endpoint. Set when using a custom backend (e.g. Express). Use full URL like http://localhost:8000/api/chat",
});
}
return result; return result;
}; };
...@@ -585,18 +592,10 @@ export const createBackendEnvFile = async ( ...@@ -585,18 +592,10 @@ export const createBackendEnvFile = async (
export const createFrontendEnvFile = async ( export const createFrontendEnvFile = async (
root: string, root: string,
opts: { opts: {
customApiPath?: string;
vectorDb?: TemplateVectorDB; vectorDb?: TemplateVectorDB;
}, },
) => { ) => {
const defaultFrontendEnvs = [ const defaultFrontendEnvs = [
{
name: "NEXT_PUBLIC_CHAT_API",
description: "The backend API for chat endpoint.",
value: opts.customApiPath
? opts.customApiPath
: "http://localhost:8000/api/chat",
},
{ {
name: "NEXT_PUBLIC_USE_LLAMACLOUD", name: "NEXT_PUBLIC_USE_LLAMACLOUD",
description: "Let's the user change indexes in LlamaCloud projects", description: "Let's the user change indexes in LlamaCloud projects",
......
...@@ -225,7 +225,6 @@ export const installTemplate = async ( ...@@ -225,7 +225,6 @@ export const installTemplate = async (
} else { } else {
// this is a frontend for a full-stack app, create .env file with model information // this is a frontend for a full-stack app, create .env file with model information
await createFrontendEnvFile(props.root, { await createFrontendEnvFile(props.root, {
customApiPath: props.customApiPath,
vectorDb: props.vectorDb, vectorDb: props.vectorDb,
}); });
} }
......
...@@ -89,7 +89,6 @@ export interface InstallTemplateArgs { ...@@ -89,7 +89,6 @@ export interface InstallTemplateArgs {
framework: TemplateFramework; framework: TemplateFramework;
ui: TemplateUI; ui: TemplateUI;
dataSources: TemplateDataSource[]; dataSources: TemplateDataSource[];
customApiPath?: string;
modelConfig: ModelConfig; modelConfig: ModelConfig;
llamaCloudKey?: string; llamaCloudKey?: string;
useLlamaParse?: boolean; useLlamaParse?: boolean;
......
...@@ -326,7 +326,6 @@ async function run(): Promise<void> { ...@@ -326,7 +326,6 @@ async function run(): Promise<void> {
...answers, ...answers,
appPath: resolvedProjectPath, appPath: resolvedProjectPath,
packageManager, packageManager,
port: options.port,
}); });
if (answers.postInstallAction === "VSCode") { if (answers.postInstallAction === "VSCode") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment