Skip to content

Commit 364d221

Browse files
committed
add test and fix deps
1 parent 6e9184d commit 364d221

File tree

3 files changed

+119
-8
lines changed

3 files changed

+119
-8
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import { expect, test } from "@playwright/test";
2+
import { exec } from "child_process";
3+
import fs from "fs";
4+
import path from "path";
5+
import util from "util";
6+
import { TemplateVectorDB } from "../helpers/types";
7+
import { createTestDir, runCreateLlama } from "./utils";
8+
9+
const execAsync = util.promisify(exec);
10+
11+
const vectorDbs: TemplateVectorDB[] = [
12+
"mongo",
13+
"pg",
14+
"pinecone",
15+
"milvus",
16+
"astra",
17+
"qdrant",
18+
"chroma",
19+
"weaviate",
20+
];
21+
22+
const toolOptions = [
23+
"wikipedia.WikipediaToolSpec",
24+
"google.GoogleSearchToolSpec",
25+
];
26+
27+
// TODO: Add data sources to the test
28+
29+
test.describe("Test resolve python dependencies", () => {
30+
for (const vectorDb of vectorDbs) {
31+
for (const tool of toolOptions) {
32+
const optionDescription = `vectorDb: ${vectorDb}, tools: ${tool}`;
33+
34+
test(`options: ${optionDescription}`, async () => {
35+
const cwd = await createTestDir();
36+
37+
const result = await runCreateLlama(
38+
cwd,
39+
"streaming",
40+
"fastapi",
41+
"--example-file",
42+
vectorDb,
43+
3000, // port
44+
8000, // externalPort
45+
"none", // postInstallAction
46+
undefined, // ui
47+
"--no-frontend", // appType
48+
undefined, // llamaCloudProjectName
49+
undefined, // llamaCloudIndexName
50+
tool,
51+
);
52+
const name = result.projectName;
53+
54+
// Check if the app folder exists
55+
const dirExists = fs.existsSync(path.join(cwd, name));
56+
expect(dirExists).toBeTruthy();
57+
58+
// Check if pyproject.toml exists
59+
const pyprojectPath = path.join(cwd, name, "pyproject.toml");
60+
const pyprojectExists = fs.existsSync(pyprojectPath);
61+
expect(pyprojectExists).toBeTruthy();
62+
63+
// Run poetry lock
64+
try {
65+
const { stdout, stderr } = await execAsync(
66+
// Config poetry to create virtualenv in project directory.
67+
// so that we can easily prune the e2e cache to avoid overloading the storage.
68+
"poetry config virtualenvs.in-project true && poetry lock --no-update",
69+
{
70+
cwd: path.join(cwd, name),
71+
},
72+
);
73+
console.log("poetry lock stdout:", stdout);
74+
console.error("poetry lock stderr:", stderr);
75+
} catch (error) {
76+
console.error("Error running poetry lock:", error);
77+
throw error;
78+
}
79+
80+
// Check if poetry.lock file was created
81+
const poetryLockExists = fs.existsSync(
82+
path.join(cwd, name, "poetry.lock"),
83+
);
84+
expect(poetryLockExists).toBeTruthy();
85+
86+
// Verify that specific dependencies are in pyproject.toml
87+
const pyprojectContent = fs.readFileSync(pyprojectPath, "utf-8");
88+
if (vectorDb !== "none") {
89+
if (vectorDb === "pg") {
90+
expect(pyprojectContent).toContain(
91+
"llama-index-vector-stores-postgres",
92+
);
93+
} else {
94+
expect(pyprojectContent).toContain(
95+
`llama-index-vector-stores-${vectorDb}`,
96+
);
97+
}
98+
}
99+
if (tool !== "none") {
100+
if (tool === "wikipedia.WikipediaToolSpec") {
101+
expect(pyprojectContent).toContain("wikipedia");
102+
}
103+
if (tool === "google.GoogleSearchToolSpec") {
104+
expect(pyprojectContent).toContain("google");
105+
}
106+
}
107+
});
108+
}
109+
}
110+
});

e2e/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export async function runCreateLlama(
3232
appType?: AppType,
3333
llamaCloudProjectName?: string,
3434
llamaCloudIndexName?: string,
35+
tools?: string,
3536
): Promise<CreateLlamaResult> {
3637
if (!process.env.OPENAI_API_KEY || !process.env.LLAMA_CLOUD_API_KEY) {
3738
throw new Error(
@@ -65,7 +66,7 @@ export async function runCreateLlama(
6566
"--post-install-action",
6667
postInstallAction,
6768
"--tools",
68-
"none",
69+
tools ?? "none",
6970
"--no-llama-parse",
7071
"--observability",
7172
"none",

helpers/python.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ const getAdditionalDependencies = (
3636
case "mongo": {
3737
dependencies.push({
3838
name: "llama-index-vector-stores-mongodb",
39-
version: "^0.1.3",
39+
version: "^0.3.1",
4040
});
4141
break;
4242
}
4343
case "pg": {
4444
dependencies.push({
4545
name: "llama-index-vector-stores-postgres",
46-
version: "^0.1.1",
46+
version: "^0.2.5",
4747
});
4848
break;
4949
}
@@ -57,7 +57,7 @@ const getAdditionalDependencies = (
5757
case "milvus": {
5858
dependencies.push({
5959
name: "llama-index-vector-stores-milvus",
60-
version: "^0.1.20",
60+
version: "^0.2.0",
6161
});
6262
dependencies.push({
6363
name: "pymilvus",
@@ -68,7 +68,7 @@ const getAdditionalDependencies = (
6868
case "astra": {
6969
dependencies.push({
7070
name: "llama-index-vector-stores-astra-db",
71-
version: "^0.1.5",
71+
version: "^0.2.0",
7272
});
7373
break;
7474
}
@@ -82,14 +82,14 @@ const getAdditionalDependencies = (
8282
case "chroma": {
8383
dependencies.push({
8484
name: "llama-index-vector-stores-chroma",
85-
version: "^0.1.8",
85+
version: "^0.2.0",
8686
});
8787
break;
8888
}
8989
case "weaviate": {
9090
dependencies.push({
9191
name: "llama-index-vector-stores-weaviate",
92-
version: "^1.0.2",
92+
version: "^1.1.1",
9393
});
9494
break;
9595
}
@@ -130,7 +130,7 @@ const getAdditionalDependencies = (
130130
case "llamacloud":
131131
dependencies.push({
132132
name: "llama-index-indices-managed-llama-cloud",
133-
version: "^0.3.0",
133+
version: "^0.3.1",
134134
});
135135
break;
136136
}

0 commit comments

Comments
 (0)