-
Notifications
You must be signed in to change notification settings - Fork 183
fix: add dependencies for pg vector store #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
f1d185a
809f88a
418b180
5146713
8690ba2
cc62e6c
6351281
87e4cf2
6e248a2
fe645fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-llama": patch | ||
--- | ||
|
||
Add dependencies for PGVectorStore |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# coderabbit.yml | ||
reviews: | ||
path_instructions: | ||
- path: "templates/**" | ||
instructions: | | ||
For files under the `templates` folder, do not report 'Missing Dependencies Detected' errors. |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,75 @@ | ||||||||||
import { expect, test } from "@playwright/test"; | ||||||||||
import { exec } from "child_process"; | ||||||||||
import fs from "fs"; | ||||||||||
import path from "path"; | ||||||||||
import util from "util"; | ||||||||||
import { TemplateFramework, TemplateVectorDB } from "../helpers/types"; | ||||||||||
import { createTestDir, runCreateLlama } from "./utils"; | ||||||||||
|
||||||||||
const execAsync = util.promisify(exec); | ||||||||||
|
||||||||||
const templateFramework: TemplateFramework = process.env.FRAMEWORK | ||||||||||
? (process.env.FRAMEWORK as TemplateFramework) | ||||||||||
: "nextjs"; | ||||||||||
const dataSource: string = process.env.DATASOURCE | ||||||||||
? process.env.DATASOURCE | ||||||||||
: "--example-file"; | ||||||||||
|
||||||||||
if ( | ||||||||||
templateFramework == "nextjs" || | ||||||||||
templateFramework == "express" // test is only relevant for TS projects | ||||||||||
) { | ||||||||||
// vectorDBs combinations to test | ||||||||||
const vectorDbs: TemplateVectorDB[] = [ | ||||||||||
"mongo", | ||||||||||
"pg", | ||||||||||
"pinecone", | ||||||||||
"milvus", | ||||||||||
"astra", | ||||||||||
"qdrant", | ||||||||||
"chroma", | ||||||||||
"llamacloud", | ||||||||||
"weaviate", | ||||||||||
]; | ||||||||||
|
||||||||||
test.describe("Test resolve TS dependencies", () => { | ||||||||||
for (const vectorDb of vectorDbs) { | ||||||||||
const optionDescription = `vectorDb: ${vectorDb}, dataSource: ${dataSource}`; | ||||||||||
|
||||||||||
test(`options: ${optionDescription}`, async () => { | ||||||||||
const cwd = await createTestDir(); | ||||||||||
|
||||||||||
const result = await runCreateLlama( | ||||||||||
cwd, | ||||||||||
"streaming", | ||||||||||
templateFramework, | ||||||||||
dataSource, | ||||||||||
vectorDb, | ||||||||||
3000, // port | ||||||||||
8000, // externalPort | ||||||||||
"dependencies", // postInstallAction | ||||||||||
); | ||||||||||
const name = result.projectName; | ||||||||||
|
||||||||||
// Check if the app folder exists | ||||||||||
const appDir = path.join(cwd, name); | ||||||||||
const dirExists = fs.existsSync(appDir); | ||||||||||
expect(dirExists).toBeTruthy(); | ||||||||||
|
||||||||||
// Run tsc -b --diagnostics and capture the output | ||||||||||
const { stdout, stderr } = await execAsync( | ||||||||||
"pnpm exec tsc -b --diagnostics", | ||||||||||
{ | ||||||||||
cwd: appDir, | ||||||||||
}, | ||||||||||
); | ||||||||||
|
||||||||||
// Check if there's any error output | ||||||||||
expect(stderr).toBeFalsy(); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check The TypeScript compiler outputs compilation errors to Apply this diff to adjust the assertion: -// Check if there's any error output
-expect(stderr).toBeFalsy();
+// Ensure that there are no compilation errors
+expect(stdout).not.toMatch(/error TS\d{4}:/); Committable suggestion
Suggested change
|
||||||||||
|
||||||||||
// Log the stdout for debugging purposes | ||||||||||
console.log("TypeScript type-check output:", stdout); | ||||||||||
}); | ||||||||||
} | ||||||||||
}); | ||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle
execAsync
rejections to properly catch TypeScript compilation errorsCurrently, if the TypeScript compilation fails due to errors,
execAsync
will reject the promise and throw an exception. This can cause the test to fail unexpectedly without providing clear feedback on the compilation errors.Consider wrapping the
execAsync
call in atry...catch
block to handle exceptions and provide informative error messages or assertions.Apply this diff to handle the error appropriately:
Committable suggestion