Mixtral ReAct agent

This commit is contained in:
Laurie Voss
2024-05-08 17:05:55 -07:00
parent c052b763b7
commit cd4c7bcac9
3 changed files with 3363 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
import {
Ollama,
FunctionTool,
ReActAgent,
Settings
} from "llamaindex"
import 'dotenv/config'
Settings.llm = new Ollama({
model: "mixtral:8x7b",
temperature: 0.1
});
/*
Set up logging so we can see the work in progress.
Available events:
llm-start
llm-end
agent-start
agent-end
llm-tool-call
llm-tool-result
*/
Settings.callbackManager.on("llm-tool-call", (event) => {
console.log(event.detail.payload)
})
Settings.callbackManager.on("llm-tool-result", (event) => {
console.log(event.detail.payload)
})
const sumNumbers = ({a, b}) => {
return `${a + b}`;
}
const tools = [
FunctionTool.from(
sumNumbers,
{
name: "sumNumbers",
description: "Use this function to sum two numbers",
parameters: {
type: "object",
properties: {
a: {
type: "number",
description: "First number to sum"
},
b: {
type: "number",
description: "Second number to sum"
},
},
required: ["a", "b"]
}
}
)
]
const agent = new ReActAgent({tools})
let response = await agent.chat({
message: "Add 101 and 303",
})
console.log(response)
+3292
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -0,0 +1,6 @@
{
"dependencies": {
"dotenv": "^16.4.5",
"llamaindex": "^0.3.1"
}
}