Skip to content

Commit 70f7dca

Browse files
authored
feat: add test deps for llamaparse (#323)
1 parent cf65162 commit 70f7dca

7 files changed

+128
-99
lines changed

.changeset/chilled-snakes-act.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+
feat: add test deps for llamaparse

e2e/extractor_template.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ if (
3232
cwd = await createTestDir();
3333
frontendPort = Math.floor(Math.random() * 10000) + 10000;
3434
backendPort = frontendPort + 1;
35-
const result = await runCreateLlama(
35+
const result = await runCreateLlama({
3636
cwd,
37-
"extractor",
38-
"fastapi",
39-
"--example-file",
40-
"none",
41-
frontendPort,
42-
backendPort,
43-
"runApp",
44-
);
37+
templateType: "extractor",
38+
templateFramework: "fastapi",
39+
dataSource: "--example-file",
40+
vectorDb: "none",
41+
port: frontendPort,
42+
externalPort: backendPort,
43+
postInstallAction: "runApp",
44+
});
4545
name = result.projectName;
4646
appProcess = result.appProcess;
4747
});

e2e/multiagent_template.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ test.describe(`Test multiagent template ${templateFramework} ${dataSource} ${tem
3636
port = Math.floor(Math.random() * 10000) + 10000;
3737
externalPort = port + 1;
3838
cwd = await createTestDir();
39-
const result = await runCreateLlama(
39+
const result = await runCreateLlama({
4040
cwd,
41-
"multiagent",
41+
templateType: "multiagent",
4242
templateFramework,
4343
dataSource,
4444
vectorDb,
4545
port,
4646
externalPort,
47-
templatePostInstallAction,
47+
postInstallAction: templatePostInstallAction,
4848
templateUI,
4949
appType,
50-
);
50+
});
5151
name = result.projectName;
5252
appProcess = result.appProcess;
5353
});

e2e/resolve_python_dependencies.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,21 @@ if (
5353
test(`options: ${optionDescription}`, async () => {
5454
const cwd = await createTestDir();
5555

56-
const result = await runCreateLlama(
56+
const result = await runCreateLlama({
5757
cwd,
58-
"streaming",
59-
"fastapi",
58+
templateType: "streaming",
59+
templateFramework: "fastapi",
6060
dataSource,
6161
vectorDb,
62-
3000, // port
63-
8000, // externalPort
64-
"none", // postInstallAction
65-
undefined, // ui
66-
"--no-frontend", // appType
67-
undefined, // llamaCloudProjectName
68-
undefined, // llamaCloudIndexName
69-
tool,
70-
);
62+
port: 3000, // port
63+
externalPort: 8000, // externalPort
64+
postInstallAction: "none", // postInstallAction
65+
templateUI: undefined, // ui
66+
appType: "--no-frontend", // appType
67+
llamaCloudProjectName: undefined, // llamaCloudProjectName
68+
llamaCloudIndexName: undefined, // llamaCloudIndexName
69+
tools: tool,
70+
});
7171
const name = result.projectName;
7272

7373
// Check if the app folder exists

e2e/resolve_ts_dependencies.spec.ts

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ if (
1919
templateFramework == "nextjs" ||
2020
templateFramework == "express" // test is only relevant for TS projects
2121
) {
22+
const llamaParseOptions = [true, false];
2223
// vectorDBs combinations to test
2324
const vectorDbs: TemplateVectorDB[] = [
2425
"mongo",
@@ -33,65 +34,69 @@ if (
3334
];
3435

3536
test.describe("Test resolve TS dependencies", () => {
36-
for (const vectorDb of vectorDbs) {
37-
const optionDescription = `vectorDb: ${vectorDb}, dataSource: ${dataSource}`;
37+
for (const llamaParseOpt of llamaParseOptions) {
38+
for (const vectorDb of vectorDbs) {
39+
const optionDescription = `vectorDb: ${vectorDb}, dataSource: ${dataSource}, llamaParse: ${llamaParseOpt}`;
3840

39-
test(`options: ${optionDescription}`, async () => {
40-
const cwd = await createTestDir();
41+
test(`options: ${optionDescription}`, async () => {
42+
const cwd = await createTestDir();
4143

42-
const result = await runCreateLlama(
43-
cwd,
44-
"streaming",
45-
templateFramework,
46-
dataSource,
47-
vectorDb,
48-
3000, // port
49-
8000, // externalPort
50-
"none", // postInstallAction
51-
undefined, // ui
52-
templateFramework === "nextjs" ? "" : "--no-frontend", // appType
53-
undefined, // llamaCloudProjectName
54-
undefined, // llamaCloudIndexName
55-
);
56-
const name = result.projectName;
44+
const result = await runCreateLlama({
45+
cwd: cwd,
46+
templateType: "streaming",
47+
templateFramework: templateFramework,
48+
dataSource: dataSource,
49+
vectorDb: vectorDb,
50+
port: 3000,
51+
externalPort: 8000,
52+
postInstallAction: "none",
53+
templateUI: undefined,
54+
appType: templateFramework === "nextjs" ? "" : "--no-frontend",
55+
llamaCloudProjectName: undefined,
56+
llamaCloudIndexName: undefined,
57+
tools: undefined,
58+
useLlamaParse: llamaParseOpt,
59+
});
60+
const name = result.projectName;
5761

58-
// Check if the app folder exists
59-
const appDir = path.join(cwd, name);
60-
const dirExists = fs.existsSync(appDir);
61-
expect(dirExists).toBeTruthy();
62+
// Check if the app folder exists
63+
const appDir = path.join(cwd, name);
64+
const dirExists = fs.existsSync(appDir);
65+
expect(dirExists).toBeTruthy();
6266

63-
// Install dependencies using pnpm
64-
try {
65-
const { stderr: installStderr } = await execAsync(
66-
"pnpm install --prefer-offline",
67-
{
68-
cwd: appDir,
69-
},
70-
);
71-
expect(installStderr).toBeFalsy();
72-
} catch (error) {
73-
console.error("Error installing dependencies:", error);
74-
throw error;
75-
}
67+
// Install dependencies using pnpm
68+
try {
69+
const { stderr: installStderr } = await execAsync(
70+
"pnpm install --prefer-offline",
71+
{
72+
cwd: appDir,
73+
},
74+
);
75+
expect(installStderr).toBeFalsy();
76+
} catch (error) {
77+
console.error("Error installing dependencies:", error);
78+
throw error;
79+
}
7680

77-
// Run tsc type check and capture the output
78-
try {
79-
const { stdout, stderr } = await execAsync(
80-
"pnpm exec tsc -b --diagnostics",
81-
{
82-
cwd: appDir,
83-
},
84-
);
85-
// Check if there's any error output
86-
expect(stderr).toBeFalsy();
81+
// Run tsc type check and capture the output
82+
try {
83+
const { stdout, stderr } = await execAsync(
84+
"pnpm exec tsc -b --diagnostics",
85+
{
86+
cwd: appDir,
87+
},
88+
);
89+
// Check if there's any error output
90+
expect(stderr).toBeFalsy();
8791

88-
// Log the stdout for debugging purposes
89-
console.log("TypeScript type-check output:", stdout);
90-
} catch (error) {
91-
console.error("Error running tsc:", error);
92-
throw error;
93-
}
94-
});
92+
// Log the stdout for debugging purposes
93+
console.log("TypeScript type-check output:", stdout);
94+
} catch (error) {
95+
console.error("Error running tsc:", error);
96+
throw error;
97+
}
98+
});
99+
}
95100
}
96101
});
97102
}

e2e/streaming_template.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ test.describe(`Test streaming template ${templateFramework} ${dataSource} ${temp
3939
port = Math.floor(Math.random() * 10000) + 10000;
4040
externalPort = port + 1;
4141
cwd = await createTestDir();
42-
const result = await runCreateLlama(
42+
const result = await runCreateLlama({
4343
cwd,
44-
"streaming",
44+
templateType: "streaming",
4545
templateFramework,
4646
dataSource,
4747
vectorDb,
4848
port,
4949
externalPort,
50-
templatePostInstallAction,
50+
postInstallAction: templatePostInstallAction,
5151
templateUI,
5252
appType,
5353
llamaCloudProjectName,
5454
llamaCloudIndexName,
55-
);
55+
});
5656
name = result.projectName;
5757
appProcess = result.appProcess;
5858
});

