Skip to content

Commit 4ea533d

Browse files
committed
fix for vectorDB example
1 parent cf7bd63 commit 4ea533d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

examples/05-VectorDB-with-agent/01-upsert-and-search.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Agent, Doc, Model, Scope } from '@smythos/sdk';
1+
import { Agent, Doc, Model, Scope, TLLMEvent } from '@smythos/sdk';
22
import path from 'path';
33
import { fileURLToPath } from 'url';
44

@@ -84,14 +84,25 @@ async function indexDataForAgent(agent: Agent) {
8484
await pinecone.insertDoc(parsedDoc.title, parsedDoc, { myEntry: 'My Metadata' });
8585
}
8686

87+
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
88+
8789
async function main() {
8890
const agent = await createAgent();
91+
console.log('Indexing data for agent');
8992
await indexDataForAgent(agent);
9093

94+
console.log('Waiting for 5 seconds before prompting the agent ... sometimes the index is not ready immediately');
95+
await delay(5000);
96+
97+
console.log('Prompting the agent');
98+
9199
//this will prompt the agent and use the agent's LLM to determine which skill to use
92-
const promptResult = await agent.prompt('What is bitcoin Proof-of-Work ?');
100+
const promptStream = await agent.prompt('What is bitcoin Proof-of-Work ?').stream();
93101
//the response comes back in natural language
94-
console.log(promptResult);
102+
console.log('\n');
103+
promptStream.on(TLLMEvent.Content, (content) => {
104+
process.stdout.write(content);
105+
});
95106
}
96107

97108
main();

0 commit comments

Comments
 (0)