@jambonz/llm 0.5.0 → 0.5.2

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.
@@ -1,4 +1,4 @@
1
- import { b as AdapterFactory, e as AuthKind, A as AuthSpec, L as LlmAdapter, d as ApiKeyAuth, h as ClientOptions, P as PromptRequest, m as LlmEvent, M as Message, p as ToolCallEvent, o as ModelInfo, c as AdapterManifest } from '../types-BWsmVtXv.cjs';
1
+ import { b as AdapterFactory, e as AuthKind, A as AuthSpec, L as LlmAdapter, d as ApiKeyAuth, h as ClientOptions, P as PromptRequest, m as LlmEvent, M as Message, p as ToolCallEvent, o as ModelInfo, c as AdapterManifest } from '../types-BEgQaQIb.cjs';
2
2
 
3
3
  /**
4
4
  * Named scenarios the harness must be able to stage. Each scenario configures
@@ -1,4 +1,4 @@
1
- import { b as AdapterFactory, e as AuthKind, A as AuthSpec, L as LlmAdapter, d as ApiKeyAuth, h as ClientOptions, P as PromptRequest, m as LlmEvent, M as Message, p as ToolCallEvent, o as ModelInfo, c as AdapterManifest } from '../types-BWsmVtXv.js';
1
+ import { b as AdapterFactory, e as AuthKind, A as AuthSpec, L as LlmAdapter, d as ApiKeyAuth, h as ClientOptions, P as PromptRequest, m as LlmEvent, M as Message, p as ToolCallEvent, o as ModelInfo, c as AdapterManifest } from '../types-BEgQaQIb.js';
2
2
 
3
3
  /**
4
4
  * Named scenarios the harness must be able to stage. Each scenario configures
@@ -78,6 +78,9 @@ async function* streamFromOpenAI(client, req, options) {
78
78
  const param = options.tokensParam ?? (needsMaxCompletionTokens(req.model) ? "max_completion_tokens" : "max_tokens");
79
79
  body[param] = effectiveMaxTokens;
80
80
  }
81
+ const t0 = process.hrtime.bigint();
82
+ let t1;
83
+ let t2;
81
84
  let stream;
82
85
  let responseHeaders;
83
86
  try {
@@ -90,6 +93,7 @@ async function* streamFromOpenAI(client, req, options) {
90
93
  } else {
91
94
  stream = await apiPromise;
92
95
  }
96
+ t1 = process.hrtime.bigint();
93
97
  } catch (err) {
94
98
  if (isAbortError(err)) {
95
99
  yield { type: "end", finishReason: "aborted" };
@@ -121,6 +125,7 @@ async function* streamFromOpenAI(client, req, options) {
121
125
  const delta = choice.delta;
122
126
  const finishReason = choice.finish_reason;
123
127
  if (delta?.content) {
128
+ if (t2 === void 0) t2 = process.hrtime.bigint();
124
129
  yield { type: "token", text: delta.content };
125
130
  }
126
131
  if (delta?.tool_calls) {
@@ -190,6 +195,14 @@ async function* streamFromOpenAI(client, req, options) {
190
195
  endEvent.vendorMetadata = metadata;
191
196
  }
192
197
  }
198
+ if (t1 !== void 0) {
199
+ const t3 = process.hrtime.bigint();
200
+ endEvent.clientTiming = {
201
+ requestToHeadersMs: Number(t1 - t0) / 1e6,
202
+ ...t2 !== void 0 ? { headersToFirstTokenMs: Number(t2 - t1) / 1e6 } : {},
203
+ totalMs: Number(t3 - t0) / 1e6
204
+ };
205
+ }
193
206
  yield endEvent;
194
207
  }
195
208
  function appendOpenAIAssistantToolCall(history, toolCalls) {
@@ -2627,6 +2640,7 @@ var groqManifest = {
2627
2640
  var GROQ_METADATA_EXTRACTOR = makeMetadataExtractor([
2628
2641
  { header: "x-request-id", key: "request_id" },
2629
2642
  { header: "x-groq-region", key: "region" },
2643
+ { header: "openai-processing-ms", key: "processing_ms", numeric: true },
2630
2644
  { header: "x-ratelimit-remaining-requests", key: "requests_remaining", numeric: true },
2631
2645
  { header: "x-ratelimit-remaining-tokens", key: "tokens_remaining", numeric: true }
2632
2646
  ]);