llmjs2 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -0
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -44,6 +44,60 @@ const response = await completion({
|
|
|
44
44
|
console.log(response);
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
## generate()
|
|
48
|
+
|
|
49
|
+
The library also exposes `generate()` for prompt-based flows with optional images, references, system instructions, and tools.
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import { generate } from 'llmjs2';
|
|
53
|
+
|
|
54
|
+
const response = await generate({
|
|
55
|
+
model: 'ollama/llama3',
|
|
56
|
+
userPrompt: 'Describe this picture.',
|
|
57
|
+
images: ['https://example.com/image.png'],
|
|
58
|
+
references: ['Some reference text about the image.'],
|
|
59
|
+
systemPrompt: 'You are a visual assistant.',
|
|
60
|
+
tools: [
|
|
61
|
+
{
|
|
62
|
+
name: 'get_weather',
|
|
63
|
+
description: 'Get the current weather for a location',
|
|
64
|
+
parameters: {
|
|
65
|
+
location: { type: 'string', required: true, description: 'City and state' },
|
|
66
|
+
},
|
|
67
|
+
handler: ({ location }) => `Weather in ${location}: Sunny`,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
console.log(response);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
You can also pass a message history directly:
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
import { generate } from 'llmjs2';
|
|
79
|
+
|
|
80
|
+
const response = await generate({
|
|
81
|
+
model: 'ollama/llama3',
|
|
82
|
+
messages: [
|
|
83
|
+
{ role: 'system', content: 'You are a helpful assistant.' },
|
|
84
|
+
{ role: 'user', content: 'Use a tool if needed.' },
|
|
85
|
+
],
|
|
86
|
+
tools: [
|
|
87
|
+
{
|
|
88
|
+
name: 'get_weather',
|
|
89
|
+
description: 'Get the current weather for a location',
|
|
90
|
+
parameters: {
|
|
91
|
+
location: { type: 'string', required: true, description: 'City and state' },
|
|
92
|
+
},
|
|
93
|
+
handler: ({ location }) => `Weather in ${location}: Sunny`,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
console.log(response);
|
|
99
|
+
```
|
|
100
|
+
|
|
47
101
|
## Configuration
|
|
48
102
|
|
|
49
103
|
The library resolves connection details in this order:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "llmjs2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Minimal zero-dependency Node.js client for Ollama and Ollama Cloud.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"types": "index.d.ts",
|
|
13
|
-
"keywords": [
|
|
13
|
+
"keywords": [
|
|
14
|
+
"llm",
|
|
15
|
+
"ollama",
|
|
16
|
+
"node",
|
|
17
|
+
"ai",
|
|
18
|
+
"client",
|
|
19
|
+
"llmjs",
|
|
20
|
+
"llmjs2"
|
|
21
|
+
],
|
|
14
22
|
"license": "MIT"
|
|
15
23
|
}
|