Skip to content

Commit

Permalink
feat(agent): update SQL tool example
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Dvorak <[email protected]>
  • Loading branch information
Tomas2D committed Oct 11, 2024
1 parent 67c3270 commit 325e1ed
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions examples/agents/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,34 @@ import { GroqChatLLM } from "bee-agent-framework/adapters/groq/chat";
import { SQLTool } from "bee-agent-framework/tools/database/sql";
import { FrameworkError } from "bee-agent-framework/errors";
import { UnconstrainedMemory } from "bee-agent-framework/memory/unconstrainedMemory";
import fs from "node:fs";
import * as path from "node:path";
import os from "node:os";

const llm = new GroqChatLLM({
modelId: "llama3-70b-8192",
modelId: "llama-3.1-70b-versatile",
parameters: {
temperature: 0,
max_tokens: 8192,
},
});

const sqlTool = new SQLTool({
provider: "sqlite",
connection: {
dialect: "sqlite",
storage: "chinook.sqlite",
logging: false,
storage: await fetch(
"https://github.com/lerocha/chinook-database/releases/download/v1.4.5/chinook_sqlite.sqlite",
).then(async (response) => {
if (!response.ok) {
throw new Error("Failed to download Chinook database!");
}

const dbPath = path.join(os.tmpdir(), "bee_chinook.sqlite");
const data = Buffer.from(await response.arrayBuffer());
await fs.promises.writeFile(dbPath, data);
return dbPath;
}),
},
});

Expand Down Expand Up @@ -59,5 +72,4 @@ try {
console.error(FrameworkError.ensure(error).dump());
} finally {
await sqlTool.destroy();
process.exit(0);
}

0 comments on commit 325e1ed

Please sign in to comment.