@easynet/agent-model 1.0.77 → 1.0.79
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 +52 -49
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,76 +1,79 @@
|
|
|
1
1
|
# @easynet/agent-model
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Introduction
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`@easynet/agent-model` initializes the framework model layer from `model.yaml` and registers the configured chat model, embedding model, and optional VLM model into the default `AgentContext`.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import { AgentContextTokens, getDefaultAgentContext } from "@easynet/agent-common";
|
|
9
|
-
import { createAgentModel } from "@easynet/agent-model";
|
|
7
|
+
## API Reference
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
console.log(result.content);
|
|
15
|
-
```
|
|
9
|
+
| API | What it does | Minimal usage |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `createAgentModel` | Load model config and register models into `AgentContext`. | `await createAgentModel({ configPath: "./model.yaml" })` |
|
|
16
12
|
|
|
17
|
-
##
|
|
13
|
+
## Usage
|
|
18
14
|
|
|
19
|
-
`model.yaml
|
|
15
|
+
Create `model.yaml`:
|
|
20
16
|
|
|
21
17
|
```yaml
|
|
22
18
|
llm:
|
|
23
|
-
# 默认使用 small 这个实例
|
|
24
19
|
default: small
|
|
25
|
-
|
|
26
|
-
# 可按需保留 strong;不需要就删掉
|
|
27
|
-
strong:
|
|
28
|
-
provider: openai
|
|
29
|
-
base_url: ${LLM_BASE_URL}
|
|
30
|
-
model: ${LLM_MODEL}
|
|
31
|
-
|
|
32
|
-
# 本地 Ollama 最常见配置
|
|
33
20
|
small:
|
|
34
21
|
provider: openai
|
|
35
22
|
base_url: http://localhost:11434/v1
|
|
36
23
|
model: qwen3:0.6b
|
|
37
|
-
|
|
38
|
-
embed:
|
|
39
|
-
default: gemma
|
|
40
|
-
gemma:
|
|
41
|
-
provider: openai
|
|
42
|
-
base_url: https://ollama-nvidia-8g-2.easynet.world/v1
|
|
43
|
-
model: embeddinggemma:latest
|
|
44
|
-
apiKey: ollama
|
|
45
|
-
|
|
46
|
-
runtime:
|
|
47
|
-
check_connectivity: false
|
|
48
24
|
```
|
|
49
25
|
|
|
50
|
-
|
|
26
|
+
Initialize the model layer:
|
|
51
27
|
|
|
52
28
|
```ts
|
|
53
|
-
import { AgentContextTokens, getDefaultAgentContext } from "@easynet/agent-common";
|
|
54
29
|
import { createAgentModel } from "@easynet/agent-model";
|
|
55
30
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
31
|
+
await createAgentModel({
|
|
32
|
+
configPath: "./model.yaml",
|
|
33
|
+
});
|
|
34
|
+
```
|
|
60
35
|
|
|
61
|
-
|
|
62
|
-
const response = await llm.invoke("请用一句话介绍你自己。");
|
|
36
|
+
### YAML config
|
|
63
37
|
|
|
64
|
-
|
|
65
|
-
console.log(response.content);
|
|
66
|
-
}
|
|
38
|
+
Example `model.yaml`:
|
|
67
39
|
|
|
68
|
-
|
|
40
|
+
```yaml
|
|
41
|
+
apiVersion: easynet.world/v1
|
|
42
|
+
kind: ModelConfig
|
|
43
|
+
metadata:
|
|
44
|
+
name: agent-model-default
|
|
45
|
+
spec:
|
|
46
|
+
llm:
|
|
47
|
+
default: small
|
|
48
|
+
small:
|
|
49
|
+
provider: openai
|
|
50
|
+
base_url: http://localhost:11434/v1
|
|
51
|
+
model: qwen3:0.6b
|
|
52
|
+
|
|
53
|
+
embed:
|
|
54
|
+
default: local
|
|
55
|
+
local:
|
|
56
|
+
provider: openai
|
|
57
|
+
base_url: http://localhost:11434/v1
|
|
58
|
+
model: qwen3-embedding:0.6b
|
|
59
|
+
apiKey: not-needed
|
|
60
|
+
|
|
61
|
+
vlm:
|
|
62
|
+
default: glm_ocr
|
|
63
|
+
glm_ocr:
|
|
64
|
+
type: image
|
|
65
|
+
provider: openai
|
|
66
|
+
base_url: http://localhost:11434/v1
|
|
67
|
+
model: glm-ocr:q8_0
|
|
68
|
+
apiKey: not-needed
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
Explanation:
|
|
72
72
|
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
73
|
+
- `spec.llm`: chat model definitions.
|
|
74
|
+
- `spec.llm.default`: the default LLM key to use.
|
|
75
|
+
- `spec.llm.<name>.provider`: provider type, usually `openai` for OpenAI-compatible APIs.
|
|
76
|
+
- `spec.llm.<name>.base_url`: base URL of the model service.
|
|
77
|
+
- `spec.llm.<name>.model`: model name sent to the provider.
|
|
78
|
+
- `spec.embed`: embedding model definitions used for retrieval or semantic search.
|
|
79
|
+
- `spec.vlm`: optional vision model definitions for image-capable workflows.
|