Skip to content

Commit de91298

Browse files
RAG pipeline
1 parent e356136 commit de91298

File tree

6 files changed

+43
-7
lines changed

6 files changed

+43
-7
lines changed

dump.rdb

0 Bytes
Binary file not shown.
File renamed without changes.

src/routes/PDF-routes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import express from "express";
22
import { pdfUploadFilesController } from "../controllers/pdf/pdf-upload";
33
import { upload } from "../middleware./uploadfiles";
4-
import { pdfChatController } from "../controllers/pdf/pdg-chat";
4+
import { pdfChatController } from "../controllers/pdf/pdf-chat";
55
const router = express.Router();
66

77
router.post("/uploads", upload.array("files", 10), pdfUploadFilesController);

src/service/ai-response-service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { GoogleGenerativeAI } from "@google/generative-ai";
33

44
const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY!);
55

6-
const model = genAI.getGenerativeModel({ model: "gemini-pro" });
6+
const model = genAI.getGenerativeModel({
7+
model: "gemini-2.5-flash-preview-05-20",
8+
});
79

810
export async function generateChatResponse(
911
question: string,

src/service/vector-store-service.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { ChromaClient, EmbeddingFunction } from "chromadb";
22
import { generateEmbedding } from "./embedding-service";
33

4-
const client = new ChromaClient();
4+
const client = new ChromaClient({
5+
host: "127.0.0.1",
6+
port: 8000,
7+
});
58

69
class GoogleAIEmbeddingFunction implements EmbeddingFunction {
710
public async generate(texts: string[]): Promise<number[][]> {
@@ -24,15 +27,17 @@ export async function getKnowledgeCollection() {
2427
return collection;
2528
}
2629

27-
export async function queryKnowledgeBase(question: string): Promise<string[]> {
28-
const collection = getKnowledgeCollection();
30+
export async function queryKnowledgeBase(question: string) {
31+
const collection = await getKnowledgeCollection();
2932

30-
const results = (await collection).query({
33+
const results = await collection.query({
3134
queryTexts: [question],
3235
nResults: 5,
3336
});
3437

35-
return (await results).documents[0];
38+
console.log(results);
39+
40+
return results.documents[0];
3641
}
3742

3843
export async function cleanUpPreviousData() {

test-chroma-connection.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { ChromaClient } from "chromadb";
2+
3+
async function main() {
4+
console.log("--- Running Isolated ChromaDB Connection Test ---");
5+
6+
console.log("Attempting to create client with host: 127.0.0.1, port: 8000");
7+
8+
const client = new ChromaClient({
9+
host: "127.0.0.1",
10+
port: 8000,
11+
});
12+
13+
try {
14+
console.log("Client created. Attempting to get heartbeat...");
15+
const heartbeat = await client.heartbeat();
16+
console.log("✅✅✅ SUCCESS: ChromaDB heartbeat received:", heartbeat);
17+
console.log(
18+
"\nThis confirms the connection from Node.js is working correctly."
19+
);
20+
} catch (error) {
21+
console.error("🔴🔴🔴 FAILED: The isolated connection test failed.");
22+
console.error(
23+
"This means the issue is fundamental to the Node.js client or your environment."
24+
);
25+
console.error("The full error is:", error);
26+
}
27+
}
28+
29+
main();

0 commit comments

Comments
 (0)