Skip to content

Commit

Permalink
fix: change error message when retrieved content doesnt have any text…
Browse files Browse the repository at this point in the history
… metadata
  • Loading branch information
ogzhanolguncu committed Jun 6, 2024
1 parent df05782 commit 38ddae2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@upstash/rag-chat",
"version": "0.0.32-alpha",
"version": "0.0.33-alpha",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
Expand Down
9 changes: 2 additions & 7 deletions src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,12 @@ export class Database {
);

if (allValuesUndefined) {
throw new TypeError(`
Query to the vector store returned ${result.length} vectors but none had "${metadataKey}" field in their metadata.
Text of your vectors should be in the "${metadataKey}" field in the metadata for the RAG Chat.
`);
throw new TypeError("There is no answer for this question in the provided context.");
}

const facts = result
.filter((x) => x.score >= similarityThreshold)
.map(
(embedding) => `- ${embedding.metadata?.[metadataKey] ?? ""}`
);
.map((embedding) => `- ${embedding.metadata?.[metadataKey] ?? ""}`);
return formatFacts(facts);
}

Expand Down

0 comments on commit 38ddae2

Please sign in to comment.