@oh-my-pi/pi-ai 15.9.3 → 15.9.5
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/pi-ai",
|
|
4
|
-
"version": "15.9.
|
|
4
|
+
"version": "15.9.5",
|
|
5
5
|
"description": "Unified LLM API with automatic model discovery and provider configuration",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@bufbuild/protobuf": "^2.12.0",
|
|
42
|
-
"@oh-my-pi/pi-utils": "15.9.
|
|
42
|
+
"@oh-my-pi/pi-utils": "15.9.5",
|
|
43
43
|
"openai": "^6.39.0",
|
|
44
44
|
"partial-json": "^0.1.7",
|
|
45
45
|
"zod": "4.4.3"
|
|
@@ -21,7 +21,13 @@ import type {
|
|
|
21
21
|
} from "../types";
|
|
22
22
|
import { type AbortSourceTracker, createAbortSourceTracker } from "../utils/abort";
|
|
23
23
|
import { AssistantMessageEventStream as EventStreamImpl } from "../utils/event-stream";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
getOpenAIStreamFirstEventTimeoutMs,
|
|
26
|
+
getOpenAIStreamIdleTimeoutMs,
|
|
27
|
+
getStreamFirstEventTimeoutMs,
|
|
28
|
+
getStreamIdleTimeoutMs,
|
|
29
|
+
iterateWithIdleTimeout,
|
|
30
|
+
} from "../utils/idle-iterator";
|
|
25
31
|
import type { BedrockOptions } from "./amazon-bedrock";
|
|
26
32
|
import type { AnthropicOptions } from "./anthropic";
|
|
27
33
|
import type { AzureOpenAIResponsesOptions } from "./azure-openai-responses";
|
|
@@ -167,11 +173,10 @@ function hasFinalResult(
|
|
|
167
173
|
}
|
|
168
174
|
|
|
169
175
|
/**
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
* still trump everything.
|
|
176
|
+
* floor used when neither caller option nor env var pins a value. Generic env
|
|
177
|
+
* vars (`PI_STREAM_FIRST_EVENT_TIMEOUT_MS`, `PI_STREAM_IDLE_TIMEOUT_MS`) still
|
|
178
|
+
* take precedence unless a provider opts into OpenAI-family idle flooring for
|
|
179
|
+
* local backends that users historically tuned with `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS`.
|
|
175
180
|
*/
|
|
176
181
|
interface LazyStreamLimits {
|
|
177
182
|
defaultFirstEventTimeoutMs?: number;
|
|
@@ -181,6 +186,12 @@ interface LazyStreamLimits {
|
|
|
181
186
|
* stream timeouts. Keep the lazy loader from racing it with generic errors.
|
|
182
187
|
*/
|
|
183
188
|
providerHandlesStreamTimeouts?: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Apply OpenAI-family idle timeout precedence in the lazy wrapper. Used by
|
|
191
|
+
* local backends whose users historically tune slow prompt-processing gaps
|
|
192
|
+
* with `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS`.
|
|
193
|
+
*/
|
|
194
|
+
openAIIdleEnvFloorsFirstEvent?: boolean;
|
|
184
195
|
}
|
|
185
196
|
/**
|
|
186
197
|
* Cloud Code Assist (google-gemini-cli / google-antigravity) routinely takes
|
|
@@ -199,6 +210,10 @@ const PROVIDER_HANDLED_STREAM_TIMEOUTS: LazyStreamLimits = {
|
|
|
199
210
|
providerHandlesStreamTimeouts: true,
|
|
200
211
|
};
|
|
201
212
|
|
|
213
|
+
const OPENAI_IDLE_FLOORED_LAZY_STREAM_LIMITS: LazyStreamLimits = {
|
|
214
|
+
openAIIdleEnvFloorsFirstEvent: true,
|
|
215
|
+
};
|
|
216
|
+
|
|
202
217
|
function forwardStream<TApi extends Api>(
|
|
203
218
|
target: EventStreamImpl,
|
|
204
219
|
source: AsyncIterable<AssistantMessageEvent>,
|
|
@@ -212,13 +227,19 @@ function forwardStream<TApi extends Api>(
|
|
|
212
227
|
const providerHandlesStreamTimeouts = limits?.providerHandlesStreamTimeouts === true;
|
|
213
228
|
const idleTimeoutMs = providerHandlesStreamTimeouts
|
|
214
229
|
? undefined
|
|
215
|
-
: (options.streamIdleTimeoutMs ??
|
|
230
|
+
: (options.streamIdleTimeoutMs ??
|
|
231
|
+
(limits?.openAIIdleEnvFloorsFirstEvent
|
|
232
|
+
? getOpenAIStreamIdleTimeoutMs(limits.defaultIdleTimeoutMs)
|
|
233
|
+
: getStreamIdleTimeoutMs(limits?.defaultIdleTimeoutMs)));
|
|
234
|
+
const firstItemTimeoutMs = providerHandlesStreamTimeouts
|
|
235
|
+
? 0
|
|
236
|
+
: (options.streamFirstEventTimeoutMs ??
|
|
237
|
+
(limits?.openAIIdleEnvFloorsFirstEvent
|
|
238
|
+
? getOpenAIStreamFirstEventTimeoutMs(idleTimeoutMs, limits.defaultFirstEventTimeoutMs)
|
|
239
|
+
: getStreamFirstEventTimeoutMs(idleTimeoutMs, limits?.defaultFirstEventTimeoutMs)));
|
|
216
240
|
const watchedSource = iterateWithIdleTimeout(source, {
|
|
217
241
|
idleTimeoutMs,
|
|
218
|
-
firstItemTimeoutMs
|
|
219
|
-
? 0
|
|
220
|
-
: (options.streamFirstEventTimeoutMs ??
|
|
221
|
-
getStreamFirstEventTimeoutMs(idleTimeoutMs, limits?.defaultFirstEventTimeoutMs)),
|
|
242
|
+
firstItemTimeoutMs,
|
|
222
243
|
errorMessage: LAZY_STREAM_IDLE_TIMEOUT_ERROR,
|
|
223
244
|
firstItemErrorMessage: LAZY_STREAM_FIRST_EVENT_TIMEOUT_ERROR,
|
|
224
245
|
onIdle: () => abortTracker.abortLocally(new Error(LAZY_STREAM_IDLE_TIMEOUT_ERROR)),
|
|
@@ -431,6 +452,6 @@ export const streamOpenAIResponses = createLazyStream(
|
|
|
431
452
|
PROVIDER_HANDLED_STREAM_TIMEOUTS,
|
|
432
453
|
);
|
|
433
454
|
export const streamCursor = createLazyStream(loadCursorProviderModule);
|
|
434
|
-
export const streamOllama = createLazyStream(loadOllamaProviderModule);
|
|
455
|
+
export const streamOllama = createLazyStream(loadOllamaProviderModule, OPENAI_IDLE_FLOORED_LAZY_STREAM_LIMITS);
|
|
435
456
|
|
|
436
457
|
export const streamBedrock = createLazyStream(loadBedrockProviderModule);
|