@ultimat3/ai 31.50.0 → 31.52.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/README.md +5 -0
- package/package.json +11 -11
- package/src/anthropic-provider.ts +5 -0
- package/src/openai-provider.ts +6 -1
package/README.md
CHANGED
|
@@ -70,6 +70,11 @@ const answer = await ai.scope(budgetKeysFor(actor), async () => {
|
|
|
70
70
|
| `openAiProvider({ baseUrl, models, apiKey, auth? })` | the OpenAI chat-completions format | OpenAI, Azure, vLLM, Ollama, LiteLLM, a company gateway — [below](#the-openai-format--azure-vllm-ollama-your-own-gateway) |
|
|
71
71
|
| your own `Provider` | anything | `{ name, models, generate, stream }` — the same contract both adapters implement |
|
|
72
72
|
|
|
73
|
+
Both shipped providers send through the app-wide egress proxy (`outbound.proxy` in `app.config.ts`)
|
|
74
|
+
when one is declared — asked per request with `ambientProxyFor` and passed to `fetch` as
|
|
75
|
+
`init.proxy` — and dial direct for a `baseUrl` on loopback or an `outbound.direct` host (a sidecar
|
|
76
|
+
gateway, a local Ollama). [Outbound HTTP](https://github.com/developerz-ai/ultimate/wiki/Outbound-HTTP).
|
|
77
|
+
|
|
73
78
|
Peers: neither adapter is the default, each serves exactly the `models` list the app hands it (an
|
|
74
79
|
empty one is `X_AI_REQUEST_INVALID` at construction), and the gateway routes a model to the first
|
|
75
80
|
provider whose `models` lists it.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/ai",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.52.0",
|
|
4
4
|
"description": "LLM gateway, versioned prompts, evals as tests, embeddings, hybrid vector search, RAG",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
"test": "bun test"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@ultimat3/action": "31.
|
|
49
|
-
"@ultimat3/cache": "31.
|
|
50
|
-
"@ultimat3/core": "31.
|
|
51
|
-
"@ultimat3/db": "31.
|
|
52
|
-
"@ultimat3/http": "31.
|
|
53
|
-
"@ultimat3/jobs": "31.
|
|
54
|
-
"@ultimat3/money": "31.
|
|
55
|
-
"@ultimat3/schema": "31.
|
|
56
|
-
"@ultimat3/time": "31.
|
|
48
|
+
"@ultimat3/action": "31.52.0",
|
|
49
|
+
"@ultimat3/cache": "31.52.0",
|
|
50
|
+
"@ultimat3/core": "31.52.0",
|
|
51
|
+
"@ultimat3/db": "31.52.0",
|
|
52
|
+
"@ultimat3/http": "31.52.0",
|
|
53
|
+
"@ultimat3/jobs": "31.52.0",
|
|
54
|
+
"@ultimat3/money": "31.52.0",
|
|
55
|
+
"@ultimat3/schema": "31.52.0",
|
|
56
|
+
"@ultimat3/time": "31.52.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@ultimat3/policy": "31.
|
|
59
|
+
"@ultimat3/policy": "31.52.0"
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// the one `fetch` it sends, and `parseMessage` for a non-streamed answer. The shared shapes are
|
|
3
3
|
// ./provider's; ./models owns the per-model rules and ./wire the streamed response half.
|
|
4
4
|
|
|
5
|
+
import { ambientProxyFor } from '@ultimat3/core/outbound';
|
|
5
6
|
import { readAnswerBody } from './answer-body';
|
|
6
7
|
import { anthropicTools } from './anthropic-strict';
|
|
7
8
|
import { billedCall } from './billed';
|
|
@@ -233,6 +234,9 @@ export class AnthropicProvider implements Provider {
|
|
|
233
234
|
}
|
|
234
235
|
const doFetch: AiFetch = this.config.fetch ?? fetch;
|
|
235
236
|
const url = `${this.config.baseUrl ?? 'https://api.anthropic.com'}/v1/messages`;
|
|
237
|
+
// Not `outbound()` (in-band stream errors, the gateway's own retries), so the app-wide egress
|
|
238
|
+
// proxy is asked here: an egress-locked deploy reaches the model, a loopback one stays direct.
|
|
239
|
+
const proxy = ambientProxyFor(url);
|
|
236
240
|
// From here an abort costs the prompt (`stream-bill.ts`): the request is on its way.
|
|
237
241
|
trackSent(request, model);
|
|
238
242
|
const response = await doFetch(url, {
|
|
@@ -247,6 +251,7 @@ export class AnthropicProvider implements Provider {
|
|
|
247
251
|
// Attached only when the caller has one: `exactOptionalPropertyTypes`, and an explicit
|
|
248
252
|
// `signal: undefined` is a different value to some fetch implementations.
|
|
249
253
|
...(signal === undefined ? {} : { signal }),
|
|
254
|
+
...(proxy === undefined ? {} : { proxy }),
|
|
250
255
|
});
|
|
251
256
|
if (!response.ok) {
|
|
252
257
|
// An overflow or the transport's code — `context-overflow.ts` decides, for both wires.
|
package/src/openai-provider.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import type { Secret } from '@ultimat3/core';
|
|
11
11
|
import { isSecret, revealSecret, trimTrailingSlashes } from '@ultimat3/core';
|
|
12
|
+
import { ambientProxyFor } from '@ultimat3/core/outbound';
|
|
12
13
|
import { readAnswerBody } from './answer-body';
|
|
13
14
|
import { billedCall } from './billed';
|
|
14
15
|
import { providerFailure } from './context-overflow';
|
|
@@ -237,9 +238,12 @@ class OpenAiProvider implements Provider {
|
|
|
237
238
|
const { signal } = request;
|
|
238
239
|
const apiKey = this.apiKey();
|
|
239
240
|
const doFetch: AiFetch = this.config.fetch ?? fetch;
|
|
241
|
+
const url = this.url();
|
|
242
|
+
// The app-wide egress proxy, asked as `anthropic-provider.ts` asks it: this is not `outbound()`.
|
|
243
|
+
const proxy = ambientProxyFor(url);
|
|
240
244
|
// From here an abort costs the prompt (`stream-bill.ts`): the request is on its way.
|
|
241
245
|
trackSent(request, model);
|
|
242
|
-
const response = await doFetch(
|
|
246
|
+
const response = await doFetch(url, {
|
|
243
247
|
method: 'POST',
|
|
244
248
|
headers: {
|
|
245
249
|
...(this.config.auth === 'api-key'
|
|
@@ -256,6 +260,7 @@ class OpenAiProvider implements Provider {
|
|
|
256
260
|
body: JSON.stringify(body),
|
|
257
261
|
// Attached only when the caller has one — same rule, same reason, as the Anthropic half.
|
|
258
262
|
...(signal === undefined ? {} : { signal }),
|
|
263
|
+
...(proxy === undefined ? {} : { proxy }),
|
|
259
264
|
});
|
|
260
265
|
if (!response.ok) {
|
|
261
266
|
// An overflow or the transport's code — `context-overflow.ts` decides, for both wires.
|