@reverbia/sdk 1.0.0-next.20251202095402 → 1.0.0-next.20251202130234
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.cjs +26 -2
- package/dist/index.d.mts +260 -2
- package/dist/index.d.ts +260 -2
- package/dist/index.mjs +23 -1
- package/dist/react/index.cjs +36 -20
- package/dist/react/index.d.mts +25 -1
- package/dist/react/index.d.ts +25 -1
- package/dist/react/index.mjs +36 -20
- package/dist/vercel/index.cjs +1 -1
- package/dist/vercel/index.d.mts +25 -1
- package/dist/vercel/index.d.ts +25 -1
- package/dist/vercel/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,9 @@ __export(index_exports, {
|
|
|
23
23
|
getApiV1Models: () => getApiV1Models,
|
|
24
24
|
getHealth: () => getHealth,
|
|
25
25
|
postApiV1ChatCompletions: () => postApiV1ChatCompletions,
|
|
26
|
-
postApiV1Embeddings: () => postApiV1Embeddings
|
|
26
|
+
postApiV1Embeddings: () => postApiV1Embeddings,
|
|
27
|
+
postApiV1ImagesGenerations: () => postApiV1ImagesGenerations,
|
|
28
|
+
postApiV1Search: () => postApiV1Search
|
|
27
29
|
});
|
|
28
30
|
module.exports = __toCommonJS(index_exports);
|
|
29
31
|
|
|
@@ -863,12 +865,32 @@ var postApiV1Embeddings = (options) => {
|
|
|
863
865
|
}
|
|
864
866
|
});
|
|
865
867
|
};
|
|
868
|
+
var postApiV1ImagesGenerations = (options) => {
|
|
869
|
+
return (options.client ?? client).post({
|
|
870
|
+
url: "/api/v1/images/generations",
|
|
871
|
+
...options,
|
|
872
|
+
headers: {
|
|
873
|
+
"Content-Type": "application/json",
|
|
874
|
+
...options.headers
|
|
875
|
+
}
|
|
876
|
+
});
|
|
877
|
+
};
|
|
866
878
|
var getApiV1Models = (options) => {
|
|
867
879
|
return (options?.client ?? client).get({
|
|
868
880
|
url: "/api/v1/models",
|
|
869
881
|
...options
|
|
870
882
|
});
|
|
871
883
|
};
|
|
884
|
+
var postApiV1Search = (options) => {
|
|
885
|
+
return (options.client ?? client).post({
|
|
886
|
+
url: "/api/v1/search",
|
|
887
|
+
...options,
|
|
888
|
+
headers: {
|
|
889
|
+
"Content-Type": "application/json",
|
|
890
|
+
...options.headers
|
|
891
|
+
}
|
|
892
|
+
});
|
|
893
|
+
};
|
|
872
894
|
var getHealth = (options) => {
|
|
873
895
|
return (options?.client ?? client).get({
|
|
874
896
|
url: "/health",
|
|
@@ -880,5 +902,7 @@ var getHealth = (options) => {
|
|
|
880
902
|
getApiV1Models,
|
|
881
903
|
getHealth,
|
|
882
904
|
postApiV1ChatCompletions,
|
|
883
|
-
postApiV1Embeddings
|
|
905
|
+
postApiV1Embeddings,
|
|
906
|
+
postApiV1ImagesGenerations,
|
|
907
|
+
postApiV1Search
|
|
884
908
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -188,6 +188,96 @@ type LlmapiEmbeddingUsage = {
|
|
|
188
188
|
*/
|
|
189
189
|
total_tokens?: number;
|
|
190
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* ExtraFields contains additional metadata such as provider/model information.
|
|
193
|
+
*/
|
|
194
|
+
type LlmapiImageGenerationExtraFields = {
|
|
195
|
+
/**
|
|
196
|
+
* ModelRequested is the model identifier that the client asked for.
|
|
197
|
+
*/
|
|
198
|
+
model_requested?: string;
|
|
199
|
+
/**
|
|
200
|
+
* Provider is the gateway that serviced this request.
|
|
201
|
+
*/
|
|
202
|
+
provider?: string;
|
|
203
|
+
/**
|
|
204
|
+
* RequestType is always "image_generation".
|
|
205
|
+
*/
|
|
206
|
+
request_type?: string;
|
|
207
|
+
};
|
|
208
|
+
type LlmapiImageGenerationImage = {
|
|
209
|
+
/**
|
|
210
|
+
* B64JSON is the base64 payload for models that can only return binary.
|
|
211
|
+
*/
|
|
212
|
+
b64_json?: string;
|
|
213
|
+
/**
|
|
214
|
+
* URL is the signed URL to download the image.
|
|
215
|
+
*/
|
|
216
|
+
url?: string;
|
|
217
|
+
};
|
|
218
|
+
type LlmapiImageGenerationRequest = {
|
|
219
|
+
/**
|
|
220
|
+
* Model is the model identifier to use for generation (e.g., "gpt-image-1").
|
|
221
|
+
*/
|
|
222
|
+
model?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Prompt is the text description of the desired image.
|
|
225
|
+
*/
|
|
226
|
+
prompt?: string;
|
|
227
|
+
/**
|
|
228
|
+
* Quality targets a quality preset (e.g., "auto", "high").
|
|
229
|
+
*/
|
|
230
|
+
quality?: string;
|
|
231
|
+
/**
|
|
232
|
+
* ResponseFormat controls how the generated image is returned (e.g., "url" or "b64_json").
|
|
233
|
+
*/
|
|
234
|
+
response_format?: string;
|
|
235
|
+
/**
|
|
236
|
+
* Size controls the dimensions of the generated image (e.g., "1024x1024").
|
|
237
|
+
*/
|
|
238
|
+
size?: string;
|
|
239
|
+
};
|
|
240
|
+
type LlmapiImageGenerationResponse = {
|
|
241
|
+
/**
|
|
242
|
+
* Created is the Unix timestamp when the image was generated.
|
|
243
|
+
*/
|
|
244
|
+
created?: number;
|
|
245
|
+
extra_fields?: LlmapiImageGenerationExtraFields;
|
|
246
|
+
/**
|
|
247
|
+
* Images contains the generated images.
|
|
248
|
+
*/
|
|
249
|
+
images?: Array<LlmapiImageGenerationImage>;
|
|
250
|
+
/**
|
|
251
|
+
* Model is the model identifier that generated the image.
|
|
252
|
+
*/
|
|
253
|
+
model?: string;
|
|
254
|
+
/**
|
|
255
|
+
* Provider is the gateway that produced the image.
|
|
256
|
+
*/
|
|
257
|
+
provider?: string;
|
|
258
|
+
usage?: LlmapiImageGenerationUsage;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Usage documents token usage (when available).
|
|
262
|
+
*/
|
|
263
|
+
type LlmapiImageGenerationUsage = {
|
|
264
|
+
/**
|
|
265
|
+
* CostMicroUSD is the inference cost for this image generation request
|
|
266
|
+
*/
|
|
267
|
+
cost_micro_usd?: number;
|
|
268
|
+
/**
|
|
269
|
+
* InputTokens is the number of tokens sent in the prompt.
|
|
270
|
+
*/
|
|
271
|
+
input_tokens?: number;
|
|
272
|
+
/**
|
|
273
|
+
* OutputTokens is the number of tokens returned by the model.
|
|
274
|
+
*/
|
|
275
|
+
output_tokens?: number;
|
|
276
|
+
/**
|
|
277
|
+
* TotalTokens is the total number of tokens consumed.
|
|
278
|
+
*/
|
|
279
|
+
total_tokens?: number;
|
|
280
|
+
};
|
|
191
281
|
/**
|
|
192
282
|
* Message is the generated message
|
|
193
283
|
*/
|
|
@@ -195,9 +285,33 @@ type LlmapiMessage = {
|
|
|
195
285
|
/**
|
|
196
286
|
* Content is the message content
|
|
197
287
|
*/
|
|
198
|
-
content?:
|
|
288
|
+
content?: Array<LlmapiMessageContentPart>;
|
|
199
289
|
role?: LlmapiRole;
|
|
200
290
|
};
|
|
291
|
+
/**
|
|
292
|
+
* ImageURL is used when Type=image_url
|
|
293
|
+
*/
|
|
294
|
+
type LlmapiMessageContentImage = {
|
|
295
|
+
/**
|
|
296
|
+
* Detail is the OpenAI detail hint (auto|low|high)
|
|
297
|
+
*/
|
|
298
|
+
detail?: string;
|
|
299
|
+
/**
|
|
300
|
+
* URL is the image URL or data URI
|
|
301
|
+
*/
|
|
302
|
+
url?: string;
|
|
303
|
+
};
|
|
304
|
+
type LlmapiMessageContentPart = {
|
|
305
|
+
image_url?: LlmapiMessageContentImage;
|
|
306
|
+
/**
|
|
307
|
+
* Text holds the text content when Type=text
|
|
308
|
+
*/
|
|
309
|
+
text?: string;
|
|
310
|
+
/**
|
|
311
|
+
* Type is the block type (`text` or `image_url`)
|
|
312
|
+
*/
|
|
313
|
+
type?: string;
|
|
314
|
+
};
|
|
201
315
|
type LlmapiModel = {
|
|
202
316
|
architecture?: LlmapiModelArchitecture;
|
|
203
317
|
/**
|
|
@@ -323,6 +437,80 @@ type LlmapiModelsListResponse = {
|
|
|
323
437
|
* Role is the message role (system, user, assistant)
|
|
324
438
|
*/
|
|
325
439
|
type LlmapiRole = string;
|
|
440
|
+
/**
|
|
441
|
+
* ExtraFields contains additional metadata.
|
|
442
|
+
*/
|
|
443
|
+
type LlmapiSearchExtraFields = {
|
|
444
|
+
/**
|
|
445
|
+
* RequestType is always "search".
|
|
446
|
+
*/
|
|
447
|
+
request_type?: string;
|
|
448
|
+
/**
|
|
449
|
+
* SearchProvider is the search provider used (e.g., "perplexity", "google-pse").
|
|
450
|
+
*/
|
|
451
|
+
search_provider?: string;
|
|
452
|
+
};
|
|
453
|
+
type LlmapiSearchRequest = {
|
|
454
|
+
/**
|
|
455
|
+
* Country code filter (e.g., "US", "GB", "DE").
|
|
456
|
+
*/
|
|
457
|
+
country?: string;
|
|
458
|
+
/**
|
|
459
|
+
* Maximum number of results to return (1-20). Default: 10.
|
|
460
|
+
*/
|
|
461
|
+
max_results?: number;
|
|
462
|
+
/**
|
|
463
|
+
* Maximum tokens per page to process. Default: 1024.
|
|
464
|
+
*/
|
|
465
|
+
max_tokens_per_page?: number;
|
|
466
|
+
/**
|
|
467
|
+
* Search query. Can be a single string or array of strings.
|
|
468
|
+
*/
|
|
469
|
+
query?: Array<string>;
|
|
470
|
+
/**
|
|
471
|
+
* List of domains to filter results (max 20 domains).
|
|
472
|
+
*/
|
|
473
|
+
search_domain_filter?: Array<string>;
|
|
474
|
+
/**
|
|
475
|
+
* The search provider to use.
|
|
476
|
+
*/
|
|
477
|
+
search_tool_name?: string;
|
|
478
|
+
};
|
|
479
|
+
type LlmapiSearchResponse = {
|
|
480
|
+
extra_fields?: LlmapiSearchExtraFields;
|
|
481
|
+
/**
|
|
482
|
+
* List of search results.
|
|
483
|
+
*/
|
|
484
|
+
results?: Array<LlmapiSearchResult>;
|
|
485
|
+
usage?: LlmapiSearchUsage;
|
|
486
|
+
};
|
|
487
|
+
type LlmapiSearchResult = {
|
|
488
|
+
/**
|
|
489
|
+
* Optional publication or last updated date.
|
|
490
|
+
*/
|
|
491
|
+
date?: string;
|
|
492
|
+
/**
|
|
493
|
+
* Text snippet from the result.
|
|
494
|
+
*/
|
|
495
|
+
snippet?: string;
|
|
496
|
+
/**
|
|
497
|
+
* Title of the search result.
|
|
498
|
+
*/
|
|
499
|
+
title?: string;
|
|
500
|
+
/**
|
|
501
|
+
* URL of the search result.
|
|
502
|
+
*/
|
|
503
|
+
url?: string;
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* Usage contains usage information.
|
|
507
|
+
*/
|
|
508
|
+
type LlmapiSearchUsage = {
|
|
509
|
+
/**
|
|
510
|
+
* CostMicroUSD is the cost of this search in micro-dollars (USD × 1,000,000).
|
|
511
|
+
*/
|
|
512
|
+
cost_micro_usd?: number;
|
|
513
|
+
};
|
|
326
514
|
type ResponseErrorResponse = {
|
|
327
515
|
error?: string;
|
|
328
516
|
};
|
|
@@ -380,6 +568,37 @@ type PostApiV1EmbeddingsResponses = {
|
|
|
380
568
|
200: LlmapiEmbeddingResponse;
|
|
381
569
|
};
|
|
382
570
|
type PostApiV1EmbeddingsResponse = PostApiV1EmbeddingsResponses[keyof PostApiV1EmbeddingsResponses];
|
|
571
|
+
type PostApiV1ImagesGenerationsData = {
|
|
572
|
+
/**
|
|
573
|
+
* Image generation request
|
|
574
|
+
*/
|
|
575
|
+
body: LlmapiImageGenerationRequest;
|
|
576
|
+
path?: never;
|
|
577
|
+
query?: never;
|
|
578
|
+
url: '/api/v1/images/generations';
|
|
579
|
+
};
|
|
580
|
+
type PostApiV1ImagesGenerationsErrors = {
|
|
581
|
+
/**
|
|
582
|
+
* Bad Request
|
|
583
|
+
*/
|
|
584
|
+
400: ResponseErrorResponse;
|
|
585
|
+
/**
|
|
586
|
+
* Internal Server Error
|
|
587
|
+
*/
|
|
588
|
+
500: ResponseErrorResponse;
|
|
589
|
+
/**
|
|
590
|
+
* Not Implemented
|
|
591
|
+
*/
|
|
592
|
+
501: ResponseErrorResponse;
|
|
593
|
+
};
|
|
594
|
+
type PostApiV1ImagesGenerationsError = PostApiV1ImagesGenerationsErrors[keyof PostApiV1ImagesGenerationsErrors];
|
|
595
|
+
type PostApiV1ImagesGenerationsResponses = {
|
|
596
|
+
/**
|
|
597
|
+
* OK
|
|
598
|
+
*/
|
|
599
|
+
200: LlmapiImageGenerationResponse;
|
|
600
|
+
};
|
|
601
|
+
type PostApiV1ImagesGenerationsResponse = PostApiV1ImagesGenerationsResponses[keyof PostApiV1ImagesGenerationsResponses];
|
|
383
602
|
type GetApiV1ModelsData = {
|
|
384
603
|
body?: never;
|
|
385
604
|
path?: never;
|
|
@@ -417,6 +636,33 @@ type GetApiV1ModelsResponses = {
|
|
|
417
636
|
200: LlmapiModelsListResponse;
|
|
418
637
|
};
|
|
419
638
|
type GetApiV1ModelsResponse = GetApiV1ModelsResponses[keyof GetApiV1ModelsResponses];
|
|
639
|
+
type PostApiV1SearchData = {
|
|
640
|
+
/**
|
|
641
|
+
* Search request
|
|
642
|
+
*/
|
|
643
|
+
body: LlmapiSearchRequest;
|
|
644
|
+
path?: never;
|
|
645
|
+
query?: never;
|
|
646
|
+
url: '/api/v1/search';
|
|
647
|
+
};
|
|
648
|
+
type PostApiV1SearchErrors = {
|
|
649
|
+
/**
|
|
650
|
+
* Bad Request
|
|
651
|
+
*/
|
|
652
|
+
400: ResponseErrorResponse;
|
|
653
|
+
/**
|
|
654
|
+
* Internal Server Error
|
|
655
|
+
*/
|
|
656
|
+
500: ResponseErrorResponse;
|
|
657
|
+
};
|
|
658
|
+
type PostApiV1SearchError = PostApiV1SearchErrors[keyof PostApiV1SearchErrors];
|
|
659
|
+
type PostApiV1SearchResponses = {
|
|
660
|
+
/**
|
|
661
|
+
* OK
|
|
662
|
+
*/
|
|
663
|
+
200: LlmapiSearchResponse;
|
|
664
|
+
};
|
|
665
|
+
type PostApiV1SearchResponse = PostApiV1SearchResponses[keyof PostApiV1SearchResponses];
|
|
420
666
|
type GetHealthData = {
|
|
421
667
|
body?: never;
|
|
422
668
|
path?: never;
|
|
@@ -752,12 +998,24 @@ declare const postApiV1ChatCompletions: <ThrowOnError extends boolean = false>(o
|
|
|
752
998
|
* Generates embeddings using the configured gateway.
|
|
753
999
|
*/
|
|
754
1000
|
declare const postApiV1Embeddings: <ThrowOnError extends boolean = false>(options: Options<PostApiV1EmbeddingsData, ThrowOnError>) => RequestResult<PostApiV1EmbeddingsResponses, PostApiV1EmbeddingsErrors, ThrowOnError>;
|
|
1001
|
+
/**
|
|
1002
|
+
* Generate images
|
|
1003
|
+
*
|
|
1004
|
+
* Generates images using the configured LLM gateway.
|
|
1005
|
+
*/
|
|
1006
|
+
declare const postApiV1ImagesGenerations: <ThrowOnError extends boolean = false>(options: Options<PostApiV1ImagesGenerationsData, ThrowOnError>) => RequestResult<PostApiV1ImagesGenerationsResponses, PostApiV1ImagesGenerationsErrors, ThrowOnError>;
|
|
755
1007
|
/**
|
|
756
1008
|
* List available models
|
|
757
1009
|
*
|
|
758
1010
|
* Returns a list of all available models from the configured gateway with optional filters.
|
|
759
1011
|
*/
|
|
760
1012
|
declare const getApiV1Models: <ThrowOnError extends boolean = false>(options?: Options<GetApiV1ModelsData, ThrowOnError>) => RequestResult<GetApiV1ModelsResponses, GetApiV1ModelsErrors, ThrowOnError>;
|
|
1013
|
+
/**
|
|
1014
|
+
* Create search
|
|
1015
|
+
*
|
|
1016
|
+
* Returns a list of ranked search results
|
|
1017
|
+
*/
|
|
1018
|
+
declare const postApiV1Search: <ThrowOnError extends boolean = false>(options: Options<PostApiV1SearchData, ThrowOnError>) => RequestResult<PostApiV1SearchResponses, PostApiV1SearchErrors, ThrowOnError>;
|
|
761
1019
|
/**
|
|
762
1020
|
* Health check
|
|
763
1021
|
*
|
|
@@ -765,4 +1023,4 @@ declare const getApiV1Models: <ThrowOnError extends boolean = false>(options?: O
|
|
|
765
1023
|
*/
|
|
766
1024
|
declare const getHealth: <ThrowOnError extends boolean = false>(options?: Options<GetHealthData, ThrowOnError>) => RequestResult<GetHealthResponses, GetHealthErrors, ThrowOnError>;
|
|
767
1025
|
|
|
768
|
-
export { type ClientOptions$1 as ClientOptions, type GetApiV1ModelsData, type GetApiV1ModelsError, type GetApiV1ModelsErrors, type GetApiV1ModelsResponse, type GetApiV1ModelsResponses, type GetHealthData, type GetHealthError, type GetHealthErrors, type GetHealthResponse, type GetHealthResponses, type HandlersHealthResponse, type LlmapiChatCompletionExtraFields, type LlmapiChatCompletionRequest, type LlmapiChatCompletionResponse, type LlmapiChatCompletionUsage, type LlmapiChoice, type LlmapiEmbeddingData, type LlmapiEmbeddingExtraFields, type LlmapiEmbeddingRequest, type LlmapiEmbeddingResponse, type LlmapiEmbeddingUsage, type LlmapiMessage, type LlmapiModel, type LlmapiModelArchitecture, type LlmapiModelPerRequestLimits, type LlmapiModelPricing, type LlmapiModelTopProvider, type LlmapiModelsListExtraFields, type LlmapiModelsListResponse, type LlmapiRole, type Options, type PostApiV1ChatCompletionsData, type PostApiV1ChatCompletionsError, type PostApiV1ChatCompletionsErrors, type PostApiV1ChatCompletionsResponse, type PostApiV1ChatCompletionsResponses, type PostApiV1EmbeddingsData, type PostApiV1EmbeddingsError, type PostApiV1EmbeddingsErrors, type PostApiV1EmbeddingsResponse, type PostApiV1EmbeddingsResponses, type ResponseErrorResponse, getApiV1Models, getHealth, postApiV1ChatCompletions, postApiV1Embeddings };
|
|
1026
|
+
export { type ClientOptions$1 as ClientOptions, type GetApiV1ModelsData, type GetApiV1ModelsError, type GetApiV1ModelsErrors, type GetApiV1ModelsResponse, type GetApiV1ModelsResponses, type GetHealthData, type GetHealthError, type GetHealthErrors, type GetHealthResponse, type GetHealthResponses, type HandlersHealthResponse, type LlmapiChatCompletionExtraFields, type LlmapiChatCompletionRequest, type LlmapiChatCompletionResponse, type LlmapiChatCompletionUsage, type LlmapiChoice, type LlmapiEmbeddingData, type LlmapiEmbeddingExtraFields, type LlmapiEmbeddingRequest, type LlmapiEmbeddingResponse, type LlmapiEmbeddingUsage, type LlmapiImageGenerationExtraFields, type LlmapiImageGenerationImage, type LlmapiImageGenerationRequest, type LlmapiImageGenerationResponse, type LlmapiImageGenerationUsage, type LlmapiMessage, type LlmapiMessageContentImage, type LlmapiMessageContentPart, type LlmapiModel, type LlmapiModelArchitecture, type LlmapiModelPerRequestLimits, type LlmapiModelPricing, type LlmapiModelTopProvider, type LlmapiModelsListExtraFields, type LlmapiModelsListResponse, type LlmapiRole, type LlmapiSearchExtraFields, type LlmapiSearchRequest, type LlmapiSearchResponse, type LlmapiSearchResult, type LlmapiSearchUsage, type Options, type PostApiV1ChatCompletionsData, type PostApiV1ChatCompletionsError, type PostApiV1ChatCompletionsErrors, type PostApiV1ChatCompletionsResponse, type PostApiV1ChatCompletionsResponses, type PostApiV1EmbeddingsData, type PostApiV1EmbeddingsError, type PostApiV1EmbeddingsErrors, type PostApiV1EmbeddingsResponse, type PostApiV1EmbeddingsResponses, type PostApiV1ImagesGenerationsData, type PostApiV1ImagesGenerationsError, type PostApiV1ImagesGenerationsErrors, type PostApiV1ImagesGenerationsResponse, type PostApiV1ImagesGenerationsResponses, type PostApiV1SearchData, type PostApiV1SearchError, type PostApiV1SearchErrors, type PostApiV1SearchResponse, type PostApiV1SearchResponses, type ResponseErrorResponse, getApiV1Models, getHealth, postApiV1ChatCompletions, postApiV1Embeddings, postApiV1ImagesGenerations, postApiV1Search };
|
package/dist/index.d.ts
CHANGED
|
@@ -188,6 +188,96 @@ type LlmapiEmbeddingUsage = {
|
|
|
188
188
|
*/
|
|
189
189
|
total_tokens?: number;
|
|
190
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* ExtraFields contains additional metadata such as provider/model information.
|
|
193
|
+
*/
|
|
194
|
+
type LlmapiImageGenerationExtraFields = {
|
|
195
|
+
/**
|
|
196
|
+
* ModelRequested is the model identifier that the client asked for.
|
|
197
|
+
*/
|
|
198
|
+
model_requested?: string;
|
|
199
|
+
/**
|
|
200
|
+
* Provider is the gateway that serviced this request.
|
|
201
|
+
*/
|
|
202
|
+
provider?: string;
|
|
203
|
+
/**
|
|
204
|
+
* RequestType is always "image_generation".
|
|
205
|
+
*/
|
|
206
|
+
request_type?: string;
|
|
207
|
+
};
|
|
208
|
+
type LlmapiImageGenerationImage = {
|
|
209
|
+
/**
|
|
210
|
+
* B64JSON is the base64 payload for models that can only return binary.
|
|
211
|
+
*/
|
|
212
|
+
b64_json?: string;
|
|
213
|
+
/**
|
|
214
|
+
* URL is the signed URL to download the image.
|
|
215
|
+
*/
|
|
216
|
+
url?: string;
|
|
217
|
+
};
|
|
218
|
+
type LlmapiImageGenerationRequest = {
|
|
219
|
+
/**
|
|
220
|
+
* Model is the model identifier to use for generation (e.g., "gpt-image-1").
|
|
221
|
+
*/
|
|
222
|
+
model?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Prompt is the text description of the desired image.
|
|
225
|
+
*/
|
|
226
|
+
prompt?: string;
|
|
227
|
+
/**
|
|
228
|
+
* Quality targets a quality preset (e.g., "auto", "high").
|
|
229
|
+
*/
|
|
230
|
+
quality?: string;
|
|
231
|
+
/**
|
|
232
|
+
* ResponseFormat controls how the generated image is returned (e.g., "url" or "b64_json").
|
|
233
|
+
*/
|
|
234
|
+
response_format?: string;
|
|
235
|
+
/**
|
|
236
|
+
* Size controls the dimensions of the generated image (e.g., "1024x1024").
|
|
237
|
+
*/
|
|
238
|
+
size?: string;
|
|
239
|
+
};
|
|
240
|
+
type LlmapiImageGenerationResponse = {
|
|
241
|
+
/**
|
|
242
|
+
* Created is the Unix timestamp when the image was generated.
|
|
243
|
+
*/
|
|
244
|
+
created?: number;
|
|
245
|
+
extra_fields?: LlmapiImageGenerationExtraFields;
|
|
246
|
+
/**
|
|
247
|
+
* Images contains the generated images.
|
|
248
|
+
*/
|
|
249
|
+
images?: Array<LlmapiImageGenerationImage>;
|
|
250
|
+
/**
|
|
251
|
+
* Model is the model identifier that generated the image.
|
|
252
|
+
*/
|
|
253
|
+
model?: string;
|
|
254
|
+
/**
|
|
255
|
+
* Provider is the gateway that produced the image.
|
|
256
|
+
*/
|
|
257
|
+
provider?: string;
|
|
258
|
+
usage?: LlmapiImageGenerationUsage;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Usage documents token usage (when available).
|
|
262
|
+
*/
|
|
263
|
+
type LlmapiImageGenerationUsage = {
|
|
264
|
+
/**
|
|
265
|
+
* CostMicroUSD is the inference cost for this image generation request
|
|
266
|
+
*/
|
|
267
|
+
cost_micro_usd?: number;
|
|
268
|
+
/**
|
|
269
|
+
* InputTokens is the number of tokens sent in the prompt.
|
|
270
|
+
*/
|
|
271
|
+
input_tokens?: number;
|
|
272
|
+
/**
|
|
273
|
+
* OutputTokens is the number of tokens returned by the model.
|
|
274
|
+
*/
|
|
275
|
+
output_tokens?: number;
|
|
276
|
+
/**
|
|
277
|
+
* TotalTokens is the total number of tokens consumed.
|
|
278
|
+
*/
|
|
279
|
+
total_tokens?: number;
|
|
280
|
+
};
|
|
191
281
|
/**
|
|
192
282
|
* Message is the generated message
|
|
193
283
|
*/
|
|
@@ -195,9 +285,33 @@ type LlmapiMessage = {
|
|
|
195
285
|
/**
|
|
196
286
|
* Content is the message content
|
|
197
287
|
*/
|
|
198
|
-
content?:
|
|
288
|
+
content?: Array<LlmapiMessageContentPart>;
|
|
199
289
|
role?: LlmapiRole;
|
|
200
290
|
};
|
|
291
|
+
/**
|
|
292
|
+
* ImageURL is used when Type=image_url
|
|
293
|
+
*/
|
|
294
|
+
type LlmapiMessageContentImage = {
|
|
295
|
+
/**
|
|
296
|
+
* Detail is the OpenAI detail hint (auto|low|high)
|
|
297
|
+
*/
|
|
298
|
+
detail?: string;
|
|
299
|
+
/**
|
|
300
|
+
* URL is the image URL or data URI
|
|
301
|
+
*/
|
|
302
|
+
url?: string;
|
|
303
|
+
};
|
|
304
|
+
type LlmapiMessageContentPart = {
|
|
305
|
+
image_url?: LlmapiMessageContentImage;
|
|
306
|
+
/**
|
|
307
|
+
* Text holds the text content when Type=text
|
|
308
|
+
*/
|
|
309
|
+
text?: string;
|
|
310
|
+
/**
|
|
311
|
+
* Type is the block type (`text` or `image_url`)
|
|
312
|
+
*/
|
|
313
|
+
type?: string;
|
|
314
|
+
};
|
|
201
315
|
type LlmapiModel = {
|
|
202
316
|
architecture?: LlmapiModelArchitecture;
|
|
203
317
|
/**
|
|
@@ -323,6 +437,80 @@ type LlmapiModelsListResponse = {
|
|
|
323
437
|
* Role is the message role (system, user, assistant)
|
|
324
438
|
*/
|
|
325
439
|
type LlmapiRole = string;
|
|
440
|
+
/**
|
|
441
|
+
* ExtraFields contains additional metadata.
|
|
442
|
+
*/
|
|
443
|
+
type LlmapiSearchExtraFields = {
|
|
444
|
+
/**
|
|
445
|
+
* RequestType is always "search".
|
|
446
|
+
*/
|
|
447
|
+
request_type?: string;
|
|
448
|
+
/**
|
|
449
|
+
* SearchProvider is the search provider used (e.g., "perplexity", "google-pse").
|
|
450
|
+
*/
|
|
451
|
+
search_provider?: string;
|
|
452
|
+
};
|
|
453
|
+
type LlmapiSearchRequest = {
|
|
454
|
+
/**
|
|
455
|
+
* Country code filter (e.g., "US", "GB", "DE").
|
|
456
|
+
*/
|
|
457
|
+
country?: string;
|
|
458
|
+
/**
|
|
459
|
+
* Maximum number of results to return (1-20). Default: 10.
|
|
460
|
+
*/
|
|
461
|
+
max_results?: number;
|
|
462
|
+
/**
|
|
463
|
+
* Maximum tokens per page to process. Default: 1024.
|
|
464
|
+
*/
|
|
465
|
+
max_tokens_per_page?: number;
|
|
466
|
+
/**
|
|
467
|
+
* Search query. Can be a single string or array of strings.
|
|
468
|
+
*/
|
|
469
|
+
query?: Array<string>;
|
|
470
|
+
/**
|
|
471
|
+
* List of domains to filter results (max 20 domains).
|
|
472
|
+
*/
|
|
473
|
+
search_domain_filter?: Array<string>;
|
|
474
|
+
/**
|
|
475
|
+
* The search provider to use.
|
|
476
|
+
*/
|
|
477
|
+
search_tool_name?: string;
|
|
478
|
+
};
|
|
479
|
+
type LlmapiSearchResponse = {
|
|
480
|
+
extra_fields?: LlmapiSearchExtraFields;
|
|
481
|
+
/**
|
|
482
|
+
* List of search results.
|
|
483
|
+
*/
|
|
484
|
+
results?: Array<LlmapiSearchResult>;
|
|
485
|
+
usage?: LlmapiSearchUsage;
|
|
486
|
+
};
|
|
487
|
+
type LlmapiSearchResult = {
|
|
488
|
+
/**
|
|
489
|
+
* Optional publication or last updated date.
|
|
490
|
+
*/
|
|
491
|
+
date?: string;
|
|
492
|
+
/**
|
|
493
|
+
* Text snippet from the result.
|
|
494
|
+
*/
|
|
495
|
+
snippet?: string;
|
|
496
|
+
/**
|
|
497
|
+
* Title of the search result.
|
|
498
|
+
*/
|
|
499
|
+
title?: string;
|
|
500
|
+
/**
|
|
501
|
+
* URL of the search result.
|
|
502
|
+
*/
|
|
503
|
+
url?: string;
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* Usage contains usage information.
|
|
507
|
+
*/
|
|
508
|
+
type LlmapiSearchUsage = {
|
|
509
|
+
/**
|
|
510
|
+
* CostMicroUSD is the cost of this search in micro-dollars (USD × 1,000,000).
|
|
511
|
+
*/
|
|
512
|
+
cost_micro_usd?: number;
|
|
513
|
+
};
|
|
326
514
|
type ResponseErrorResponse = {
|
|
327
515
|
error?: string;
|
|
328
516
|
};
|
|
@@ -380,6 +568,37 @@ type PostApiV1EmbeddingsResponses = {
|
|
|
380
568
|
200: LlmapiEmbeddingResponse;
|
|
381
569
|
};
|
|
382
570
|
type PostApiV1EmbeddingsResponse = PostApiV1EmbeddingsResponses[keyof PostApiV1EmbeddingsResponses];
|
|
571
|
+
type PostApiV1ImagesGenerationsData = {
|
|
572
|
+
/**
|
|
573
|
+
* Image generation request
|
|
574
|
+
*/
|
|
575
|
+
body: LlmapiImageGenerationRequest;
|
|
576
|
+
path?: never;
|
|
577
|
+
query?: never;
|
|
578
|
+
url: '/api/v1/images/generations';
|
|
579
|
+
};
|
|
580
|
+
type PostApiV1ImagesGenerationsErrors = {
|
|
581
|
+
/**
|
|
582
|
+
* Bad Request
|
|
583
|
+
*/
|
|
584
|
+
400: ResponseErrorResponse;
|
|
585
|
+
/**
|
|
586
|
+
* Internal Server Error
|
|
587
|
+
*/
|
|
588
|
+
500: ResponseErrorResponse;
|
|
589
|
+
/**
|
|
590
|
+
* Not Implemented
|
|
591
|
+
*/
|
|
592
|
+
501: ResponseErrorResponse;
|
|
593
|
+
};
|
|
594
|
+
type PostApiV1ImagesGenerationsError = PostApiV1ImagesGenerationsErrors[keyof PostApiV1ImagesGenerationsErrors];
|
|
595
|
+
type PostApiV1ImagesGenerationsResponses = {
|
|
596
|
+
/**
|
|
597
|
+
* OK
|
|
598
|
+
*/
|
|
599
|
+
200: LlmapiImageGenerationResponse;
|
|
600
|
+
};
|
|
601
|
+
type PostApiV1ImagesGenerationsResponse = PostApiV1ImagesGenerationsResponses[keyof PostApiV1ImagesGenerationsResponses];
|
|
383
602
|
type GetApiV1ModelsData = {
|
|
384
603
|
body?: never;
|
|
385
604
|
path?: never;
|
|
@@ -417,6 +636,33 @@ type GetApiV1ModelsResponses = {
|
|
|
417
636
|
200: LlmapiModelsListResponse;
|
|
418
637
|
};
|
|
419
638
|
type GetApiV1ModelsResponse = GetApiV1ModelsResponses[keyof GetApiV1ModelsResponses];
|
|
639
|
+
type PostApiV1SearchData = {
|
|
640
|
+
/**
|
|
641
|
+
* Search request
|
|
642
|
+
*/
|
|
643
|
+
body: LlmapiSearchRequest;
|
|
644
|
+
path?: never;
|
|
645
|
+
query?: never;
|
|
646
|
+
url: '/api/v1/search';
|
|
647
|
+
};
|
|
648
|
+
type PostApiV1SearchErrors = {
|
|
649
|
+
/**
|
|
650
|
+
* Bad Request
|
|
651
|
+
*/
|
|
652
|
+
400: ResponseErrorResponse;
|
|
653
|
+
/**
|
|
654
|
+
* Internal Server Error
|
|
655
|
+
*/
|
|
656
|
+
500: ResponseErrorResponse;
|
|
657
|
+
};
|
|
658
|
+
type PostApiV1SearchError = PostApiV1SearchErrors[keyof PostApiV1SearchErrors];
|
|
659
|
+
type PostApiV1SearchResponses = {
|
|
660
|
+
/**
|
|
661
|
+
* OK
|
|
662
|
+
*/
|
|
663
|
+
200: LlmapiSearchResponse;
|
|
664
|
+
};
|
|
665
|
+
type PostApiV1SearchResponse = PostApiV1SearchResponses[keyof PostApiV1SearchResponses];
|
|
420
666
|
type GetHealthData = {
|
|
421
667
|
body?: never;
|
|
422
668
|
path?: never;
|
|
@@ -752,12 +998,24 @@ declare const postApiV1ChatCompletions: <ThrowOnError extends boolean = false>(o
|
|
|
752
998
|
* Generates embeddings using the configured gateway.
|
|
753
999
|
*/
|
|
754
1000
|
declare const postApiV1Embeddings: <ThrowOnError extends boolean = false>(options: Options<PostApiV1EmbeddingsData, ThrowOnError>) => RequestResult<PostApiV1EmbeddingsResponses, PostApiV1EmbeddingsErrors, ThrowOnError>;
|
|
1001
|
+
/**
|
|
1002
|
+
* Generate images
|
|
1003
|
+
*
|
|
1004
|
+
* Generates images using the configured LLM gateway.
|
|
1005
|
+
*/
|
|
1006
|
+
declare const postApiV1ImagesGenerations: <ThrowOnError extends boolean = false>(options: Options<PostApiV1ImagesGenerationsData, ThrowOnError>) => RequestResult<PostApiV1ImagesGenerationsResponses, PostApiV1ImagesGenerationsErrors, ThrowOnError>;
|
|
755
1007
|
/**
|
|
756
1008
|
* List available models
|
|
757
1009
|
*
|
|
758
1010
|
* Returns a list of all available models from the configured gateway with optional filters.
|
|
759
1011
|
*/
|
|
760
1012
|
declare const getApiV1Models: <ThrowOnError extends boolean = false>(options?: Options<GetApiV1ModelsData, ThrowOnError>) => RequestResult<GetApiV1ModelsResponses, GetApiV1ModelsErrors, ThrowOnError>;
|
|
1013
|
+
/**
|
|
1014
|
+
* Create search
|
|
1015
|
+
*
|
|
1016
|
+
* Returns a list of ranked search results
|
|
1017
|
+
*/
|
|
1018
|
+
declare const postApiV1Search: <ThrowOnError extends boolean = false>(options: Options<PostApiV1SearchData, ThrowOnError>) => RequestResult<PostApiV1SearchResponses, PostApiV1SearchErrors, ThrowOnError>;
|
|
761
1019
|
/**
|
|
762
1020
|
* Health check
|
|
763
1021
|
*
|
|
@@ -765,4 +1023,4 @@ declare const getApiV1Models: <ThrowOnError extends boolean = false>(options?: O
|
|
|
765
1023
|
*/
|
|
766
1024
|
declare const getHealth: <ThrowOnError extends boolean = false>(options?: Options<GetHealthData, ThrowOnError>) => RequestResult<GetHealthResponses, GetHealthErrors, ThrowOnError>;
|
|
767
1025
|
|
|
768
|
-
export { type ClientOptions$1 as ClientOptions, type GetApiV1ModelsData, type GetApiV1ModelsError, type GetApiV1ModelsErrors, type GetApiV1ModelsResponse, type GetApiV1ModelsResponses, type GetHealthData, type GetHealthError, type GetHealthErrors, type GetHealthResponse, type GetHealthResponses, type HandlersHealthResponse, type LlmapiChatCompletionExtraFields, type LlmapiChatCompletionRequest, type LlmapiChatCompletionResponse, type LlmapiChatCompletionUsage, type LlmapiChoice, type LlmapiEmbeddingData, type LlmapiEmbeddingExtraFields, type LlmapiEmbeddingRequest, type LlmapiEmbeddingResponse, type LlmapiEmbeddingUsage, type LlmapiMessage, type LlmapiModel, type LlmapiModelArchitecture, type LlmapiModelPerRequestLimits, type LlmapiModelPricing, type LlmapiModelTopProvider, type LlmapiModelsListExtraFields, type LlmapiModelsListResponse, type LlmapiRole, type Options, type PostApiV1ChatCompletionsData, type PostApiV1ChatCompletionsError, type PostApiV1ChatCompletionsErrors, type PostApiV1ChatCompletionsResponse, type PostApiV1ChatCompletionsResponses, type PostApiV1EmbeddingsData, type PostApiV1EmbeddingsError, type PostApiV1EmbeddingsErrors, type PostApiV1EmbeddingsResponse, type PostApiV1EmbeddingsResponses, type ResponseErrorResponse, getApiV1Models, getHealth, postApiV1ChatCompletions, postApiV1Embeddings };
|
|
1026
|
+
export { type ClientOptions$1 as ClientOptions, type GetApiV1ModelsData, type GetApiV1ModelsError, type GetApiV1ModelsErrors, type GetApiV1ModelsResponse, type GetApiV1ModelsResponses, type GetHealthData, type GetHealthError, type GetHealthErrors, type GetHealthResponse, type GetHealthResponses, type HandlersHealthResponse, type LlmapiChatCompletionExtraFields, type LlmapiChatCompletionRequest, type LlmapiChatCompletionResponse, type LlmapiChatCompletionUsage, type LlmapiChoice, type LlmapiEmbeddingData, type LlmapiEmbeddingExtraFields, type LlmapiEmbeddingRequest, type LlmapiEmbeddingResponse, type LlmapiEmbeddingUsage, type LlmapiImageGenerationExtraFields, type LlmapiImageGenerationImage, type LlmapiImageGenerationRequest, type LlmapiImageGenerationResponse, type LlmapiImageGenerationUsage, type LlmapiMessage, type LlmapiMessageContentImage, type LlmapiMessageContentPart, type LlmapiModel, type LlmapiModelArchitecture, type LlmapiModelPerRequestLimits, type LlmapiModelPricing, type LlmapiModelTopProvider, type LlmapiModelsListExtraFields, type LlmapiModelsListResponse, type LlmapiRole, type LlmapiSearchExtraFields, type LlmapiSearchRequest, type LlmapiSearchResponse, type LlmapiSearchResult, type LlmapiSearchUsage, type Options, type PostApiV1ChatCompletionsData, type PostApiV1ChatCompletionsError, type PostApiV1ChatCompletionsErrors, type PostApiV1ChatCompletionsResponse, type PostApiV1ChatCompletionsResponses, type PostApiV1EmbeddingsData, type PostApiV1EmbeddingsError, type PostApiV1EmbeddingsErrors, type PostApiV1EmbeddingsResponse, type PostApiV1EmbeddingsResponses, type PostApiV1ImagesGenerationsData, type PostApiV1ImagesGenerationsError, type PostApiV1ImagesGenerationsErrors, type PostApiV1ImagesGenerationsResponse, type PostApiV1ImagesGenerationsResponses, type PostApiV1SearchData, type PostApiV1SearchError, type PostApiV1SearchErrors, type PostApiV1SearchResponse, type PostApiV1SearchResponses, type ResponseErrorResponse, getApiV1Models, getHealth, postApiV1ChatCompletions, postApiV1Embeddings, postApiV1ImagesGenerations, postApiV1Search };
|
package/dist/index.mjs
CHANGED
|
@@ -834,12 +834,32 @@ var postApiV1Embeddings = (options) => {
|
|
|
834
834
|
}
|
|
835
835
|
});
|
|
836
836
|
};
|
|
837
|
+
var postApiV1ImagesGenerations = (options) => {
|
|
838
|
+
return (options.client ?? client).post({
|
|
839
|
+
url: "/api/v1/images/generations",
|
|
840
|
+
...options,
|
|
841
|
+
headers: {
|
|
842
|
+
"Content-Type": "application/json",
|
|
843
|
+
...options.headers
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
};
|
|
837
847
|
var getApiV1Models = (options) => {
|
|
838
848
|
return (options?.client ?? client).get({
|
|
839
849
|
url: "/api/v1/models",
|
|
840
850
|
...options
|
|
841
851
|
});
|
|
842
852
|
};
|
|
853
|
+
var postApiV1Search = (options) => {
|
|
854
|
+
return (options.client ?? client).post({
|
|
855
|
+
url: "/api/v1/search",
|
|
856
|
+
...options,
|
|
857
|
+
headers: {
|
|
858
|
+
"Content-Type": "application/json",
|
|
859
|
+
...options.headers
|
|
860
|
+
}
|
|
861
|
+
});
|
|
862
|
+
};
|
|
843
863
|
var getHealth = (options) => {
|
|
844
864
|
return (options?.client ?? client).get({
|
|
845
865
|
url: "/health",
|
|
@@ -850,5 +870,7 @@ export {
|
|
|
850
870
|
getApiV1Models,
|
|
851
871
|
getHealth,
|
|
852
872
|
postApiV1ChatCompletions,
|
|
853
|
-
postApiV1Embeddings
|
|
873
|
+
postApiV1Embeddings,
|
|
874
|
+
postApiV1ImagesGenerations,
|
|
875
|
+
postApiV1Search
|
|
854
876
|
};
|
package/dist/react/index.cjs
CHANGED
|
@@ -47775,15 +47775,12 @@ function useChat(options) {
|
|
|
47775
47775
|
const lastUserMessage = [...messages].reverse().find((m) => m.role === "user");
|
|
47776
47776
|
if (lastUserMessage?.content) {
|
|
47777
47777
|
setIsSelectingTool(true);
|
|
47778
|
+
const contentString = lastUserMessage.content?.map((part) => part.text || "").join("") || "";
|
|
47778
47779
|
try {
|
|
47779
|
-
const selectionResult = await selectTool(
|
|
47780
|
-
|
|
47781
|
-
|
|
47782
|
-
|
|
47783
|
-
model: toolSelectorModel,
|
|
47784
|
-
signal: abortController.signal
|
|
47785
|
-
}
|
|
47786
|
-
);
|
|
47780
|
+
const selectionResult = await selectTool(contentString, tools, {
|
|
47781
|
+
model: toolSelectorModel,
|
|
47782
|
+
signal: abortController.signal
|
|
47783
|
+
});
|
|
47787
47784
|
if (selectionResult.toolSelected && selectionResult.toolName) {
|
|
47788
47785
|
const selectedTool = tools.find(
|
|
47789
47786
|
(t) => t.name === selectionResult.toolName
|
|
@@ -47805,22 +47802,32 @@ function useChat(options) {
|
|
|
47805
47802
|
if (toolExecutionResult.success && toolExecutionResult.result !== void 0) {
|
|
47806
47803
|
const toolResultContext = {
|
|
47807
47804
|
role: "system",
|
|
47808
|
-
content:
|
|
47805
|
+
content: [
|
|
47806
|
+
{
|
|
47807
|
+
type: "text",
|
|
47808
|
+
text: `Tool "${toolExecutionResult.toolName}" was executed with the following result:
|
|
47809
47809
|
${JSON.stringify(
|
|
47810
|
-
|
|
47811
|
-
|
|
47812
|
-
|
|
47813
|
-
|
|
47810
|
+
toolExecutionResult.result,
|
|
47811
|
+
null,
|
|
47812
|
+
2
|
|
47813
|
+
)}
|
|
47814
47814
|
|
|
47815
47815
|
Use this information to respond to the user's request.`
|
|
47816
|
+
}
|
|
47817
|
+
]
|
|
47816
47818
|
};
|
|
47817
47819
|
messagesWithToolContext = [...messages, toolResultContext];
|
|
47818
47820
|
} else if (toolExecutionResult.error) {
|
|
47819
47821
|
const toolErrorContext = {
|
|
47820
47822
|
role: "system",
|
|
47821
|
-
content:
|
|
47823
|
+
content: [
|
|
47824
|
+
{
|
|
47825
|
+
type: "text",
|
|
47826
|
+
text: `Tool "${toolExecutionResult.toolName}" was executed but encountered an error: ${toolExecutionResult.error}
|
|
47822
47827
|
|
|
47823
47828
|
Please inform the user about this issue and try to help them alternatively.`
|
|
47829
|
+
}
|
|
47830
|
+
]
|
|
47824
47831
|
};
|
|
47825
47832
|
messagesWithToolContext = [...messages, toolErrorContext];
|
|
47826
47833
|
}
|
|
@@ -47839,7 +47846,7 @@ Please inform the user about this issue and try to help them alternatively.`
|
|
|
47839
47846
|
const usedModel = localModel;
|
|
47840
47847
|
const formattedMessages = messagesWithToolContext.map((m) => ({
|
|
47841
47848
|
role: m.role || "user",
|
|
47842
|
-
content: m.content || ""
|
|
47849
|
+
content: m.content?.map((p) => p.text || "").join("") || ""
|
|
47843
47850
|
}));
|
|
47844
47851
|
await generateLocalChatCompletion(formattedMessages, {
|
|
47845
47852
|
model: usedModel,
|
|
@@ -47858,7 +47865,7 @@ Please inform the user about this issue and try to help them alternatively.`
|
|
|
47858
47865
|
index: 0,
|
|
47859
47866
|
message: {
|
|
47860
47867
|
role: "assistant",
|
|
47861
|
-
content: accumulatedContent
|
|
47868
|
+
content: [{ type: "text", text: accumulatedContent }]
|
|
47862
47869
|
},
|
|
47863
47870
|
finish_reason: "stop"
|
|
47864
47871
|
}
|
|
@@ -47972,7 +47979,7 @@ Please inform the user about this issue and try to help them alternatively.`
|
|
|
47972
47979
|
index: 0,
|
|
47973
47980
|
message: {
|
|
47974
47981
|
role: "assistant",
|
|
47975
|
-
content: accumulatedContent
|
|
47982
|
+
content: [{ type: "text", text: accumulatedContent }]
|
|
47976
47983
|
},
|
|
47977
47984
|
finish_reason: finishReason
|
|
47978
47985
|
}
|
|
@@ -48593,9 +48600,12 @@ function useMemory(options = {}) {
|
|
|
48593
48600
|
messages: [
|
|
48594
48601
|
{
|
|
48595
48602
|
role: "system",
|
|
48596
|
-
content: FACT_EXTRACTION_PROMPT
|
|
48603
|
+
content: [{ type: "text", text: FACT_EXTRACTION_PROMPT }]
|
|
48597
48604
|
},
|
|
48598
|
-
...messages
|
|
48605
|
+
...messages.map((m) => ({
|
|
48606
|
+
role: m.role,
|
|
48607
|
+
content: [{ type: "text", text: m.content }]
|
|
48608
|
+
}))
|
|
48599
48609
|
],
|
|
48600
48610
|
model: model || completionsModel
|
|
48601
48611
|
},
|
|
@@ -48616,7 +48626,13 @@ function useMemory(options = {}) {
|
|
|
48616
48626
|
);
|
|
48617
48627
|
return null;
|
|
48618
48628
|
}
|
|
48619
|
-
const
|
|
48629
|
+
const messageContent = completion.data.choices?.[0]?.message?.content;
|
|
48630
|
+
let content = "";
|
|
48631
|
+
if (Array.isArray(messageContent)) {
|
|
48632
|
+
content = messageContent.map((p) => p.text || "").join("").trim();
|
|
48633
|
+
} else if (typeof messageContent === "string") {
|
|
48634
|
+
content = messageContent.trim();
|
|
48635
|
+
}
|
|
48620
48636
|
if (!content) {
|
|
48621
48637
|
console.error("No content in memory extraction response");
|
|
48622
48638
|
return null;
|
package/dist/react/index.d.mts
CHANGED
|
@@ -74,9 +74,33 @@ type LlmapiMessage = {
|
|
|
74
74
|
/**
|
|
75
75
|
* Content is the message content
|
|
76
76
|
*/
|
|
77
|
-
content?:
|
|
77
|
+
content?: Array<LlmapiMessageContentPart>;
|
|
78
78
|
role?: LlmapiRole;
|
|
79
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* ImageURL is used when Type=image_url
|
|
82
|
+
*/
|
|
83
|
+
type LlmapiMessageContentImage = {
|
|
84
|
+
/**
|
|
85
|
+
* Detail is the OpenAI detail hint (auto|low|high)
|
|
86
|
+
*/
|
|
87
|
+
detail?: string;
|
|
88
|
+
/**
|
|
89
|
+
* URL is the image URL or data URI
|
|
90
|
+
*/
|
|
91
|
+
url?: string;
|
|
92
|
+
};
|
|
93
|
+
type LlmapiMessageContentPart = {
|
|
94
|
+
image_url?: LlmapiMessageContentImage;
|
|
95
|
+
/**
|
|
96
|
+
* Text holds the text content when Type=text
|
|
97
|
+
*/
|
|
98
|
+
text?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Type is the block type (`text` or `image_url`)
|
|
101
|
+
*/
|
|
102
|
+
type?: string;
|
|
103
|
+
};
|
|
80
104
|
type LlmapiModel = {
|
|
81
105
|
architecture?: LlmapiModelArchitecture;
|
|
82
106
|
/**
|
package/dist/react/index.d.ts
CHANGED
|
@@ -74,9 +74,33 @@ type LlmapiMessage = {
|
|
|
74
74
|
/**
|
|
75
75
|
* Content is the message content
|
|
76
76
|
*/
|
|
77
|
-
content?:
|
|
77
|
+
content?: Array<LlmapiMessageContentPart>;
|
|
78
78
|
role?: LlmapiRole;
|
|
79
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* ImageURL is used when Type=image_url
|
|
82
|
+
*/
|
|
83
|
+
type LlmapiMessageContentImage = {
|
|
84
|
+
/**
|
|
85
|
+
* Detail is the OpenAI detail hint (auto|low|high)
|
|
86
|
+
*/
|
|
87
|
+
detail?: string;
|
|
88
|
+
/**
|
|
89
|
+
* URL is the image URL or data URI
|
|
90
|
+
*/
|
|
91
|
+
url?: string;
|
|
92
|
+
};
|
|
93
|
+
type LlmapiMessageContentPart = {
|
|
94
|
+
image_url?: LlmapiMessageContentImage;
|
|
95
|
+
/**
|
|
96
|
+
* Text holds the text content when Type=text
|
|
97
|
+
*/
|
|
98
|
+
text?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Type is the block type (`text` or `image_url`)
|
|
101
|
+
*/
|
|
102
|
+
type?: string;
|
|
103
|
+
};
|
|
80
104
|
type LlmapiModel = {
|
|
81
105
|
architecture?: LlmapiModelArchitecture;
|
|
82
106
|
/**
|
package/dist/react/index.mjs
CHANGED
|
@@ -1090,15 +1090,12 @@ function useChat(options) {
|
|
|
1090
1090
|
const lastUserMessage = [...messages].reverse().find((m) => m.role === "user");
|
|
1091
1091
|
if (lastUserMessage?.content) {
|
|
1092
1092
|
setIsSelectingTool(true);
|
|
1093
|
+
const contentString = lastUserMessage.content?.map((part) => part.text || "").join("") || "";
|
|
1093
1094
|
try {
|
|
1094
|
-
const selectionResult = await selectTool(
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
model: toolSelectorModel,
|
|
1099
|
-
signal: abortController.signal
|
|
1100
|
-
}
|
|
1101
|
-
);
|
|
1095
|
+
const selectionResult = await selectTool(contentString, tools, {
|
|
1096
|
+
model: toolSelectorModel,
|
|
1097
|
+
signal: abortController.signal
|
|
1098
|
+
});
|
|
1102
1099
|
if (selectionResult.toolSelected && selectionResult.toolName) {
|
|
1103
1100
|
const selectedTool = tools.find(
|
|
1104
1101
|
(t) => t.name === selectionResult.toolName
|
|
@@ -1120,22 +1117,32 @@ function useChat(options) {
|
|
|
1120
1117
|
if (toolExecutionResult.success && toolExecutionResult.result !== void 0) {
|
|
1121
1118
|
const toolResultContext = {
|
|
1122
1119
|
role: "system",
|
|
1123
|
-
content:
|
|
1120
|
+
content: [
|
|
1121
|
+
{
|
|
1122
|
+
type: "text",
|
|
1123
|
+
text: `Tool "${toolExecutionResult.toolName}" was executed with the following result:
|
|
1124
1124
|
${JSON.stringify(
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1125
|
+
toolExecutionResult.result,
|
|
1126
|
+
null,
|
|
1127
|
+
2
|
|
1128
|
+
)}
|
|
1129
1129
|
|
|
1130
1130
|
Use this information to respond to the user's request.`
|
|
1131
|
+
}
|
|
1132
|
+
]
|
|
1131
1133
|
};
|
|
1132
1134
|
messagesWithToolContext = [...messages, toolResultContext];
|
|
1133
1135
|
} else if (toolExecutionResult.error) {
|
|
1134
1136
|
const toolErrorContext = {
|
|
1135
1137
|
role: "system",
|
|
1136
|
-
content:
|
|
1138
|
+
content: [
|
|
1139
|
+
{
|
|
1140
|
+
type: "text",
|
|
1141
|
+
text: `Tool "${toolExecutionResult.toolName}" was executed but encountered an error: ${toolExecutionResult.error}
|
|
1137
1142
|
|
|
1138
1143
|
Please inform the user about this issue and try to help them alternatively.`
|
|
1144
|
+
}
|
|
1145
|
+
]
|
|
1139
1146
|
};
|
|
1140
1147
|
messagesWithToolContext = [...messages, toolErrorContext];
|
|
1141
1148
|
}
|
|
@@ -1154,7 +1161,7 @@ Please inform the user about this issue and try to help them alternatively.`
|
|
|
1154
1161
|
const usedModel = localModel;
|
|
1155
1162
|
const formattedMessages = messagesWithToolContext.map((m) => ({
|
|
1156
1163
|
role: m.role || "user",
|
|
1157
|
-
content: m.content || ""
|
|
1164
|
+
content: m.content?.map((p) => p.text || "").join("") || ""
|
|
1158
1165
|
}));
|
|
1159
1166
|
await generateLocalChatCompletion(formattedMessages, {
|
|
1160
1167
|
model: usedModel,
|
|
@@ -1173,7 +1180,7 @@ Please inform the user about this issue and try to help them alternatively.`
|
|
|
1173
1180
|
index: 0,
|
|
1174
1181
|
message: {
|
|
1175
1182
|
role: "assistant",
|
|
1176
|
-
content: accumulatedContent
|
|
1183
|
+
content: [{ type: "text", text: accumulatedContent }]
|
|
1177
1184
|
},
|
|
1178
1185
|
finish_reason: "stop"
|
|
1179
1186
|
}
|
|
@@ -1287,7 +1294,7 @@ Please inform the user about this issue and try to help them alternatively.`
|
|
|
1287
1294
|
index: 0,
|
|
1288
1295
|
message: {
|
|
1289
1296
|
role: "assistant",
|
|
1290
|
-
content: accumulatedContent
|
|
1297
|
+
content: [{ type: "text", text: accumulatedContent }]
|
|
1291
1298
|
},
|
|
1292
1299
|
finish_reason: finishReason
|
|
1293
1300
|
}
|
|
@@ -1908,9 +1915,12 @@ function useMemory(options = {}) {
|
|
|
1908
1915
|
messages: [
|
|
1909
1916
|
{
|
|
1910
1917
|
role: "system",
|
|
1911
|
-
content: FACT_EXTRACTION_PROMPT
|
|
1918
|
+
content: [{ type: "text", text: FACT_EXTRACTION_PROMPT }]
|
|
1912
1919
|
},
|
|
1913
|
-
...messages
|
|
1920
|
+
...messages.map((m) => ({
|
|
1921
|
+
role: m.role,
|
|
1922
|
+
content: [{ type: "text", text: m.content }]
|
|
1923
|
+
}))
|
|
1914
1924
|
],
|
|
1915
1925
|
model: model || completionsModel
|
|
1916
1926
|
},
|
|
@@ -1931,7 +1941,13 @@ function useMemory(options = {}) {
|
|
|
1931
1941
|
);
|
|
1932
1942
|
return null;
|
|
1933
1943
|
}
|
|
1934
|
-
const
|
|
1944
|
+
const messageContent = completion.data.choices?.[0]?.message?.content;
|
|
1945
|
+
let content = "";
|
|
1946
|
+
if (Array.isArray(messageContent)) {
|
|
1947
|
+
content = messageContent.map((p) => p.text || "").join("").trim();
|
|
1948
|
+
} else if (typeof messageContent === "string") {
|
|
1949
|
+
content = messageContent.trim();
|
|
1950
|
+
}
|
|
1935
1951
|
if (!content) {
|
|
1936
1952
|
console.error("No content in memory extraction response");
|
|
1937
1953
|
return null;
|
package/dist/vercel/index.cjs
CHANGED
package/dist/vercel/index.d.mts
CHANGED
|
@@ -7,9 +7,33 @@ type LlmapiMessage = {
|
|
|
7
7
|
/**
|
|
8
8
|
* Content is the message content
|
|
9
9
|
*/
|
|
10
|
-
content?:
|
|
10
|
+
content?: Array<LlmapiMessageContentPart>;
|
|
11
11
|
role?: LlmapiRole;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* ImageURL is used when Type=image_url
|
|
15
|
+
*/
|
|
16
|
+
type LlmapiMessageContentImage = {
|
|
17
|
+
/**
|
|
18
|
+
* Detail is the OpenAI detail hint (auto|low|high)
|
|
19
|
+
*/
|
|
20
|
+
detail?: string;
|
|
21
|
+
/**
|
|
22
|
+
* URL is the image URL or data URI
|
|
23
|
+
*/
|
|
24
|
+
url?: string;
|
|
25
|
+
};
|
|
26
|
+
type LlmapiMessageContentPart = {
|
|
27
|
+
image_url?: LlmapiMessageContentImage;
|
|
28
|
+
/**
|
|
29
|
+
* Text holds the text content when Type=text
|
|
30
|
+
*/
|
|
31
|
+
text?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Type is the block type (`text` or `image_url`)
|
|
34
|
+
*/
|
|
35
|
+
type?: string;
|
|
36
|
+
};
|
|
13
37
|
/**
|
|
14
38
|
* Role is the message role (system, user, assistant)
|
|
15
39
|
*/
|
package/dist/vercel/index.d.ts
CHANGED
|
@@ -7,9 +7,33 @@ type LlmapiMessage = {
|
|
|
7
7
|
/**
|
|
8
8
|
* Content is the message content
|
|
9
9
|
*/
|
|
10
|
-
content?:
|
|
10
|
+
content?: Array<LlmapiMessageContentPart>;
|
|
11
11
|
role?: LlmapiRole;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* ImageURL is used when Type=image_url
|
|
15
|
+
*/
|
|
16
|
+
type LlmapiMessageContentImage = {
|
|
17
|
+
/**
|
|
18
|
+
* Detail is the OpenAI detail hint (auto|low|high)
|
|
19
|
+
*/
|
|
20
|
+
detail?: string;
|
|
21
|
+
/**
|
|
22
|
+
* URL is the image URL or data URI
|
|
23
|
+
*/
|
|
24
|
+
url?: string;
|
|
25
|
+
};
|
|
26
|
+
type LlmapiMessageContentPart = {
|
|
27
|
+
image_url?: LlmapiMessageContentImage;
|
|
28
|
+
/**
|
|
29
|
+
* Text holds the text content when Type=text
|
|
30
|
+
*/
|
|
31
|
+
text?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Type is the block type (`text` or `image_url`)
|
|
34
|
+
*/
|
|
35
|
+
type?: string;
|
|
36
|
+
};
|
|
13
37
|
/**
|
|
14
38
|
* Role is the message role (system, user, assistant)
|
|
15
39
|
*/
|
package/dist/vercel/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reverbia/sdk",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.20251202130234",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"homepage": "https://github.com/zeta-chain/ai-sdk#readme",
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@huggingface/transformers": "^3.8.0",
|
|
60
|
-
"@reverbia/portal": "1.0.0-next.
|
|
60
|
+
"@reverbia/portal": "1.0.0-next.20251201184846",
|
|
61
61
|
"ai": "5.0.93"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|