@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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as ServiceAccountJson, A as AuthSpec, a as AuthKindSchema, P as PromptRequest, b as AdapterFactory, c as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-BWsmVtXv.cjs';
2
- export { d as ApiKeyAuth, e as AuthKind, f as AzureOpenAIApiKeyAuth, B as BedrockApiKeyAuth, g as BedrockIamAuth, h as ClientOptions, i as ContentBlock, F as FinishReason, j as FormField, k as FormFieldType, G as GoogleApiKeyAuth, l as GoogleServiceAccountAuth, J as JsonSchema, m as LlmEvent, M as Message, n as ModelCapabilities, o as ModelInfo, R as Role, T as Tool, p as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-BWsmVtXv.cjs';
1
+ import { S as ServiceAccountJson, A as AuthSpec, a as AuthKindSchema, P as PromptRequest, b as AdapterFactory, c as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-BEgQaQIb.cjs';
2
+ export { d as ApiKeyAuth, e as AuthKind, f as AzureOpenAIApiKeyAuth, B as BedrockApiKeyAuth, g as BedrockIamAuth, h as ClientOptions, i as ContentBlock, F as FinishReason, j as FormField, k as FormFieldType, G as GoogleApiKeyAuth, l as GoogleServiceAccountAuth, J as JsonSchema, m as LlmEvent, M as Message, n as ModelCapabilities, o as ModelInfo, R as Role, T as Tool, p as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-BEgQaQIb.cjs';
3
3
 
4
4
  /**
5
5
  * The loose "DB-shape" input accepted by `normalizeAuth`.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as ServiceAccountJson, A as AuthSpec, a as AuthKindSchema, P as PromptRequest, b as AdapterFactory, c as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-BWsmVtXv.js';
2
- export { d as ApiKeyAuth, e as AuthKind, f as AzureOpenAIApiKeyAuth, B as BedrockApiKeyAuth, g as BedrockIamAuth, h as ClientOptions, i as ContentBlock, F as FinishReason, j as FormField, k as FormFieldType, G as GoogleApiKeyAuth, l as GoogleServiceAccountAuth, J as JsonSchema, m as LlmEvent, M as Message, n as ModelCapabilities, o as ModelInfo, R as Role, T as Tool, p as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-BWsmVtXv.js';
1
+ import { S as ServiceAccountJson, A as AuthSpec, a as AuthKindSchema, P as PromptRequest, b as AdapterFactory, c as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-BEgQaQIb.js';
2
+ export { d as ApiKeyAuth, e as AuthKind, f as AzureOpenAIApiKeyAuth, B as BedrockApiKeyAuth, g as BedrockIamAuth, h as ClientOptions, i as ContentBlock, F as FinishReason, j as FormField, k as FormFieldType, G as GoogleApiKeyAuth, l as GoogleServiceAccountAuth, J as JsonSchema, m as LlmEvent, M as Message, n as ModelCapabilities, o as ModelInfo, R as Role, T as Tool, p as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-BEgQaQIb.js';
3
3
 
4
4
  /**
5
5
  * The loose "DB-shape" input accepted by `normalizeAuth`.
package/dist/index.js CHANGED
@@ -85,6 +85,9 @@ async function* streamFromOpenAI(client, req, options) {
85
85
  const param = options.tokensParam ?? (needsMaxCompletionTokens(req.model) ? "max_completion_tokens" : "max_tokens");
86
86
  body[param] = effectiveMaxTokens;
87
87
  }
88
+ const t0 = process.hrtime.bigint();
89
+ let t1;
90
+ let t2;
88
91
  let stream;
89
92
  let responseHeaders;
90
93
  try {
@@ -97,6 +100,7 @@ async function* streamFromOpenAI(client, req, options) {
97
100
  } else {
98
101
  stream = await apiPromise;
99
102
  }
103
+ t1 = process.hrtime.bigint();
100
104
  } catch (err) {
101
105
  if (isAbortError(err)) {
102
106
  yield { type: "end", finishReason: "aborted" };
@@ -128,6 +132,7 @@ async function* streamFromOpenAI(client, req, options) {
128
132
  const delta = choice.delta;
129
133
  const finishReason = choice.finish_reason;
130
134
  if (delta?.content) {
135
+ if (t2 === void 0) t2 = process.hrtime.bigint();
131
136
  yield { type: "token", text: delta.content };
132
137
  }
133
138
  if (delta?.tool_calls) {
@@ -197,6 +202,14 @@ async function* streamFromOpenAI(client, req, options) {
197
202
  endEvent.vendorMetadata = metadata;
198
203
  }
199
204
  }
205
+ if (t1 !== void 0) {
206
+ const t3 = process.hrtime.bigint();
207
+ endEvent.clientTiming = {
208
+ requestToHeadersMs: Number(t1 - t0) / 1e6,
209
+ ...t2 !== void 0 ? { headersToFirstTokenMs: Number(t2 - t1) / 1e6 } : {},
210
+ totalMs: Number(t3 - t0) / 1e6
211
+ };
212
+ }
200
213
  yield endEvent;
201
214
  }
202
215
  function appendOpenAIAssistantToolCall(history, toolCalls) {
@@ -2634,6 +2647,7 @@ var groqManifest = {
2634
2647
  var GROQ_METADATA_EXTRACTOR = makeMetadataExtractor([
2635
2648
  { header: "x-request-id", key: "request_id" },
2636
2649
  { header: "x-groq-region", key: "region" },
2650
+ { header: "openai-processing-ms", key: "processing_ms", numeric: true },
2637
2651
  { header: "x-ratelimit-remaining-requests", key: "requests_remaining", numeric: true },
2638
2652
  { header: "x-ratelimit-remaining-tokens", key: "tokens_remaining", numeric: true }
2639
2653
  ]);