forked from i-am-bee/bee-agent-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathollama.ts
42 lines (36 loc) · 920 Bytes
/
ollama.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { OllamaLLM } from "bee-agent-framework/adapters/ollama/llm";
import { OllamaChatLLM } from "bee-agent-framework/adapters/ollama/chat";
import { BaseMessage } from "bee-agent-framework/llms/primitives/message";
{
console.info("===RAW===");
const llm = new OllamaLLM({
modelId: "llama3.1",
parameters: {
num_predict: 10,
stop: ["post"],
},
});
console.info("Meta", await llm.meta());
const response = await llm.generate("Hello world!", {
stream: true,
});
console.info(response.finalResult);
}
{
console.info("===CHAT===");
const llm = new OllamaChatLLM({
modelId: "llama3.1",
parameters: {
num_predict: 10,
temperature: 0,
},
});
console.info("Meta", await llm.meta());
const response = await llm.generate([
BaseMessage.of({
role: "user",
text: "Hello world!",
}),
]);
console.info(response.finalResult);
}