@auto-engineer/model-factory 1.148.0 → 1.150.0
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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +3 -3
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +33 -0
- package/README.md +171 -0
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @auto-engineer/model-factory@1.
|
|
2
|
+
> @auto-engineer/model-factory@1.150.0 build /home/runner/work/auto-engineer/auto-engineer/packages/model-factory
|
|
3
3
|
> tsc && tsx ../../scripts/fix-esm-imports.ts
|
|
4
4
|
|
|
5
5
|
Fixed ESM imports in dist/
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @auto-engineer/model-factory@1.
|
|
2
|
+
> @auto-engineer/model-factory@1.149.0 test /home/runner/work/auto-engineer/auto-engineer/packages/model-factory
|
|
3
3
|
> vitest run --reporter=dot
|
|
4
4
|
|
|
5
5
|
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
11
11
|
[2m Tests [22m [1m[32m5 passed[39m[22m[90m (5)[39m
|
|
12
|
-
[2m Start at [22m
|
|
13
|
-
[2m Duration [22m
|
|
12
|
+
[2m Start at [22m 12:20:36
|
|
13
|
+
[2m Duration [22m 1.83s[2m (transform 264ms, setup 0ms, collect 212ms, tests 121ms, environment 0ms, prepare 565ms)[22m
|
|
14
14
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @auto-engineer/model-factory
|
|
2
2
|
|
|
3
|
+
## 1.150.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`a502d47`](https://github.com/BeOnAuto/auto-engineer/commit/a502d472df528a1c5d53905898220c2a3a49d8a5) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
8
|
+
|
|
9
|
+
- [`c96a70e`](https://github.com/BeOnAuto/auto-engineer/commit/c96a70e49f9f64213450d0b9840bc9a8b2b1d77d) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
10
|
+
|
|
11
|
+
- [`4343bca`](https://github.com/BeOnAuto/auto-engineer/commit/4343bcaa2576703ae578fd9b7f5ec5b9776702a9) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
12
|
+
|
|
13
|
+
- [`28ffce9`](https://github.com/BeOnAuto/auto-engineer/commit/28ffce9c8b95f0c3ca61728bd1f667fa9416d461) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
14
|
+
|
|
15
|
+
- [`3fd5dbf`](https://github.com/BeOnAuto/auto-engineer/commit/3fd5dbfbfb4f7a5fe71ae53105b31a1b0f30f911) Thanks [@osamanar](https://github.com/osamanar)! -
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`41f3df3`](https://github.com/BeOnAuto/auto-engineer/commit/41f3df3025445ba92208c2b007b8e29a40489309) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **global**: version packages
|
|
20
|
+
- **global**: major refresh to all the docs
|
|
21
|
+
|
|
22
|
+
## 1.149.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- [`e1eebbd`](https://github.com/BeOnAuto/auto-engineer/commit/e1eebbdf4f209780e790094d2e6887c4fa809f98) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **server-generator-apollo-emmett**: add Given state ref hints to state.ts.ejs
|
|
27
|
+
- **server-generator-apollo-emmett**: context-aware nonCommandField instructions
|
|
28
|
+
- **server-generator-apollo-emmett**: add state context instruction
|
|
29
|
+
- **server-generator-apollo-emmett**: extract shared template helpers
|
|
30
|
+
- **server-generator-apollo-emmett**: filter state refs from hasGivenEvents in decide.ts.ejs
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- [`d38c81e`](https://github.com/BeOnAuto/auto-engineer/commit/d38c81e7bb442a39626564cf4f6d8d55b60d0a38) Thanks [@SamHatoum](https://github.com/SamHatoum)! -
|
|
35
|
+
|
|
3
36
|
## 1.148.0
|
|
4
37
|
|
|
5
38
|
### Minor Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# @auto-engineer/model-factory
|
|
2
|
+
|
|
3
|
+
Creates a Vercel AI SDK `LanguageModel` from environment variables, connecting to any OpenAI-compatible provider.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
Without `model-factory`, you would have to hard-code provider setup logic (provider name, base URL, API key, model ID) in every package that needs an LLM. This module centralises that configuration into four environment variables and returns a ready-to-use `LanguageModel` instance.
|
|
10
|
+
|
|
11
|
+
The design is deliberately minimal: one function, four env vars, no config files. Any OpenAI-compatible API gateway (LiteLLM, OpenRouter, a direct provider endpoint) works without code changes.
|
|
12
|
+
|
|
13
|
+
## Key Concepts
|
|
14
|
+
|
|
15
|
+
- **OpenAI-compatible provider** -- The factory uses `@ai-sdk/openai-compatible` under the hood, so any provider that exposes an OpenAI-shaped chat completions API is supported.
|
|
16
|
+
- **Environment-driven configuration** -- All connection details come from `CUSTOM_PROVIDER_*` environment variables. No constructor arguments, no config objects.
|
|
17
|
+
- **Vercel AI SDK integration** -- The returned object satisfies the AI SDK `LanguageModel` interface and can be passed directly to `generateText`, `streamText`, and other AI SDK functions.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm add @auto-engineer/model-factory
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Peer dependency:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm add ai
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
Set the required environment variables:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
export CUSTOM_PROVIDER_NAME="litellm"
|
|
41
|
+
export CUSTOM_PROVIDER_BASE_URL="https://gateway.example.com/v1"
|
|
42
|
+
export CUSTOM_PROVIDER_API_KEY="sk-..."
|
|
43
|
+
export CUSTOM_PROVIDER_DEFAULT_MODEL="xai/grok-code-fast-1"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Then create and use a model:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { createModelFromEnv } from '@auto-engineer/model-factory';
|
|
50
|
+
import { generateText } from 'ai';
|
|
51
|
+
|
|
52
|
+
const model = createModelFromEnv();
|
|
53
|
+
|
|
54
|
+
const { text } = await generateText({
|
|
55
|
+
model,
|
|
56
|
+
prompt: 'Explain monads in one sentence.',
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## How-to Guides
|
|
63
|
+
|
|
64
|
+
### Connect to a different provider
|
|
65
|
+
|
|
66
|
+
Change the environment variables -- no code changes required:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# OpenRouter
|
|
70
|
+
export CUSTOM_PROVIDER_NAME="openrouter"
|
|
71
|
+
export CUSTOM_PROVIDER_BASE_URL="https://openrouter.ai/api/v1"
|
|
72
|
+
export CUSTOM_PROVIDER_API_KEY="sk-or-..."
|
|
73
|
+
export CUSTOM_PROVIDER_DEFAULT_MODEL="anthropic/claude-sonnet-4-20250514"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Use in tests
|
|
77
|
+
|
|
78
|
+
Mock the module or set test-specific env vars before importing:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
process.env.CUSTOM_PROVIDER_NAME = 'test-provider';
|
|
82
|
+
process.env.CUSTOM_PROVIDER_BASE_URL = 'http://localhost:4000/v1';
|
|
83
|
+
process.env.CUSTOM_PROVIDER_API_KEY = 'test-key';
|
|
84
|
+
process.env.CUSTOM_PROVIDER_DEFAULT_MODEL = 'test-model';
|
|
85
|
+
|
|
86
|
+
const { createModelFromEnv } = await import('@auto-engineer/model-factory');
|
|
87
|
+
const model = createModelFromEnv();
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## API Reference
|
|
93
|
+
|
|
94
|
+
### Package Exports
|
|
95
|
+
|
|
96
|
+
| Export | Kind | Description |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| `createModelFromEnv` | Function | Creates a `LanguageModel` from environment variables |
|
|
99
|
+
| `ChatMessage` | Interface | A single chat message with role and content |
|
|
100
|
+
| `ChatTurn` | Interface | A prompt/response pair |
|
|
101
|
+
|
|
102
|
+
### Functions
|
|
103
|
+
|
|
104
|
+
#### `createModelFromEnv()`
|
|
105
|
+
|
|
106
|
+
Creates a Vercel AI SDK `LanguageModel` by reading four required environment variables.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
function createModelFromEnv(): LanguageModel
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Environment variables (all required):**
|
|
113
|
+
|
|
114
|
+
| Variable | Description |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `CUSTOM_PROVIDER_NAME` | Identifier for the provider (e.g. `"litellm"`) |
|
|
117
|
+
| `CUSTOM_PROVIDER_BASE_URL` | Base URL of the OpenAI-compatible API |
|
|
118
|
+
| `CUSTOM_PROVIDER_API_KEY` | API key for authentication |
|
|
119
|
+
| `CUSTOM_PROVIDER_DEFAULT_MODEL` | Model identifier to use (e.g. `"xai/grok-code-fast-1"`) |
|
|
120
|
+
|
|
121
|
+
**Throws:** `Error` if any of the four environment variables is missing or empty.
|
|
122
|
+
|
|
123
|
+
**Returns:** A `LanguageModel` instance backed by the configured provider.
|
|
124
|
+
|
|
125
|
+
### Interfaces
|
|
126
|
+
|
|
127
|
+
#### `ChatMessage`
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
interface ChatMessage {
|
|
131
|
+
role: 'user' | 'assistant';
|
|
132
|
+
content: string;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### `ChatTurn`
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
interface ChatTurn {
|
|
140
|
+
prompt: ChatMessage;
|
|
141
|
+
response: ChatMessage;
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Architecture
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
src/
|
|
151
|
+
index.ts # createModelFromEnv, ChatMessage, ChatTurn
|
|
152
|
+
index.specs.ts # Unit tests
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Dependencies
|
|
156
|
+
|
|
157
|
+
| Package | Purpose |
|
|
158
|
+
|---|---|
|
|
159
|
+
| `@ai-sdk/openai-compatible` | Creates the underlying provider client |
|
|
160
|
+
| `ai` (peer) | Provides the `LanguageModel` type |
|
|
161
|
+
|
|
162
|
+
### Unused direct dependencies
|
|
163
|
+
|
|
164
|
+
The following packages are listed in `dependencies` but are not currently imported in source code. They may be intended for future provider-specific factories:
|
|
165
|
+
|
|
166
|
+
| Package |
|
|
167
|
+
|---|
|
|
168
|
+
| `@ai-sdk/anthropic` |
|
|
169
|
+
| `@ai-sdk/google` |
|
|
170
|
+
| `@ai-sdk/openai` |
|
|
171
|
+
| `@ai-sdk/xai` |
|