Skip to content

Commit

Permalink
Update examples to use local LM and upgrade dependencies
Browse files Browse the repository at this point in the history
- updated discover.ts to use brain.discoverLocal()
- added new file expert_for_model.ts with example usage of local LM
- updated package.json to reflect dependency changes
  • Loading branch information
synw committed May 30, 2024
1 parent 3a474ae commit 61a6c34
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/discover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const prompt = "Give me a short list of the planets names in the solar system";

async function initAgent() {
const brain = useAgentBrain();
await brain.discoverExperts();
await brain.discoverLocal();
console.log("Experts:", brain.experts.map(e => e.name));
console.log("Current expert:", brain.ex.name);
brain.ex.setOnToken((t) => process.stdout.write(t));
Expand Down
25 changes: 25 additions & 0 deletions examples/expert_for_model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env node
import { useAgentBrain, useLmExpert } from "@agent-smith/brain";

// run a local Ollama instance before running this example
// node --loader ts-node/esm expert_for_model.ts

const ex = useLmExpert({
name: "default",
localLm: "ollama",
});
// add more experts ...

const brain = useAgentBrain([ex]);

async function main() {
// auto discover loc
console.log("Auto discovering brain backend ...");
await brain.discover(true);
await brain.expertsForModelsInfo()
console.log("Experts for model:", brain.expertsForModels)
}

(async () => {
await main();
})();
4 changes: 2 additions & 2 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
},
"dependencies": {
"@agent-smith/body": "^0.0.8",
"@agent-smith/brain": "^0.0.13",
"@agent-smith/brain": "^0.0.16",
"@agent-smith/smem": "^0.0.2",
"@xenova/transformers": "^2.17.1",
"vectordb": "^0.4.20"
"vectordb": "^0.5.0"
},
"devDependencies": {
"@locallm/types": "^0.0.16",
Expand Down

0 comments on commit 61a6c34

Please sign in to comment.