@astack-tech/integrations 0.2.0-beta.11 → 0.2.0-beta.12
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/CHANGELOG.md +6 -0
- package/README.md +41 -30
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @astack-tech/integrations
|
|
2
2
|
|
|
3
|
+
## 0.2.0-beta.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a395d53: The READMEs lead with the model you choose: `OpenAICompatible` for OpenAI, Qwen, local models through Ollama and any other OpenAI-compatible API, `Deepseek` as a preset, and any object with `chatCompletion()` for everything else.
|
|
8
|
+
|
|
3
9
|
## 0.2.0-beta.11
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -19,28 +19,45 @@ npm install @astack-tech/integrations @astack-tech/core
|
|
|
19
19
|
```typescript
|
|
20
20
|
import { ModelProvider } from '@astack-tech/integrations';
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
// OpenAI, or any API that speaks the OpenAI chat completions protocol
|
|
23
|
+
const model = new ModelProvider.OpenAICompatible({
|
|
24
|
+
apiKey: process.env['OPENAI_API_KEY'] ?? '',
|
|
25
|
+
model: 'gpt-4o-mini',
|
|
26
|
+
});
|
|
23
27
|
|
|
24
28
|
const text = await model.run('What is flow-based programming?');
|
|
25
29
|
const reply = await model.chatCompletion([{ role: 'user', content: 'Hello' }]);
|
|
26
30
|
```
|
|
27
31
|
|
|
28
|
-
`
|
|
32
|
+
`OpenAICompatible` and `Deepseek` are also available from the subpath: `import { OpenAICompatible, Deepseek } from '@astack-tech/integrations/model-provider'`.
|
|
29
33
|
|
|
30
|
-
##
|
|
34
|
+
## Choose a model
|
|
35
|
+
|
|
36
|
+
| Model | Provider |
|
|
37
|
+
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
38
|
+
| OpenAI | `new ModelProvider.OpenAICompatible({ apiKey, model: 'gpt-4o-mini' })` |
|
|
39
|
+
| DeepSeek | `new ModelProvider.Deepseek({ apiKey })` |
|
|
40
|
+
| Qwen, Moonshot and other OpenAI-compatible APIs | `new ModelProvider.OpenAICompatible({ apiKey, baseURL, model })` |
|
|
41
|
+
| Local models through Ollama or vLLM | `new ModelProvider.OpenAICompatible({ apiKey: 'ollama', baseURL: 'http://localhost:11434/v1', model: 'llama3.1' })` |
|
|
42
|
+
| Any other API | Implement the `ModelProvider` interface of `@astack-tech/components` (`chatCompletion(messages)`) |
|
|
43
|
+
|
|
44
|
+
Every provider satisfies the `ModelProvider` interface of `@astack-tech/components`, so it can drive `Agent` and `StreamingAgent` directly.
|
|
45
|
+
|
|
46
|
+
## OpenAICompatible
|
|
31
47
|
|
|
32
|
-
|
|
48
|
+
Calls any API that speaks the OpenAI chat completions protocol through the official `openai` client: OpenAI and the compatible endpoints of DeepSeek, Qwen, Moonshot, Ollama, vLLM and others. Tool calling and streaming depend on what the endpoint supports.
|
|
33
49
|
|
|
34
|
-
| Option | Default
|
|
35
|
-
| -------------------- |
|
|
36
|
-
| `apiKey` | —
|
|
37
|
-
| `model` |
|
|
38
|
-
| `baseURL` | `https://api.
|
|
39
|
-
| `
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
50
|
+
| Option | Default | Description |
|
|
51
|
+
| -------------------- | --------------------------- | -------------------------------------------------------------------- |
|
|
52
|
+
| `apiKey` | — | API key of the provider |
|
|
53
|
+
| `model` | — | Model name (required) |
|
|
54
|
+
| `baseURL` | `https://api.openai.com/v1` | API base URL |
|
|
55
|
+
| `name` | `The model API` | Provider name in errors and logs |
|
|
56
|
+
| `temperature` | `0.7` | Sampling temperature |
|
|
57
|
+
| `maxTokens`, `topP` | not sent | Optional sampling limits |
|
|
58
|
+
| `systemPrompt` | none | Added before every request |
|
|
59
|
+
| `rawTools` / `tools` | none | Tools as `{ name, description, parameters }` or in the OpenAI format |
|
|
60
|
+
| `verbose` | `false` | Log API errors to the console |
|
|
44
61
|
|
|
45
62
|
| Method | Returns |
|
|
46
63
|
| --------------------------------------------------------------- | -------------------------------------------------------------- |
|
|
@@ -56,33 +73,27 @@ Messages are checked before the request: the role must be `system`, `user`, `ass
|
|
|
56
73
|
| `prompt` | `completion` |
|
|
57
74
|
| `messages` | `message` |
|
|
58
75
|
|
|
59
|
-
|
|
76
|
+
A value of the wrong type on an input port rejects the pipeline run with a `TypeError` before the API is called.
|
|
60
77
|
|
|
61
|
-
##
|
|
78
|
+
## Deepseek
|
|
62
79
|
|
|
63
|
-
|
|
80
|
+
`OpenAICompatible` with DeepSeek's defaults. Methods, ports and the other options are the same.
|
|
64
81
|
|
|
65
82
|
```typescript
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const model = new ModelProvider.OpenAICompatible({
|
|
69
|
-
apiKey: process.env['OPENAI_API_KEY'] ?? '',
|
|
70
|
-
model: 'gpt-4o-mini',
|
|
71
|
-
});
|
|
83
|
+
const model = new ModelProvider.Deepseek({ apiKey: process.env['DEEPSEEK_API_KEY'] ?? '' });
|
|
72
84
|
```
|
|
73
85
|
|
|
74
|
-
| Option | Default
|
|
75
|
-
| --------- |
|
|
76
|
-
| `apiKey` | —
|
|
77
|
-
| `model` |
|
|
78
|
-
| `baseURL` | `https://api.
|
|
79
|
-
| `name` | `The model API` | Provider name in errors and logs |
|
|
86
|
+
| Option | Default | Description |
|
|
87
|
+
| --------- | ----------------------------- | ---------------- |
|
|
88
|
+
| `apiKey` | — | DeepSeek API key |
|
|
89
|
+
| `model` | `deepseek-chat` | Model name |
|
|
90
|
+
| `baseURL` | `https://api.deepseek.com/v1` | API base URL |
|
|
80
91
|
|
|
81
92
|
## Learn more
|
|
82
93
|
|
|
83
94
|
- [API reference](https://astack.tech/docs/api/integrations): every export, generated from the source
|
|
84
95
|
- [Model providers](https://astack.tech/docs/model-providers), including how to write your own
|
|
85
|
-
-
|
|
96
|
+
- Examples: [chat](https://astack.tech/examples/chat), [custom model](https://astack.tech/examples/custom-model)
|
|
86
97
|
|
|
87
98
|
## The AStack packages
|
|
88
99
|
|
package/package.json
CHANGED