@adaptic/lumic-utils 1.0.27 → 1.0.29
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/{apollo-client.client-eo-xgmdi.js → apollo-client.client-BQLzKbg9.js} +4 -4
- package/dist/{apollo-client.client-eo-xgmdi.js.map → apollo-client.client-BQLzKbg9.js.map} +1 -1
- package/dist/{apollo-client.client-DD13VF_T.js → apollo-client.client-C1dwHT2X.js} +3 -3
- package/dist/{apollo-client.client-DD13VF_T.js.map → apollo-client.client-C1dwHT2X.js.map} +1 -1
- package/dist/{apollo-client.server-BxpJcsVI.js → apollo-client.server-Crk0lXFR.js} +3 -3
- package/dist/{apollo-client.server-BxpJcsVI.js.map → apollo-client.server-Crk0lXFR.js.map} +1 -1
- package/dist/{apollo-client.server-2zi9dbLa.js → apollo-client.server-DoI6FK_-.js} +3 -3
- package/dist/{apollo-client.server-2zi9dbLa.js.map → apollo-client.server-DoI6FK_-.js.map} +1 -1
- package/dist/{index-BbwdRyPk.js → index-CV8HlDp8.js} +719 -42
- package/dist/{index-zDK1X6HR.js.map → index-CV8HlDp8.js.map} +1 -1
- package/dist/{index-zDK1X6HR.js → index-CtY-7qjs.js} +720 -41
- package/dist/{index-BbwdRyPk.js.map → index-CtY-7qjs.js.map} +1 -1
- package/dist/{index-BQ1buNZm.js → index-DA066GXe.js} +2 -2
- package/dist/{index-BQ1buNZm.js.map → index-DA066GXe.js.map} +1 -1
- package/dist/{index-CV0UmY0w.js → index-IAFN9E4Q.js} +2 -2
- package/dist/{index-CV0UmY0w.js.map → index-IAFN9E4Q.js.map} +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/test.cjs +1 -1
- package/dist/test.mjs +1 -1
- package/dist/types/config/secrets.d.ts +10 -0
- package/dist/types/functions/__tests__/gpt56-model-release-layer.test.d.ts +1 -0
- package/dist/types/functions/__tests__/llm-openai-responses-routing.test.d.ts +1 -0
- package/dist/types/functions/llm-config.d.ts +8 -6
- package/dist/types/functions/llm-openai.d.ts +125 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/schemas/openai-schemas.d.ts +30 -30
- package/dist/types/schemas/perplexity-schemas.d.ts +40 -40
- package/dist/types/types/openai-types.d.ts +42 -5
- package/dist/types/utils/config.d.ts +12 -1
- package/dist/types/utils/llm-cost-tracker.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-CtY-7qjs.js');
|
|
4
4
|
require('openai');
|
|
5
5
|
require('zod');
|
|
6
6
|
require('@aws-sdk/client-s3');
|
|
@@ -60,9 +60,11 @@ exports.JsonParseError = index.JsonParseError;
|
|
|
60
60
|
exports.LLMCostTracker = index.LLMCostTracker;
|
|
61
61
|
exports.LLMError = index.LLMError;
|
|
62
62
|
exports.LLM_ADVANCED_PROVIDER = index.LLM_ADVANCED_PROVIDER;
|
|
63
|
+
exports.LLM_CRITICAL_PROVIDER = index.LLM_CRITICAL_PROVIDER;
|
|
63
64
|
exports.LLM_DEFAULT_PROVIDER = index.LLM_DEFAULT_PROVIDER;
|
|
64
65
|
exports.LLM_MINI_PROVIDER = index.LLM_MINI_PROVIDER;
|
|
65
66
|
exports.LLM_MODEL_ADVANCED = index.LLM_MODEL_ADVANCED;
|
|
67
|
+
exports.LLM_MODEL_CRITICAL = index.LLM_MODEL_CRITICAL;
|
|
66
68
|
exports.LLM_MODEL_MINI = index.LLM_MODEL_MINI;
|
|
67
69
|
exports.LLM_MODEL_NORMAL = index.LLM_MODEL_NORMAL;
|
|
68
70
|
exports.LLM_NORMAL_PROVIDER = index.LLM_NORMAL_PROVIDER;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { bY as AWSLambdaError, bZ as AWSS3Error, c7 as AWS_LAMBDA_TIMEOUT_MS, c8 as AWS_S3_TIMEOUT_MS, aV as CircuitBreaker, aX as CircuitBreakerOpenError, aW as CircuitBreakerState, aY as DEFAULT_CIRCUIT_BREAKER_CONFIG, ca as GENERIC_FETCH_TIMEOUT_MS, c5 as GOOGLE_SHEETS_TIMEOUT_MS, b_ as GoogleSheetsError, c0 as JsonParseError, b0 as LLMCostTracker, bX as LLMError, bt as LLM_ADVANCED_PROVIDER, bu as LLM_CRITICAL_PROVIDER, bq as LLM_DEFAULT_PROVIDER, br as LLM_MINI_PROVIDER, by as LLM_MODEL_ADVANCED, bz as LLM_MODEL_CRITICAL, bw as LLM_MODEL_MINI, bx as LLM_MODEL_NORMAL, bs as LLM_NORMAL_PROVIDER, bv as LLM_PROVIDER, c6 as LLM_TIMEOUT_MS, bV as LumicError, bn as MODEL_ALIASES, bo as OPENAI_COMPATIBLE_PROVIDERS, c9 as OPENWEATHER_TIMEOUT_MS, c1 as PDFError, c4 as PERPLEXITY_TIMEOUT_MS, bp as PROVIDER_DEFAULT_MODELS, b$ as PerplexityError, be as RATE_LIMIT_PROFILES, c3 as SLACK_TIMEOUT_MS, bj as SUPPORTED_MODELS, bW as SlackError, bd as TokenBucketRateLimiter, c2 as ZipError, bi as checkIntegrationHealth, bU as createSafeValidator, bT as createValidator, b8 as generateCorrelationId, ba as getCorrelationContext, bc as getCorrelationHeaders, b9 as getCorrelationId, b1 as getLLMCostTracker, aM as getLumicLogger, b5 as getMetricsCollector, bl as getModelCapabilities, bm as getModelProvider, bf as getRateLimiter, aR as getSecrets, bJ as googleSheetsValueRangeSchema, bk as isValidModel, bO as lambdaInvokeResponseSchema, l as lumic, bA as makeAnthropicCall, bB as makeOpenAICompatibleCall, bC as openAIChatCompletionSchema, bD as openAIImageResponseSchema, bG as perplexityResponseSchema, aT as requireSecret, bg as resetAllRateLimiters, b3 as resetLLMCostTracker, b6 as resetMetricsCollector, aS as resetSecrets, bN as s3GetObjectSchema, bM as s3ListObjectsSchema, bL as safeValidateGoogleSheetsResponse, bS as safeValidateLambdaResponse, bF as safeValidateOpenAIChatCompletion, bI as safeValidatePerplexityResponse, bQ as safeValidateS3ListObjects, aP as sanitizeAWSAuth, aO as sanitizeError, aN as sanitizeForLog, aQ as sanitizeObject, b2 as setLLMCostTracker, aL as setLumicLogger, b4 as setMetricsCollector, a$ as validateGoogleSheetsRange, bK as validateGoogleSheetsResponse, bR as validateLambdaResponse, bE as validateOpenAIChatCompletion, bH as validatePerplexityResponse, a_ as validateS3Key, bP as validateS3ListObjects, aZ as validateSlackChannel, bb as withCorrelationId, b7 as withMetrics, bh as withRateLimit, aU as withRetry } from './index-CV8HlDp8.js';
|
|
2
2
|
import 'openai';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '@aws-sdk/client-s3';
|
package/dist/test.cjs
CHANGED
package/dist/test.mjs
CHANGED
|
@@ -117,9 +117,11 @@ declare const lumicSecretsSchema: z.ZodObject<{
|
|
|
117
117
|
llmMiniProvider: z.ZodOptional<z.ZodString>;
|
|
118
118
|
llmNormalProvider: z.ZodOptional<z.ZodString>;
|
|
119
119
|
llmAdvancedProvider: z.ZodOptional<z.ZodString>;
|
|
120
|
+
llmCriticalProvider: z.ZodOptional<z.ZodString>;
|
|
120
121
|
llmModelMini: z.ZodOptional<z.ZodString>;
|
|
121
122
|
llmModelNormal: z.ZodOptional<z.ZodString>;
|
|
122
123
|
llmModelAdvanced: z.ZodOptional<z.ZodString>;
|
|
124
|
+
llmModelCritical: z.ZodOptional<z.ZodString>;
|
|
123
125
|
lumicDebug: z.ZodDefault<z.ZodBoolean>;
|
|
124
126
|
allowedUploadPaths: z.ZodDefault<z.ZodString>;
|
|
125
127
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -131,9 +133,11 @@ declare const lumicSecretsSchema: z.ZodObject<{
|
|
|
131
133
|
llmMiniProvider?: string | undefined;
|
|
132
134
|
llmNormalProvider?: string | undefined;
|
|
133
135
|
llmAdvancedProvider?: string | undefined;
|
|
136
|
+
llmCriticalProvider?: string | undefined;
|
|
134
137
|
llmModelMini?: string | undefined;
|
|
135
138
|
llmModelNormal?: string | undefined;
|
|
136
139
|
llmModelAdvanced?: string | undefined;
|
|
140
|
+
llmModelCritical?: string | undefined;
|
|
137
141
|
}, {
|
|
138
142
|
aiModel?: string | undefined;
|
|
139
143
|
perplexityModel?: string | undefined;
|
|
@@ -141,9 +145,11 @@ declare const lumicSecretsSchema: z.ZodObject<{
|
|
|
141
145
|
llmMiniProvider?: string | undefined;
|
|
142
146
|
llmNormalProvider?: string | undefined;
|
|
143
147
|
llmAdvancedProvider?: string | undefined;
|
|
148
|
+
llmCriticalProvider?: string | undefined;
|
|
144
149
|
llmModelMini?: string | undefined;
|
|
145
150
|
llmModelNormal?: string | undefined;
|
|
146
151
|
llmModelAdvanced?: string | undefined;
|
|
152
|
+
llmModelCritical?: string | undefined;
|
|
147
153
|
lumicDebug?: boolean | undefined;
|
|
148
154
|
allowedUploadPaths?: string | undefined;
|
|
149
155
|
}>;
|
|
@@ -200,9 +206,11 @@ declare const lumicSecretsSchema: z.ZodObject<{
|
|
|
200
206
|
llmMiniProvider?: string | undefined;
|
|
201
207
|
llmNormalProvider?: string | undefined;
|
|
202
208
|
llmAdvancedProvider?: string | undefined;
|
|
209
|
+
llmCriticalProvider?: string | undefined;
|
|
203
210
|
llmModelMini?: string | undefined;
|
|
204
211
|
llmModelNormal?: string | undefined;
|
|
205
212
|
llmModelAdvanced?: string | undefined;
|
|
213
|
+
llmModelCritical?: string | undefined;
|
|
206
214
|
};
|
|
207
215
|
}, {
|
|
208
216
|
openai: {
|
|
@@ -255,9 +263,11 @@ declare const lumicSecretsSchema: z.ZodObject<{
|
|
|
255
263
|
llmMiniProvider?: string | undefined;
|
|
256
264
|
llmNormalProvider?: string | undefined;
|
|
257
265
|
llmAdvancedProvider?: string | undefined;
|
|
266
|
+
llmCriticalProvider?: string | undefined;
|
|
258
267
|
llmModelMini?: string | undefined;
|
|
259
268
|
llmModelNormal?: string | undefined;
|
|
260
269
|
llmModelAdvanced?: string | undefined;
|
|
270
|
+
llmModelCritical?: string | undefined;
|
|
261
271
|
lumicDebug?: boolean | undefined;
|
|
262
272
|
allowedUploadPaths?: string | undefined;
|
|
263
273
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,13 +7,15 @@ interface AIModelCosts {
|
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Token costs in USD per token. Last updated
|
|
10
|
+
* Token costs in USD per token. Last updated July 2026.
|
|
11
11
|
*
|
|
12
|
-
* `cacheHitCost` reflects
|
|
13
|
-
* standard input rate per OpenAI's prompt
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
12
|
+
* `cacheHitCost` reflects each model's cached-input billing rate. For most
|
|
13
|
+
* models this is ~50% of the standard input rate (per OpenAI's prompt-caching
|
|
14
|
+
* documentation); the GPT-5.6 reasoning trio discounts cached input more
|
|
15
|
+
* aggressively, to 10% of the input rate. When set, `calculateCost` splits
|
|
16
|
+
* prompt tokens into cached vs non-cached buckets and applies the discount; when
|
|
17
|
+
* omitted, cached tokens are billed at the full input rate (a silent cost
|
|
18
|
+
* overstatement for cache-friendly workloads).
|
|
17
19
|
*/
|
|
18
20
|
export declare const openAiModelCosts: AIModelCosts;
|
|
19
21
|
export declare const anthropicModelCosts: AIModelCosts;
|
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
import { ChatCompletionContentPart } from 'openai/resources/chat';
|
|
2
|
-
import { LLMResponse, LLMOptions, OpenAIResponseFormat } from '../types';
|
|
3
|
-
import { ResponseCreateParamsNonStreaming } from 'openai/resources/responses/responses';
|
|
2
|
+
import { LLMResponse, LLMOptions, OpenAIModel, OpenAIResponseFormat } from '../types';
|
|
3
|
+
import { ResponseCreateParamsNonStreaming, Response as OpenAIResponse } from 'openai/resources/responses/responses';
|
|
4
|
+
/**
|
|
5
|
+
* Provider-agnostic completion shape produced by BOTH OpenAI transports (Chat
|
|
6
|
+
* Completions and Responses). `makeOpenAIChatCompletionCall` builds its
|
|
7
|
+
* {@link LLMResponse} envelope from this shape, so keeping the two producers
|
|
8
|
+
* ({@link createCompletion} and the Responses normalizer) emitting an identical
|
|
9
|
+
* `CompletionResponse` is what guarantees a byte-identical caller-facing result
|
|
10
|
+
* regardless of which OpenAI endpoint served the request.
|
|
11
|
+
*/
|
|
12
|
+
export interface CompletionResponse {
|
|
13
|
+
id: string;
|
|
14
|
+
content: string;
|
|
15
|
+
tool_calls?: Array<{
|
|
16
|
+
id: string;
|
|
17
|
+
type: 'function';
|
|
18
|
+
function: {
|
|
19
|
+
name: string;
|
|
20
|
+
arguments: string;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
usage: {
|
|
24
|
+
prompt_tokens: number;
|
|
25
|
+
completion_tokens: number;
|
|
26
|
+
total_tokens: number;
|
|
27
|
+
cached_tokens: number;
|
|
28
|
+
/**
|
|
29
|
+
* Reasoning tokens billed at the output rate. Always 0 on the Chat
|
|
30
|
+
* Completions path (non-reasoning models). Populated from the Responses
|
|
31
|
+
* API's `output_tokens_details.reasoning_tokens` when a reasoning model is
|
|
32
|
+
* routed to the Responses transport so cost tracking stays accurate.
|
|
33
|
+
*/
|
|
34
|
+
reasoning_tokens: number;
|
|
35
|
+
};
|
|
36
|
+
system_fingerprint?: string;
|
|
37
|
+
service_tier?: string;
|
|
38
|
+
provider: string;
|
|
39
|
+
model: OpenAIModel;
|
|
40
|
+
}
|
|
4
41
|
export declare const DEFAULT_OPTIONS: LLMOptions;
|
|
5
42
|
/**
|
|
6
43
|
* Checks if the given model supports the temperature parameter. Reasoning models (o1*, o3*, o4*) do not support temperature.
|
|
@@ -14,9 +51,95 @@ export declare function supportsTemperature(model: string): boolean;
|
|
|
14
51
|
* @returns True if the model is a reasoning model, false otherwise.
|
|
15
52
|
*/
|
|
16
53
|
export declare function isReasoningModel(model: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Checks whether a model must use the OpenAI Responses API (`/v1/responses`)
|
|
56
|
+
* for function-tool calls rather than Chat Completions (`/v1/chat/completions`).
|
|
57
|
+
*
|
|
58
|
+
* Driven entirely by the {@link ModelCapabilities.requiresResponsesApiForTools}
|
|
59
|
+
* flag in the model registry — there are no hardcoded model-name checks here.
|
|
60
|
+
* Unknown models and models without the flag return `false` (stay on Chat
|
|
61
|
+
* Completions).
|
|
62
|
+
*
|
|
63
|
+
* @param model The model to check.
|
|
64
|
+
* @returns True when tool-bearing calls for this model must be routed to the
|
|
65
|
+
* Responses API, false otherwise.
|
|
66
|
+
*/
|
|
67
|
+
export declare function requiresResponsesApiForTools(model: string): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Builds an OpenAI Responses API request body from the exact same arguments a
|
|
70
|
+
* caller passes to {@link makeOpenAIChatCompletionCall}. This is the request
|
|
71
|
+
* half of the transparent routing layer.
|
|
72
|
+
*
|
|
73
|
+
* The mapping deliberately mirrors {@link createCompletion}'s Chat request
|
|
74
|
+
* one-for-one so request semantics are preserved across transports:
|
|
75
|
+
* - `developerPrompt` (+ context messages + user `content`) → `input` items
|
|
76
|
+
* (chat `tool_calls`/`tool` messages become `function_call`/
|
|
77
|
+
* `function_call_output` items).
|
|
78
|
+
* - chat `tools` → Responses `tools` (function tools only).
|
|
79
|
+
* - `temperature` → `temperature`, gated by {@link supportsTemperature} exactly
|
|
80
|
+
* as the Chat path (dropped for GPT-5.6/o-series reasoning models).
|
|
81
|
+
* - `max_completion_tokens` → `max_output_tokens`.
|
|
82
|
+
* - {@link OpenAIResponseFormat} → `text.format`.
|
|
83
|
+
* - `reasoning_effort` → `reasoning.effort`, clamped per-model via
|
|
84
|
+
* {@link clampReasoningEffort} and gated on {@link isReasoningModel} exactly as
|
|
85
|
+
* the Chat path, so the two transports clamp identically. Only set when the
|
|
86
|
+
* caller explicitly supplies it — parity is preserved for callers (like the
|
|
87
|
+
* engine decision path) that do not.
|
|
88
|
+
*
|
|
89
|
+
* Parameters the Chat path does not forward (`top_p`, `parallel_tool_calls`,
|
|
90
|
+
* `tool_choice`, `metadata`, `store`) are intentionally omitted here too, so the
|
|
91
|
+
* request semantics stay identical to today's production Chat behaviour.
|
|
92
|
+
*
|
|
93
|
+
* @param content The user content (string or multi-modal content parts).
|
|
94
|
+
* @param responseFormat The desired response format.
|
|
95
|
+
* @param options The Chat-Completions-style options bag.
|
|
96
|
+
* @param normalizedModel The normalized model name to target.
|
|
97
|
+
* @returns A ready-to-send non-streaming Responses API request body.
|
|
98
|
+
* @throws Error when a `json_schema` format is requested for an incompatible model.
|
|
99
|
+
*/
|
|
100
|
+
export declare function buildResponsesRequestFromChatOptions(content: string | ChatCompletionContentPart[], responseFormat: OpenAIResponseFormat, options: LLMOptions, normalizedModel: string): ResponseCreateParamsNonStreaming;
|
|
101
|
+
/**
|
|
102
|
+
* Normalizes an OpenAI Responses API result into the internal
|
|
103
|
+
* {@link CompletionResponse} shape. This is the response half of the
|
|
104
|
+
* transparent routing layer and is the single most correctness-critical mapping
|
|
105
|
+
* in this module: the returned `tool_calls` MUST be byte-identical to what the
|
|
106
|
+
* Chat path produces so downstream consumers (notably the engine decision path,
|
|
107
|
+
* which reads `tool_call.function.arguments` as a JSON string) parse it
|
|
108
|
+
* unchanged.
|
|
109
|
+
*
|
|
110
|
+
* Mapping:
|
|
111
|
+
* - `function_call` output items → `{ id: call_id, type:'function',
|
|
112
|
+
* function:{ name, arguments } }` with `arguments` kept as the raw JSON
|
|
113
|
+
* string (never pre-parsed) — exactly the Chat `ChatCompletionMessageToolCall`
|
|
114
|
+
* shape. `id` is sourced from `call_id` (not the item `id`) so it round-trips
|
|
115
|
+
* as the `tool_call_id` in a multi-turn conversation.
|
|
116
|
+
* - `message` output items → concatenated `output_text` parts (refusals and
|
|
117
|
+
* non-text parts contribute nothing, matching the Chat path's null-content →
|
|
118
|
+
* empty-string behaviour).
|
|
119
|
+
* - usage: `input_tokens`→prompt, `output_tokens`→completion,
|
|
120
|
+
* `input_tokens_details.cached_tokens`→cached,
|
|
121
|
+
* `output_tokens_details.reasoning_tokens`→reasoning.
|
|
122
|
+
*
|
|
123
|
+
* `system_fingerprint` is `undefined` — the Responses API does not return one
|
|
124
|
+
* (the Chat path forwards it; consumers already treat it as optional).
|
|
125
|
+
*
|
|
126
|
+
* @param response The raw OpenAI Responses API result.
|
|
127
|
+
* @param normalizedModel The normalized model name the request targeted.
|
|
128
|
+
* @param serviceTier The caller's requested service tier, echoed through as on
|
|
129
|
+
* the Chat path.
|
|
130
|
+
* @returns A {@link CompletionResponse} structurally identical to the Chat path's.
|
|
131
|
+
*/
|
|
132
|
+
export declare function normalizeResponsesToCompletion(response: OpenAIResponse, normalizedModel: string, serviceTier?: string): CompletionResponse;
|
|
17
133
|
/**
|
|
18
134
|
* Makes a call to the Lumic LLM interface, either to the default model or to one specified.
|
|
19
135
|
*
|
|
136
|
+
* Transport is chosen transparently: models flagged
|
|
137
|
+
* {@link ModelCapabilities.requiresResponsesApiForTools} (the GPT-5.6 reasoning
|
|
138
|
+
* trio) that are called WITH function tools are routed to the OpenAI Responses
|
|
139
|
+
* API; every other call stays on Chat Completions. The returned
|
|
140
|
+
* {@link LLMResponse} envelope — `response`, `tool_calls`, and `usage` — is
|
|
141
|
+
* byte-identical across both transports, so callers require no changes.
|
|
142
|
+
*
|
|
20
143
|
* @param content The content to pass to the LLM.
|
|
21
144
|
* @param responseFormat The format of the response. Defaults to 'text'.
|
|
22
145
|
* @param options The options for the LLM call. Defaults to an empty object.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export { ParseJsonOptions } from './functions/llm-utils';
|
|
|
43
43
|
export { FixJsonWithAIOptions } from './functions/json-llm-tools';
|
|
44
44
|
export { SUPPORTED_MODELS, isValidModel, getModelCapabilities, getModelProvider, MODEL_ALIASES, OPENAI_COMPATIBLE_PROVIDERS, PROVIDER_DEFAULT_MODELS, } from './types/openai-types';
|
|
45
45
|
export type { SupportedModel, OpenAIModel, AnthropicModel, DeepseekModel, KimiModel, QwenModel, XAIModel, GeminiModel, LLMModel, LLMProvider, ModelCapabilities, OpenAICompatibleProviderConfig, } from './types/openai-types';
|
|
46
|
-
export { LLM_DEFAULT_PROVIDER, LLM_MINI_PROVIDER, LLM_NORMAL_PROVIDER, LLM_ADVANCED_PROVIDER, LLM_PROVIDER, LLM_MODEL_MINI, LLM_MODEL_NORMAL, LLM_MODEL_ADVANCED, } from './utils/config';
|
|
46
|
+
export { LLM_DEFAULT_PROVIDER, LLM_MINI_PROVIDER, LLM_NORMAL_PROVIDER, LLM_ADVANCED_PROVIDER, LLM_CRITICAL_PROVIDER, LLM_PROVIDER, LLM_MODEL_MINI, LLM_MODEL_NORMAL, LLM_MODEL_ADVANCED, LLM_MODEL_CRITICAL, } from './utils/config';
|
|
47
47
|
export { makeAnthropicCall } from './functions/llm-anthropic';
|
|
48
48
|
export { makeOpenAICompatibleCall } from './functions/llm-openai-compatible';
|
|
49
49
|
export { openAIChatCompletionSchema, openAIImageResponseSchema, validateOpenAIChatCompletion, safeValidateOpenAIChatCompletion, perplexityResponseSchema, validatePerplexityResponse, safeValidatePerplexityResponse, googleSheetsValueRangeSchema, validateGoogleSheetsResponse, safeValidateGoogleSheetsResponse, s3ListObjectsSchema, s3GetObjectSchema, lambdaInvokeResponseSchema, validateS3ListObjects, safeValidateS3ListObjects, validateLambdaResponse, safeValidateLambdaResponse, createValidator, createSafeValidator, } from './schemas';
|
|
@@ -44,8 +44,8 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
44
44
|
}>, "many">>;
|
|
45
45
|
refusal: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
46
46
|
}, "strip", z.ZodTypeAny, {
|
|
47
|
-
content: string | null;
|
|
48
47
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
48
|
+
content: string | null;
|
|
49
49
|
tool_calls?: {
|
|
50
50
|
function: {
|
|
51
51
|
name: string;
|
|
@@ -56,8 +56,8 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
56
56
|
}[] | undefined;
|
|
57
57
|
refusal?: string | null | undefined;
|
|
58
58
|
}, {
|
|
59
|
-
content: string | null;
|
|
60
59
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
60
|
+
content: string | null;
|
|
61
61
|
tool_calls?: {
|
|
62
62
|
function: {
|
|
63
63
|
name: string;
|
|
@@ -71,8 +71,8 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
71
71
|
finish_reason: z.ZodNullable<z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "function_call"]>>;
|
|
72
72
|
}, "strip", z.ZodTypeAny, {
|
|
73
73
|
message: {
|
|
74
|
-
content: string | null;
|
|
75
74
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
75
|
+
content: string | null;
|
|
76
76
|
tool_calls?: {
|
|
77
77
|
function: {
|
|
78
78
|
name: string;
|
|
@@ -84,11 +84,11 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
84
84
|
refusal?: string | null | undefined;
|
|
85
85
|
};
|
|
86
86
|
index: number;
|
|
87
|
-
finish_reason: "length" | "
|
|
87
|
+
finish_reason: "length" | "function_call" | "tool_calls" | "stop" | "content_filter" | null;
|
|
88
88
|
}, {
|
|
89
89
|
message: {
|
|
90
|
-
content: string | null;
|
|
91
90
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
91
|
+
content: string | null;
|
|
92
92
|
tool_calls?: {
|
|
93
93
|
function: {
|
|
94
94
|
name: string;
|
|
@@ -100,7 +100,7 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
100
100
|
refusal?: string | null | undefined;
|
|
101
101
|
};
|
|
102
102
|
index: number;
|
|
103
|
-
finish_reason: "length" | "
|
|
103
|
+
finish_reason: "length" | "function_call" | "tool_calls" | "stop" | "content_filter" | null;
|
|
104
104
|
}>, "many">;
|
|
105
105
|
usage: z.ZodOptional<z.ZodObject<{
|
|
106
106
|
prompt_tokens: z.ZodNumber;
|
|
@@ -198,8 +198,8 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
198
198
|
}>, "many">>;
|
|
199
199
|
refusal: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
200
200
|
}, "strip", z.ZodTypeAny, {
|
|
201
|
-
content: string | null;
|
|
202
201
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
202
|
+
content: string | null;
|
|
203
203
|
tool_calls?: {
|
|
204
204
|
function: {
|
|
205
205
|
name: string;
|
|
@@ -210,8 +210,8 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
210
210
|
}[] | undefined;
|
|
211
211
|
refusal?: string | null | undefined;
|
|
212
212
|
}, {
|
|
213
|
-
content: string | null;
|
|
214
213
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
214
|
+
content: string | null;
|
|
215
215
|
tool_calls?: {
|
|
216
216
|
function: {
|
|
217
217
|
name: string;
|
|
@@ -225,8 +225,8 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
225
225
|
finish_reason: z.ZodNullable<z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "function_call"]>>;
|
|
226
226
|
}, "strip", z.ZodTypeAny, {
|
|
227
227
|
message: {
|
|
228
|
-
content: string | null;
|
|
229
228
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
229
|
+
content: string | null;
|
|
230
230
|
tool_calls?: {
|
|
231
231
|
function: {
|
|
232
232
|
name: string;
|
|
@@ -238,11 +238,11 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
238
238
|
refusal?: string | null | undefined;
|
|
239
239
|
};
|
|
240
240
|
index: number;
|
|
241
|
-
finish_reason: "length" | "
|
|
241
|
+
finish_reason: "length" | "function_call" | "tool_calls" | "stop" | "content_filter" | null;
|
|
242
242
|
}, {
|
|
243
243
|
message: {
|
|
244
|
-
content: string | null;
|
|
245
244
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
245
|
+
content: string | null;
|
|
246
246
|
tool_calls?: {
|
|
247
247
|
function: {
|
|
248
248
|
name: string;
|
|
@@ -254,7 +254,7 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
254
254
|
refusal?: string | null | undefined;
|
|
255
255
|
};
|
|
256
256
|
index: number;
|
|
257
|
-
finish_reason: "length" | "
|
|
257
|
+
finish_reason: "length" | "function_call" | "tool_calls" | "stop" | "content_filter" | null;
|
|
258
258
|
}>, "many">;
|
|
259
259
|
usage: z.ZodOptional<z.ZodObject<{
|
|
260
260
|
prompt_tokens: z.ZodNumber;
|
|
@@ -352,8 +352,8 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
352
352
|
}>, "many">>;
|
|
353
353
|
refusal: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
354
354
|
}, "strip", z.ZodTypeAny, {
|
|
355
|
-
content: string | null;
|
|
356
355
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
356
|
+
content: string | null;
|
|
357
357
|
tool_calls?: {
|
|
358
358
|
function: {
|
|
359
359
|
name: string;
|
|
@@ -364,8 +364,8 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
364
364
|
}[] | undefined;
|
|
365
365
|
refusal?: string | null | undefined;
|
|
366
366
|
}, {
|
|
367
|
-
content: string | null;
|
|
368
367
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
368
|
+
content: string | null;
|
|
369
369
|
tool_calls?: {
|
|
370
370
|
function: {
|
|
371
371
|
name: string;
|
|
@@ -379,8 +379,8 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
379
379
|
finish_reason: z.ZodNullable<z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "function_call"]>>;
|
|
380
380
|
}, "strip", z.ZodTypeAny, {
|
|
381
381
|
message: {
|
|
382
|
-
content: string | null;
|
|
383
382
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
383
|
+
content: string | null;
|
|
384
384
|
tool_calls?: {
|
|
385
385
|
function: {
|
|
386
386
|
name: string;
|
|
@@ -392,11 +392,11 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
392
392
|
refusal?: string | null | undefined;
|
|
393
393
|
};
|
|
394
394
|
index: number;
|
|
395
|
-
finish_reason: "length" | "
|
|
395
|
+
finish_reason: "length" | "function_call" | "tool_calls" | "stop" | "content_filter" | null;
|
|
396
396
|
}, {
|
|
397
397
|
message: {
|
|
398
|
-
content: string | null;
|
|
399
398
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
399
|
+
content: string | null;
|
|
400
400
|
tool_calls?: {
|
|
401
401
|
function: {
|
|
402
402
|
name: string;
|
|
@@ -408,7 +408,7 @@ export declare const openAIChatCompletionSchema: z.ZodObject<{
|
|
|
408
408
|
refusal?: string | null | undefined;
|
|
409
409
|
};
|
|
410
410
|
index: number;
|
|
411
|
-
finish_reason: "length" | "
|
|
411
|
+
finish_reason: "length" | "function_call" | "tool_calls" | "stop" | "content_filter" | null;
|
|
412
412
|
}>, "many">;
|
|
413
413
|
usage: z.ZodOptional<z.ZodObject<{
|
|
414
414
|
prompt_tokens: z.ZodNumber;
|
|
@@ -561,8 +561,8 @@ export declare const validateOpenAIChatCompletion: (data: unknown) => z.objectIn
|
|
|
561
561
|
}>, "many">>;
|
|
562
562
|
refusal: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
563
563
|
}, "strip", z.ZodTypeAny, {
|
|
564
|
-
content: string | null;
|
|
565
564
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
565
|
+
content: string | null;
|
|
566
566
|
tool_calls?: {
|
|
567
567
|
function: {
|
|
568
568
|
name: string;
|
|
@@ -573,8 +573,8 @@ export declare const validateOpenAIChatCompletion: (data: unknown) => z.objectIn
|
|
|
573
573
|
}[] | undefined;
|
|
574
574
|
refusal?: string | null | undefined;
|
|
575
575
|
}, {
|
|
576
|
-
content: string | null;
|
|
577
576
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
577
|
+
content: string | null;
|
|
578
578
|
tool_calls?: {
|
|
579
579
|
function: {
|
|
580
580
|
name: string;
|
|
@@ -588,8 +588,8 @@ export declare const validateOpenAIChatCompletion: (data: unknown) => z.objectIn
|
|
|
588
588
|
finish_reason: z.ZodNullable<z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "function_call"]>>;
|
|
589
589
|
}, "strip", z.ZodTypeAny, {
|
|
590
590
|
message: {
|
|
591
|
-
content: string | null;
|
|
592
591
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
592
|
+
content: string | null;
|
|
593
593
|
tool_calls?: {
|
|
594
594
|
function: {
|
|
595
595
|
name: string;
|
|
@@ -601,11 +601,11 @@ export declare const validateOpenAIChatCompletion: (data: unknown) => z.objectIn
|
|
|
601
601
|
refusal?: string | null | undefined;
|
|
602
602
|
};
|
|
603
603
|
index: number;
|
|
604
|
-
finish_reason: "length" | "
|
|
604
|
+
finish_reason: "length" | "function_call" | "tool_calls" | "stop" | "content_filter" | null;
|
|
605
605
|
}, {
|
|
606
606
|
message: {
|
|
607
|
-
content: string | null;
|
|
608
607
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
608
|
+
content: string | null;
|
|
609
609
|
tool_calls?: {
|
|
610
610
|
function: {
|
|
611
611
|
name: string;
|
|
@@ -617,7 +617,7 @@ export declare const validateOpenAIChatCompletion: (data: unknown) => z.objectIn
|
|
|
617
617
|
refusal?: string | null | undefined;
|
|
618
618
|
};
|
|
619
619
|
index: number;
|
|
620
|
-
finish_reason: "length" | "
|
|
620
|
+
finish_reason: "length" | "function_call" | "tool_calls" | "stop" | "content_filter" | null;
|
|
621
621
|
}>, "many">;
|
|
622
622
|
usage: z.ZodOptional<z.ZodObject<{
|
|
623
623
|
prompt_tokens: z.ZodNumber;
|
|
@@ -717,8 +717,8 @@ export declare const safeValidateOpenAIChatCompletion: (data: unknown) => import
|
|
|
717
717
|
}>, "many">>;
|
|
718
718
|
refusal: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
719
719
|
}, "strip", z.ZodTypeAny, {
|
|
720
|
-
content: string | null;
|
|
721
720
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
721
|
+
content: string | null;
|
|
722
722
|
tool_calls?: {
|
|
723
723
|
function: {
|
|
724
724
|
name: string;
|
|
@@ -729,8 +729,8 @@ export declare const safeValidateOpenAIChatCompletion: (data: unknown) => import
|
|
|
729
729
|
}[] | undefined;
|
|
730
730
|
refusal?: string | null | undefined;
|
|
731
731
|
}, {
|
|
732
|
-
content: string | null;
|
|
733
732
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
733
|
+
content: string | null;
|
|
734
734
|
tool_calls?: {
|
|
735
735
|
function: {
|
|
736
736
|
name: string;
|
|
@@ -744,8 +744,8 @@ export declare const safeValidateOpenAIChatCompletion: (data: unknown) => import
|
|
|
744
744
|
finish_reason: z.ZodNullable<z.ZodEnum<["stop", "length", "tool_calls", "content_filter", "function_call"]>>;
|
|
745
745
|
}, "strip", z.ZodTypeAny, {
|
|
746
746
|
message: {
|
|
747
|
-
content: string | null;
|
|
748
747
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
748
|
+
content: string | null;
|
|
749
749
|
tool_calls?: {
|
|
750
750
|
function: {
|
|
751
751
|
name: string;
|
|
@@ -757,11 +757,11 @@ export declare const safeValidateOpenAIChatCompletion: (data: unknown) => import
|
|
|
757
757
|
refusal?: string | null | undefined;
|
|
758
758
|
};
|
|
759
759
|
index: number;
|
|
760
|
-
finish_reason: "length" | "
|
|
760
|
+
finish_reason: "length" | "function_call" | "tool_calls" | "stop" | "content_filter" | null;
|
|
761
761
|
}, {
|
|
762
762
|
message: {
|
|
763
|
-
content: string | null;
|
|
764
763
|
role: "function" | "system" | "user" | "assistant" | "tool";
|
|
764
|
+
content: string | null;
|
|
765
765
|
tool_calls?: {
|
|
766
766
|
function: {
|
|
767
767
|
name: string;
|
|
@@ -773,7 +773,7 @@ export declare const safeValidateOpenAIChatCompletion: (data: unknown) => import
|
|
|
773
773
|
refusal?: string | null | undefined;
|
|
774
774
|
};
|
|
775
775
|
index: number;
|
|
776
|
-
finish_reason: "length" | "
|
|
776
|
+
finish_reason: "length" | "function_call" | "tool_calls" | "stop" | "content_filter" | null;
|
|
777
777
|
}>, "many">;
|
|
778
778
|
usage: z.ZodOptional<z.ZodObject<{
|
|
779
779
|
prompt_tokens: z.ZodNumber;
|