e2e/utils.ts

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,39 @@ export type CreateLlamaResult = {
1818
appProcess: ChildProcess;
1919
};
2020

21-
// eslint-disable-next-line max-params
22-
export async function runCreateLlama(
23-
cwd: string,
24-
templateType: TemplateType,
25-
templateFramework: TemplateFramework,
26-
dataSource: string,
27-
vectorDb: TemplateVectorDB,
28-
port: number,
29-
externalPort: number,
30-
postInstallAction: TemplatePostInstallAction,
31-
templateUI?: TemplateUI,
32-
appType?: AppType,
33-
llamaCloudProjectName?: string,
34-
llamaCloudIndexName?: string,
35-
tools?: string,
36-
): Promise<CreateLlamaResult> {
21+
export type RunCreateLlamaOptions = {
22+
cwd: string;
23+
templateType: TemplateType;
24+
templateFramework: TemplateFramework;
25+
dataSource: string;
26+
vectorDb: TemplateVectorDB;
27+
port: number;
28+
externalPort: number;
29+
postInstallAction: TemplatePostInstallAction;
30+
templateUI?: TemplateUI;
31+
appType?: AppType;
32+
llamaCloudProjectName?: string;
33+
llamaCloudIndexName?: string;
34+
tools?: string;
35+
useLlamaParse?: boolean;
36+
};
37+
38+
export async function runCreateLlama({
39+
cwd,
40+
templateType,
41+
templateFramework,
42+
dataSource,
43+
vectorDb,
44+
port,
45+
externalPort,
46+
postInstallAction,
47+
templateUI,
48+
appType,
49+
llamaCloudProjectName,
50+
llamaCloudIndexName,
51+
tools,
52+
useLlamaParse,
53+
}: RunCreateLlamaOptions): Promise<CreateLlamaResult> {
3754
if (!process.env.OPENAI_API_KEY || !process.env.LLAMA_CLOUD_API_KEY) {
3855
throw new Error(
3956
"Setting the OPENAI_API_KEY and LLAMA_CLOUD_API_KEY is mandatory to run tests",
@@ -80,7 +97,6 @@ export async function runCreateLlama(
8097
postInstallAction,
8198
"--tools",
8299
tools ?? "none",
83-
"--no-llama-parse",
84100
"--observability",
85101
"none",
86102
"--llama-cloud-key",
@@ -93,6 +109,9 @@ export async function runCreateLlama(
93109
if (appType) {
94110
commandArgs.push(appType);
95111
}
112+
if (!useLlamaParse) {
113+
commandArgs.push("--no-llama-parse");
114+
}
96115

97116
const command = commandArgs.join(" ");
98117
console.log(`running command '${command}' in ${cwd}`);

0 commit comments

Comments
 (0)