Skip to content

Commit

Permalink
fix: fallback for result
Browse files Browse the repository at this point in the history
  • Loading branch information
thucpn committed Nov 29, 2024
1 parent f658536 commit 719ded9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions examples/vercel/llamacloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ async function main() {
name: "test-pipeline",
projectName: "Default",
apiKey: process.env.LLAMA_CLOUD_API_KEY,
baseUrl: process.env.LLAMA_CLOUD_BASE_URL,
});
const queryTool = await llamaindex({ index });
const queryTool = await llamaindex({
index,
description: "Search through Abramov's essay", // optional description
});
console.log("Successfully created index and queryTool");

streamText({
Expand Down
2 changes: 1 addition & 1 deletion examples/vercel/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function llamaindex({
}),
execute: async ({ query }) => {
const result = await queryEngine?.query({ query });
return result?.message.content;
return result?.message.content ?? "No result found in documents.";
},
};
}
5 changes: 4 additions & 1 deletion examples/vercel/vector-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ async function main() {
const document = new Document({ text: essay, id_: path });

const index = await VectorStoreIndex.fromDocuments([document]);
const queryTool = await llamaindex({ index });
const queryTool = await llamaindex({
index,
description: "Search through Abramov's essay", // optional description
});
console.log("Successfully created index and queryTool");

streamText({
Expand Down

0 comments on commit 719ded9

Please sign in to comment.