@reverbia/sdk 1.0.0-next.20251219162520 → 1.0.0-next.20251220010649
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/expo/index.cjs +39 -1
- package/dist/expo/index.d.mts +42 -0
- package/dist/expo/index.d.ts +42 -0
- package/dist/expo/index.mjs +39 -1
- package/dist/index.cjs +12 -0
- package/dist/index.d.mts +243 -4
- package/dist/index.d.ts +243 -4
- package/dist/index.mjs +11 -0
- package/dist/react/index.cjs +39 -1
- package/dist/react/index.d.mts +42 -0
- package/dist/react/index.d.ts +42 -0
- package/dist/react/index.mjs +39 -1
- package/dist/vercel/index.d.mts +28 -0
- package/dist/vercel/index.d.ts +28 -0
- package/package.json +2 -2
package/dist/expo/index.cjs
CHANGED
|
@@ -612,6 +612,37 @@ async function updateMessageErrorOp(ctx, uniqueId, error) {
|
|
|
612
612
|
});
|
|
613
613
|
return messageToStored(message);
|
|
614
614
|
}
|
|
615
|
+
async function updateMessageOp(ctx, uniqueId, opts) {
|
|
616
|
+
let message;
|
|
617
|
+
try {
|
|
618
|
+
message = await ctx.messagesCollection.find(uniqueId);
|
|
619
|
+
} catch {
|
|
620
|
+
return null;
|
|
621
|
+
}
|
|
622
|
+
await ctx.database.write(async () => {
|
|
623
|
+
await message.update((msg) => {
|
|
624
|
+
if (opts.content !== void 0) msg._setRaw("content", opts.content);
|
|
625
|
+
if (opts.model !== void 0) msg._setRaw("model", opts.model);
|
|
626
|
+
if (opts.files !== void 0)
|
|
627
|
+
msg._setRaw("files", JSON.stringify(opts.files));
|
|
628
|
+
if (opts.usage !== void 0)
|
|
629
|
+
msg._setRaw("usage", JSON.stringify(opts.usage));
|
|
630
|
+
if (opts.sources !== void 0)
|
|
631
|
+
msg._setRaw("sources", JSON.stringify(opts.sources));
|
|
632
|
+
if (opts.responseDuration !== void 0)
|
|
633
|
+
msg._setRaw("response_duration", opts.responseDuration);
|
|
634
|
+
if (opts.vector !== void 0)
|
|
635
|
+
msg._setRaw("vector", JSON.stringify(opts.vector));
|
|
636
|
+
if (opts.embeddingModel !== void 0)
|
|
637
|
+
msg._setRaw("embedding_model", opts.embeddingModel);
|
|
638
|
+
if (opts.wasStopped !== void 0)
|
|
639
|
+
msg._setRaw("was_stopped", opts.wasStopped);
|
|
640
|
+
if (opts.error !== void 0)
|
|
641
|
+
msg._setRaw("error", opts.error === null ? "" : opts.error);
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
return messageToStored(message);
|
|
645
|
+
}
|
|
615
646
|
|
|
616
647
|
// src/expo/useChatStorage.ts
|
|
617
648
|
function storedToLlmapiMessage(stored) {
|
|
@@ -728,6 +759,12 @@ function useChatStorage(options) {
|
|
|
728
759
|
},
|
|
729
760
|
[storageCtx]
|
|
730
761
|
);
|
|
762
|
+
const updateMessage = (0, import_react2.useCallback)(
|
|
763
|
+
async (uniqueId, options2) => {
|
|
764
|
+
return updateMessageOp(storageCtx, uniqueId, options2);
|
|
765
|
+
},
|
|
766
|
+
[storageCtx]
|
|
767
|
+
);
|
|
731
768
|
const ensureConversation = (0, import_react2.useCallback)(async () => {
|
|
732
769
|
if (currentConversationId) {
|
|
733
770
|
const existing = await getConversation(currentConversationId);
|
|
@@ -939,7 +976,8 @@ function useChatStorage(options) {
|
|
|
939
976
|
deleteConversation,
|
|
940
977
|
getMessages,
|
|
941
978
|
getMessageCount,
|
|
942
|
-
clearMessages
|
|
979
|
+
clearMessages,
|
|
980
|
+
updateMessage
|
|
943
981
|
};
|
|
944
982
|
}
|
|
945
983
|
|
package/dist/expo/index.d.mts
CHANGED
|
@@ -172,6 +172,10 @@ type LlmapiMessage = {
|
|
|
172
172
|
*/
|
|
173
173
|
content?: Array<LlmapiMessageContentPart>;
|
|
174
174
|
role?: LlmapiRole;
|
|
175
|
+
/**
|
|
176
|
+
* ToolCalls contains tool/function calls made by the assistant (only for assistant role)
|
|
177
|
+
*/
|
|
178
|
+
tool_calls?: Array<LlmapiToolCall>;
|
|
175
179
|
};
|
|
176
180
|
/**
|
|
177
181
|
* ImageURL is used when Type=image_url
|
|
@@ -298,6 +302,30 @@ type LlmapiModelTopProvider = {
|
|
|
298
302
|
* Role is the message role (system, user, assistant)
|
|
299
303
|
*/
|
|
300
304
|
type LlmapiRole = string;
|
|
305
|
+
type LlmapiToolCall = {
|
|
306
|
+
function?: LlmapiToolCallFunction;
|
|
307
|
+
/**
|
|
308
|
+
* ID is the unique identifier for this tool call
|
|
309
|
+
*/
|
|
310
|
+
id?: string;
|
|
311
|
+
/**
|
|
312
|
+
* Type is the type of tool call (always "function" for now)
|
|
313
|
+
*/
|
|
314
|
+
type?: string;
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* Function contains the function call details
|
|
318
|
+
*/
|
|
319
|
+
type LlmapiToolCallFunction = {
|
|
320
|
+
/**
|
|
321
|
+
* Arguments is the JSON string of arguments to pass to the function
|
|
322
|
+
*/
|
|
323
|
+
arguments?: string;
|
|
324
|
+
/**
|
|
325
|
+
* Name is the name of the function to call
|
|
326
|
+
*/
|
|
327
|
+
name?: string;
|
|
328
|
+
};
|
|
301
329
|
|
|
302
330
|
/**
|
|
303
331
|
* Base arguments for sending a message
|
|
@@ -490,6 +518,18 @@ interface CreateConversationOptions {
|
|
|
490
518
|
conversationId?: string;
|
|
491
519
|
title?: string;
|
|
492
520
|
}
|
|
521
|
+
interface UpdateMessageOptions {
|
|
522
|
+
content?: string;
|
|
523
|
+
model?: string;
|
|
524
|
+
files?: FileMetadata[];
|
|
525
|
+
usage?: ChatCompletionUsage;
|
|
526
|
+
sources?: SearchSource[];
|
|
527
|
+
responseDuration?: number;
|
|
528
|
+
vector?: number[];
|
|
529
|
+
embeddingModel?: string;
|
|
530
|
+
wasStopped?: boolean;
|
|
531
|
+
error?: string | null;
|
|
532
|
+
}
|
|
493
533
|
interface BaseUseChatStorageOptions {
|
|
494
534
|
database: Database;
|
|
495
535
|
conversationId?: string;
|
|
@@ -597,6 +637,8 @@ type SendMessageWithStorageResult = BaseSendMessageWithStorageResult;
|
|
|
597
637
|
interface UseChatStorageResult extends BaseUseChatStorageResult {
|
|
598
638
|
/** Send a message and automatically store it (Expo version) */
|
|
599
639
|
sendMessage: (args: SendMessageWithStorageArgs) => Promise<SendMessageWithStorageResult>;
|
|
640
|
+
/** Update a message's fields (content, embedding, files, etc). Returns updated message or null if not found. */
|
|
641
|
+
updateMessage: (uniqueId: string, options: UpdateMessageOptions) => Promise<StoredMessage | null>;
|
|
600
642
|
}
|
|
601
643
|
/**
|
|
602
644
|
* A React hook that wraps useChat with automatic message persistence using WatermelonDB.
|
package/dist/expo/index.d.ts
CHANGED
|
@@ -172,6 +172,10 @@ type LlmapiMessage = {
|
|
|
172
172
|
*/
|
|
173
173
|
content?: Array<LlmapiMessageContentPart>;
|
|
174
174
|
role?: LlmapiRole;
|
|
175
|
+
/**
|
|
176
|
+
* ToolCalls contains tool/function calls made by the assistant (only for assistant role)
|
|
177
|
+
*/
|
|
178
|
+
tool_calls?: Array<LlmapiToolCall>;
|
|
175
179
|
};
|
|
176
180
|
/**
|
|
177
181
|
* ImageURL is used when Type=image_url
|
|
@@ -298,6 +302,30 @@ type LlmapiModelTopProvider = {
|
|
|
298
302
|
* Role is the message role (system, user, assistant)
|
|
299
303
|
*/
|
|
300
304
|
type LlmapiRole = string;
|
|
305
|
+
type LlmapiToolCall = {
|
|
306
|
+
function?: LlmapiToolCallFunction;
|
|
307
|
+
/**
|
|
308
|
+
* ID is the unique identifier for this tool call
|
|
309
|
+
*/
|
|
310
|
+
id?: string;
|
|
311
|
+
/**
|
|
312
|
+
* Type is the type of tool call (always "function" for now)
|
|
313
|
+
*/
|
|
314
|
+
type?: string;
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* Function contains the function call details
|
|
318
|
+
*/
|
|
319
|
+
type LlmapiToolCallFunction = {
|
|
320
|
+
/**
|
|
321
|
+
* Arguments is the JSON string of arguments to pass to the function
|
|
322
|
+
*/
|
|
323
|
+
arguments?: string;
|
|
324
|
+
/**
|
|
325
|
+
* Name is the name of the function to call
|
|
326
|
+
*/
|
|
327
|
+
name?: string;
|
|
328
|
+
};
|
|
301
329
|
|
|
302
330
|
/**
|
|
303
331
|
* Base arguments for sending a message
|
|
@@ -490,6 +518,18 @@ interface CreateConversationOptions {
|
|
|
490
518
|
conversationId?: string;
|
|
491
519
|
title?: string;
|
|
492
520
|
}
|
|
521
|
+
interface UpdateMessageOptions {
|
|
522
|
+
content?: string;
|
|
523
|
+
model?: string;
|
|
524
|
+
files?: FileMetadata[];
|
|
525
|
+
usage?: ChatCompletionUsage;
|
|
526
|
+
sources?: SearchSource[];
|
|
527
|
+
responseDuration?: number;
|
|
528
|
+
vector?: number[];
|
|
529
|
+
embeddingModel?: string;
|
|
530
|
+
wasStopped?: boolean;
|
|
531
|
+
error?: string | null;
|
|
532
|
+
}
|
|
493
533
|
interface BaseUseChatStorageOptions {
|
|
494
534
|
database: Database;
|
|
495
535
|
conversationId?: string;
|
|
@@ -597,6 +637,8 @@ type SendMessageWithStorageResult = BaseSendMessageWithStorageResult;
|
|
|
597
637
|
interface UseChatStorageResult extends BaseUseChatStorageResult {
|
|
598
638
|
/** Send a message and automatically store it (Expo version) */
|
|
599
639
|
sendMessage: (args: SendMessageWithStorageArgs) => Promise<SendMessageWithStorageResult>;
|
|
640
|
+
/** Update a message's fields (content, embedding, files, etc). Returns updated message or null if not found. */
|
|
641
|
+
updateMessage: (uniqueId: string, options: UpdateMessageOptions) => Promise<StoredMessage | null>;
|
|
600
642
|
}
|
|
601
643
|
/**
|
|
602
644
|
* A React hook that wraps useChat with automatic message persistence using WatermelonDB.
|
package/dist/expo/index.mjs
CHANGED
|
@@ -576,6 +576,37 @@ async function updateMessageErrorOp(ctx, uniqueId, error) {
|
|
|
576
576
|
});
|
|
577
577
|
return messageToStored(message);
|
|
578
578
|
}
|
|
579
|
+
async function updateMessageOp(ctx, uniqueId, opts) {
|
|
580
|
+
let message;
|
|
581
|
+
try {
|
|
582
|
+
message = await ctx.messagesCollection.find(uniqueId);
|
|
583
|
+
} catch {
|
|
584
|
+
return null;
|
|
585
|
+
}
|
|
586
|
+
await ctx.database.write(async () => {
|
|
587
|
+
await message.update((msg) => {
|
|
588
|
+
if (opts.content !== void 0) msg._setRaw("content", opts.content);
|
|
589
|
+
if (opts.model !== void 0) msg._setRaw("model", opts.model);
|
|
590
|
+
if (opts.files !== void 0)
|
|
591
|
+
msg._setRaw("files", JSON.stringify(opts.files));
|
|
592
|
+
if (opts.usage !== void 0)
|
|
593
|
+
msg._setRaw("usage", JSON.stringify(opts.usage));
|
|
594
|
+
if (opts.sources !== void 0)
|
|
595
|
+
msg._setRaw("sources", JSON.stringify(opts.sources));
|
|
596
|
+
if (opts.responseDuration !== void 0)
|
|
597
|
+
msg._setRaw("response_duration", opts.responseDuration);
|
|
598
|
+
if (opts.vector !== void 0)
|
|
599
|
+
msg._setRaw("vector", JSON.stringify(opts.vector));
|
|
600
|
+
if (opts.embeddingModel !== void 0)
|
|
601
|
+
msg._setRaw("embedding_model", opts.embeddingModel);
|
|
602
|
+
if (opts.wasStopped !== void 0)
|
|
603
|
+
msg._setRaw("was_stopped", opts.wasStopped);
|
|
604
|
+
if (opts.error !== void 0)
|
|
605
|
+
msg._setRaw("error", opts.error === null ? "" : opts.error);
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
return messageToStored(message);
|
|
609
|
+
}
|
|
579
610
|
|
|
580
611
|
// src/expo/useChatStorage.ts
|
|
581
612
|
function storedToLlmapiMessage(stored) {
|
|
@@ -692,6 +723,12 @@ function useChatStorage(options) {
|
|
|
692
723
|
},
|
|
693
724
|
[storageCtx]
|
|
694
725
|
);
|
|
726
|
+
const updateMessage = useCallback2(
|
|
727
|
+
async (uniqueId, options2) => {
|
|
728
|
+
return updateMessageOp(storageCtx, uniqueId, options2);
|
|
729
|
+
},
|
|
730
|
+
[storageCtx]
|
|
731
|
+
);
|
|
695
732
|
const ensureConversation = useCallback2(async () => {
|
|
696
733
|
if (currentConversationId) {
|
|
697
734
|
const existing = await getConversation(currentConversationId);
|
|
@@ -903,7 +940,8 @@ function useChatStorage(options) {
|
|
|
903
940
|
deleteConversation,
|
|
904
941
|
getMessages,
|
|
905
942
|
getMessageCount,
|
|
906
|
-
clearMessages
|
|
943
|
+
clearMessages,
|
|
944
|
+
updateMessage
|
|
907
945
|
};
|
|
908
946
|
}
|
|
909
947
|
|
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
postApiV1ChatCompletions: () => postApiV1ChatCompletions,
|
|
27
27
|
postApiV1Embeddings: () => postApiV1Embeddings,
|
|
28
28
|
postApiV1ImagesGenerations: () => postApiV1ImagesGenerations,
|
|
29
|
+
postApiV1Responses: () => postApiV1Responses,
|
|
29
30
|
postApiV1Search: () => postApiV1Search,
|
|
30
31
|
postAuthOauthByProviderExchange: () => postAuthOauthByProviderExchange,
|
|
31
32
|
postAuthOauthByProviderRefresh: () => postAuthOauthByProviderRefresh,
|
|
@@ -891,6 +892,16 @@ var getApiV1Models = (options) => {
|
|
|
891
892
|
...options
|
|
892
893
|
});
|
|
893
894
|
};
|
|
895
|
+
var postApiV1Responses = (options) => {
|
|
896
|
+
return (options.client ?? client).post({
|
|
897
|
+
url: "/api/v1/responses",
|
|
898
|
+
...options,
|
|
899
|
+
headers: {
|
|
900
|
+
"Content-Type": "application/json",
|
|
901
|
+
...options.headers
|
|
902
|
+
}
|
|
903
|
+
});
|
|
904
|
+
};
|
|
894
905
|
var postApiV1Search = (options) => {
|
|
895
906
|
return (options.client ?? client).post({
|
|
896
907
|
url: "/api/v1/search",
|
|
@@ -945,6 +956,7 @@ var getHealth = (options) => {
|
|
|
945
956
|
postApiV1ChatCompletions,
|
|
946
957
|
postApiV1Embeddings,
|
|
947
958
|
postApiV1ImagesGenerations,
|
|
959
|
+
postApiV1Responses,
|
|
948
960
|
postApiV1Search,
|
|
949
961
|
postAuthOauthByProviderExchange,
|
|
950
962
|
postAuthOauthByProviderRefresh,
|
package/dist/index.d.mts
CHANGED
|
@@ -319,6 +319,10 @@ type LlmapiMessage = {
|
|
|
319
319
|
*/
|
|
320
320
|
content?: Array<LlmapiMessageContentPart>;
|
|
321
321
|
role?: LlmapiRole;
|
|
322
|
+
/**
|
|
323
|
+
* ToolCalls contains tool/function calls made by the assistant (only for assistant role)
|
|
324
|
+
*/
|
|
325
|
+
tool_calls?: Array<LlmapiToolCall>;
|
|
322
326
|
};
|
|
323
327
|
/**
|
|
324
328
|
* ImageURL is used when Type=image_url
|
|
@@ -469,6 +473,162 @@ type LlmapiModelsListResponse = {
|
|
|
469
473
|
*/
|
|
470
474
|
next_page_token?: string;
|
|
471
475
|
};
|
|
476
|
+
/**
|
|
477
|
+
* ExtraFields contains additional metadata
|
|
478
|
+
*/
|
|
479
|
+
type LlmapiResponseExtraFields = {
|
|
480
|
+
/**
|
|
481
|
+
* Latency is the request latency in milliseconds
|
|
482
|
+
*/
|
|
483
|
+
latency?: number;
|
|
484
|
+
/**
|
|
485
|
+
* ModelRequested is the model that was requested
|
|
486
|
+
*/
|
|
487
|
+
model_requested?: string;
|
|
488
|
+
/**
|
|
489
|
+
* Provider is the LLM provider used (e.g., "openai", "anthropic")
|
|
490
|
+
*/
|
|
491
|
+
provider?: string;
|
|
492
|
+
/**
|
|
493
|
+
* RequestType is always "responses"
|
|
494
|
+
*/
|
|
495
|
+
request_type?: string;
|
|
496
|
+
};
|
|
497
|
+
type LlmapiResponseOutputContent = {
|
|
498
|
+
/**
|
|
499
|
+
* Text is the text content
|
|
500
|
+
*/
|
|
501
|
+
text?: string;
|
|
502
|
+
/**
|
|
503
|
+
* Type is the content type (e.g., "output_text")
|
|
504
|
+
*/
|
|
505
|
+
type?: string;
|
|
506
|
+
};
|
|
507
|
+
type LlmapiResponseOutputItem = {
|
|
508
|
+
/**
|
|
509
|
+
* Arguments is the function arguments for function_call types
|
|
510
|
+
*/
|
|
511
|
+
arguments?: string;
|
|
512
|
+
/**
|
|
513
|
+
* CallID is the call ID for function_call types
|
|
514
|
+
*/
|
|
515
|
+
call_id?: string;
|
|
516
|
+
/**
|
|
517
|
+
* Content is the content array for message types
|
|
518
|
+
*/
|
|
519
|
+
content?: Array<LlmapiResponseOutputContent>;
|
|
520
|
+
/**
|
|
521
|
+
* ID is the unique identifier for this output item
|
|
522
|
+
*/
|
|
523
|
+
id?: string;
|
|
524
|
+
/**
|
|
525
|
+
* Name is the function name for function_call types
|
|
526
|
+
*/
|
|
527
|
+
name?: string;
|
|
528
|
+
/**
|
|
529
|
+
* Role is the role for message types (e.g., "assistant")
|
|
530
|
+
*/
|
|
531
|
+
role?: string;
|
|
532
|
+
/**
|
|
533
|
+
* Status is the status of this output item (e.g., "completed")
|
|
534
|
+
*/
|
|
535
|
+
status?: string;
|
|
536
|
+
/**
|
|
537
|
+
* Type is the output item type (e.g., "message", "function_call")
|
|
538
|
+
*/
|
|
539
|
+
type?: string;
|
|
540
|
+
};
|
|
541
|
+
type LlmapiResponseRequest = {
|
|
542
|
+
/**
|
|
543
|
+
* Background indicates if request should be processed in background
|
|
544
|
+
*/
|
|
545
|
+
background?: boolean;
|
|
546
|
+
/**
|
|
547
|
+
* Conversation is the conversation ID (optional)
|
|
548
|
+
*/
|
|
549
|
+
conversation?: string;
|
|
550
|
+
/**
|
|
551
|
+
* Input is the simple text input for the response
|
|
552
|
+
*/
|
|
553
|
+
input: string;
|
|
554
|
+
/**
|
|
555
|
+
* MaxOutputTokens is the maximum number of tokens to generate
|
|
556
|
+
*/
|
|
557
|
+
max_output_tokens?: number;
|
|
558
|
+
/**
|
|
559
|
+
* Model is the model identifier in 'provider/model' format
|
|
560
|
+
*/
|
|
561
|
+
model: string;
|
|
562
|
+
/**
|
|
563
|
+
* PreviousResponseID is the ID of a previous response to continue from
|
|
564
|
+
*/
|
|
565
|
+
previous_response_id?: string;
|
|
566
|
+
/**
|
|
567
|
+
* Store indicates if the response should be stored
|
|
568
|
+
*/
|
|
569
|
+
store?: boolean;
|
|
570
|
+
/**
|
|
571
|
+
* Stream indicates if response should be streamed
|
|
572
|
+
*/
|
|
573
|
+
stream?: boolean;
|
|
574
|
+
/**
|
|
575
|
+
* Temperature controls randomness (0.0 to 2.0)
|
|
576
|
+
*/
|
|
577
|
+
temperature?: number;
|
|
578
|
+
/**
|
|
579
|
+
* ToolChoice controls which tool to use (auto, any, none, required, or tool name)
|
|
580
|
+
*/
|
|
581
|
+
tool_choice?: string;
|
|
582
|
+
/**
|
|
583
|
+
* Tools is an array of tool definitions (passed through, no MCP loop)
|
|
584
|
+
*/
|
|
585
|
+
tools?: Array<LlmapiTool>;
|
|
586
|
+
};
|
|
587
|
+
type LlmapiResponseResponse = {
|
|
588
|
+
/**
|
|
589
|
+
* Created is the Unix timestamp of creation (created_at in OpenAI format)
|
|
590
|
+
*/
|
|
591
|
+
created_at?: number;
|
|
592
|
+
extra_fields?: LlmapiResponseExtraFields;
|
|
593
|
+
/**
|
|
594
|
+
* ID is the unique response identifier
|
|
595
|
+
*/
|
|
596
|
+
id?: string;
|
|
597
|
+
/**
|
|
598
|
+
* Model is the model used for generation
|
|
599
|
+
*/
|
|
600
|
+
model?: string;
|
|
601
|
+
/**
|
|
602
|
+
* Object is the response type (e.g., "response")
|
|
603
|
+
*/
|
|
604
|
+
object?: string;
|
|
605
|
+
/**
|
|
606
|
+
* Output is the array of output items (OpenAI Responses API format)
|
|
607
|
+
*/
|
|
608
|
+
output?: Array<LlmapiResponseOutputItem>;
|
|
609
|
+
usage?: LlmapiResponseUsage;
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Usage contains token usage information
|
|
613
|
+
*/
|
|
614
|
+
type LlmapiResponseUsage = {
|
|
615
|
+
/**
|
|
616
|
+
* CompletionTokens is the number of tokens in the completion
|
|
617
|
+
*/
|
|
618
|
+
completion_tokens?: number;
|
|
619
|
+
/**
|
|
620
|
+
* CostMicroUSD is the cost of this response in micro-dollars (USD × 1,000,000)
|
|
621
|
+
*/
|
|
622
|
+
cost_micro_usd?: number;
|
|
623
|
+
/**
|
|
624
|
+
* PromptTokens is the number of tokens in the prompt
|
|
625
|
+
*/
|
|
626
|
+
prompt_tokens?: number;
|
|
627
|
+
/**
|
|
628
|
+
* TotalTokens is the total number of tokens used
|
|
629
|
+
*/
|
|
630
|
+
total_tokens?: number;
|
|
631
|
+
};
|
|
472
632
|
/**
|
|
473
633
|
* Role is the message role (system, user, assistant)
|
|
474
634
|
*/
|
|
@@ -547,6 +707,52 @@ type LlmapiSearchUsage = {
|
|
|
547
707
|
*/
|
|
548
708
|
cost_micro_usd?: number;
|
|
549
709
|
};
|
|
710
|
+
type LlmapiTool = {
|
|
711
|
+
function?: LlmapiToolFunction;
|
|
712
|
+
/**
|
|
713
|
+
* Type is the tool type (function, code_interpreter, file_search, web_search)
|
|
714
|
+
*/
|
|
715
|
+
type?: string;
|
|
716
|
+
};
|
|
717
|
+
type LlmapiToolCall = {
|
|
718
|
+
function?: LlmapiToolCallFunction;
|
|
719
|
+
/**
|
|
720
|
+
* ID is the unique identifier for this tool call
|
|
721
|
+
*/
|
|
722
|
+
id?: string;
|
|
723
|
+
/**
|
|
724
|
+
* Type is the type of tool call (always "function" for now)
|
|
725
|
+
*/
|
|
726
|
+
type?: string;
|
|
727
|
+
};
|
|
728
|
+
/**
|
|
729
|
+
* Function contains the function call details
|
|
730
|
+
*/
|
|
731
|
+
type LlmapiToolCallFunction = {
|
|
732
|
+
/**
|
|
733
|
+
* Arguments is the JSON string of arguments to pass to the function
|
|
734
|
+
*/
|
|
735
|
+
arguments?: string;
|
|
736
|
+
/**
|
|
737
|
+
* Name is the name of the function to call
|
|
738
|
+
*/
|
|
739
|
+
name?: string;
|
|
740
|
+
};
|
|
741
|
+
/**
|
|
742
|
+
* Function is the function definition (when Type is "function")
|
|
743
|
+
*/
|
|
744
|
+
type LlmapiToolFunction = {
|
|
745
|
+
/**
|
|
746
|
+
* Arguments is the function arguments schema (JSON object)
|
|
747
|
+
*/
|
|
748
|
+
arguments?: {
|
|
749
|
+
[key: string]: unknown;
|
|
750
|
+
};
|
|
751
|
+
/**
|
|
752
|
+
* Name is the function name
|
|
753
|
+
*/
|
|
754
|
+
name?: string;
|
|
755
|
+
};
|
|
550
756
|
type ResponseErrorResponse = {
|
|
551
757
|
error?: string;
|
|
552
758
|
};
|
|
@@ -687,6 +893,33 @@ type GetApiV1ModelsResponses = {
|
|
|
687
893
|
200: LlmapiModelsListResponse;
|
|
688
894
|
};
|
|
689
895
|
type GetApiV1ModelsResponse = GetApiV1ModelsResponses[keyof GetApiV1ModelsResponses];
|
|
896
|
+
type PostApiV1ResponsesData = {
|
|
897
|
+
/**
|
|
898
|
+
* Response request
|
|
899
|
+
*/
|
|
900
|
+
body: LlmapiResponseRequest;
|
|
901
|
+
path?: never;
|
|
902
|
+
query?: never;
|
|
903
|
+
url: '/api/v1/responses';
|
|
904
|
+
};
|
|
905
|
+
type PostApiV1ResponsesErrors = {
|
|
906
|
+
/**
|
|
907
|
+
* Bad Request
|
|
908
|
+
*/
|
|
909
|
+
400: ResponseErrorResponse;
|
|
910
|
+
/**
|
|
911
|
+
* Internal Server Error
|
|
912
|
+
*/
|
|
913
|
+
500: ResponseErrorResponse;
|
|
914
|
+
};
|
|
915
|
+
type PostApiV1ResponsesError = PostApiV1ResponsesErrors[keyof PostApiV1ResponsesErrors];
|
|
916
|
+
type PostApiV1ResponsesResponses = {
|
|
917
|
+
/**
|
|
918
|
+
* OK
|
|
919
|
+
*/
|
|
920
|
+
200: LlmapiResponseResponse | string;
|
|
921
|
+
};
|
|
922
|
+
type PostApiV1ResponsesResponse = PostApiV1ResponsesResponses[keyof PostApiV1ResponsesResponses];
|
|
690
923
|
type PostApiV1SearchData = {
|
|
691
924
|
/**
|
|
692
925
|
* Search request
|
|
@@ -721,7 +954,7 @@ type PostAuthOauthByProviderExchangeData = {
|
|
|
721
954
|
body: HandlersExchangeRequest;
|
|
722
955
|
path: {
|
|
723
956
|
/**
|
|
724
|
-
* OAuth provider (google-drive)
|
|
957
|
+
* OAuth provider (google-drive, dropbox)
|
|
725
958
|
*/
|
|
726
959
|
provider: string;
|
|
727
960
|
};
|
|
@@ -753,7 +986,7 @@ type PostAuthOauthByProviderRefreshData = {
|
|
|
753
986
|
body: HandlersRefreshRequest;
|
|
754
987
|
path: {
|
|
755
988
|
/**
|
|
756
|
-
* OAuth provider (google-drive)
|
|
989
|
+
* OAuth provider (google-drive, dropbox)
|
|
757
990
|
*/
|
|
758
991
|
provider: string;
|
|
759
992
|
};
|
|
@@ -785,7 +1018,7 @@ type PostAuthOauthByProviderRevokeData = {
|
|
|
785
1018
|
body: HandlersRevokeRequest;
|
|
786
1019
|
path: {
|
|
787
1020
|
/**
|
|
788
|
-
* OAuth provider (google-drive)
|
|
1021
|
+
* OAuth provider (google-drive, dropbox)
|
|
789
1022
|
*/
|
|
790
1023
|
provider: string;
|
|
791
1024
|
};
|
|
@@ -1165,6 +1398,12 @@ declare const postApiV1ImagesGenerations: <ThrowOnError extends boolean = false>
|
|
|
1165
1398
|
* Returns a list of all available models from the configured gateway with optional filters. Models include modality information indicating their capabilities (e.g., llm, embedding, vision, image, audio, reasoning, code, reranker, multimodal, video).
|
|
1166
1399
|
*/
|
|
1167
1400
|
declare const getApiV1Models: <ThrowOnError extends boolean = false>(options?: Options<GetApiV1ModelsData, ThrowOnError>) => RequestResult<GetApiV1ModelsResponses, GetApiV1ModelsErrors, ThrowOnError>;
|
|
1401
|
+
/**
|
|
1402
|
+
* Create response
|
|
1403
|
+
*
|
|
1404
|
+
* Generates a response using the Responses API format. Supports streaming when stream=true.
|
|
1405
|
+
*/
|
|
1406
|
+
declare const postApiV1Responses: <ThrowOnError extends boolean = false>(options: Options<PostApiV1ResponsesData, ThrowOnError>) => RequestResult<PostApiV1ResponsesResponses, PostApiV1ResponsesErrors, ThrowOnError>;
|
|
1168
1407
|
/**
|
|
1169
1408
|
* Create search
|
|
1170
1409
|
*
|
|
@@ -1196,4 +1435,4 @@ declare const postAuthOauthByProviderRevoke: <ThrowOnError extends boolean = fal
|
|
|
1196
1435
|
*/
|
|
1197
1436
|
declare const getHealth: <ThrowOnError extends boolean = false>(options?: Options<GetHealthData, ThrowOnError>) => RequestResult<GetHealthResponses, GetHealthErrors, ThrowOnError>;
|
|
1198
1437
|
|
|
1199
|
-
export { type ClientOptions$1 as ClientOptions, type GetApiV1DocsSwaggerJsonData, type GetApiV1DocsSwaggerJsonResponse, type GetApiV1DocsSwaggerJsonResponses, type GetApiV1ModelsData, type GetApiV1ModelsError, type GetApiV1ModelsErrors, type GetApiV1ModelsResponse, type GetApiV1ModelsResponses, type GetHealthData, type GetHealthError, type GetHealthErrors, type GetHealthResponse, type GetHealthResponses, type HandlersExchangeRequest, type HandlersHealthResponse, type HandlersRefreshRequest, type HandlersRevokeRequest, type HandlersTokenResponse, 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 PostAuthOauthByProviderExchangeData, type PostAuthOauthByProviderExchangeError, type PostAuthOauthByProviderExchangeErrors, type PostAuthOauthByProviderExchangeResponse, type PostAuthOauthByProviderExchangeResponses, type PostAuthOauthByProviderRefreshData, type PostAuthOauthByProviderRefreshError, type PostAuthOauthByProviderRefreshErrors, type PostAuthOauthByProviderRefreshResponse, type PostAuthOauthByProviderRefreshResponses, type PostAuthOauthByProviderRevokeData, type PostAuthOauthByProviderRevokeError, type PostAuthOauthByProviderRevokeErrors, type PostAuthOauthByProviderRevokeResponse, type PostAuthOauthByProviderRevokeResponses, type ResponseErrorResponse, getApiV1DocsSwaggerJson, getApiV1Models, getHealth, postApiV1ChatCompletions, postApiV1Embeddings, postApiV1ImagesGenerations, postApiV1Search, postAuthOauthByProviderExchange, postAuthOauthByProviderRefresh, postAuthOauthByProviderRevoke };
|
|
1438
|
+
export { type ClientOptions$1 as ClientOptions, type GetApiV1DocsSwaggerJsonData, type GetApiV1DocsSwaggerJsonResponse, type GetApiV1DocsSwaggerJsonResponses, type GetApiV1ModelsData, type GetApiV1ModelsError, type GetApiV1ModelsErrors, type GetApiV1ModelsResponse, type GetApiV1ModelsResponses, type GetHealthData, type GetHealthError, type GetHealthErrors, type GetHealthResponse, type GetHealthResponses, type HandlersExchangeRequest, type HandlersHealthResponse, type HandlersRefreshRequest, type HandlersRevokeRequest, type HandlersTokenResponse, 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 LlmapiResponseExtraFields, type LlmapiResponseOutputContent, type LlmapiResponseOutputItem, type LlmapiResponseRequest, type LlmapiResponseResponse, type LlmapiResponseUsage, type LlmapiRole, type LlmapiSearchExtraFields, type LlmapiSearchRequest, type LlmapiSearchResponse, type LlmapiSearchResult, type LlmapiSearchUsage, type LlmapiTool, type LlmapiToolCall, type LlmapiToolCallFunction, type LlmapiToolFunction, 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 PostApiV1ResponsesData, type PostApiV1ResponsesError, type PostApiV1ResponsesErrors, type PostApiV1ResponsesResponse, type PostApiV1ResponsesResponses, type PostApiV1SearchData, type PostApiV1SearchError, type PostApiV1SearchErrors, type PostApiV1SearchResponse, type PostApiV1SearchResponses, type PostAuthOauthByProviderExchangeData, type PostAuthOauthByProviderExchangeError, type PostAuthOauthByProviderExchangeErrors, type PostAuthOauthByProviderExchangeResponse, type PostAuthOauthByProviderExchangeResponses, type PostAuthOauthByProviderRefreshData, type PostAuthOauthByProviderRefreshError, type PostAuthOauthByProviderRefreshErrors, type PostAuthOauthByProviderRefreshResponse, type PostAuthOauthByProviderRefreshResponses, type PostAuthOauthByProviderRevokeData, type PostAuthOauthByProviderRevokeError, type PostAuthOauthByProviderRevokeErrors, type PostAuthOauthByProviderRevokeResponse, type PostAuthOauthByProviderRevokeResponses, type ResponseErrorResponse, getApiV1DocsSwaggerJson, getApiV1Models, getHealth, postApiV1ChatCompletions, postApiV1Embeddings, postApiV1ImagesGenerations, postApiV1Responses, postApiV1Search, postAuthOauthByProviderExchange, postAuthOauthByProviderRefresh, postAuthOauthByProviderRevoke };
|
package/dist/index.d.ts
CHANGED
|
@@ -319,6 +319,10 @@ type LlmapiMessage = {
|
|
|
319
319
|
*/
|
|
320
320
|
content?: Array<LlmapiMessageContentPart>;
|
|
321
321
|
role?: LlmapiRole;
|
|
322
|
+
/**
|
|
323
|
+
* ToolCalls contains tool/function calls made by the assistant (only for assistant role)
|
|
324
|
+
*/
|
|
325
|
+
tool_calls?: Array<LlmapiToolCall>;
|
|
322
326
|
};
|
|
323
327
|
/**
|
|
324
328
|
* ImageURL is used when Type=image_url
|
|
@@ -469,6 +473,162 @@ type LlmapiModelsListResponse = {
|
|
|
469
473
|
*/
|
|
470
474
|
next_page_token?: string;
|
|
471
475
|
};
|
|
476
|
+
/**
|
|
477
|
+
* ExtraFields contains additional metadata
|
|
478
|
+
*/
|
|
479
|
+
type LlmapiResponseExtraFields = {
|
|
480
|
+
/**
|
|
481
|
+
* Latency is the request latency in milliseconds
|
|
482
|
+
*/
|
|
483
|
+
latency?: number;
|
|
484
|
+
/**
|
|
485
|
+
* ModelRequested is the model that was requested
|
|
486
|
+
*/
|
|
487
|
+
model_requested?: string;
|
|
488
|
+
/**
|
|
489
|
+
* Provider is the LLM provider used (e.g., "openai", "anthropic")
|
|
490
|
+
*/
|
|
491
|
+
provider?: string;
|
|
492
|
+
/**
|
|
493
|
+
* RequestType is always "responses"
|
|
494
|
+
*/
|
|
495
|
+
request_type?: string;
|
|
496
|
+
};
|
|
497
|
+
type LlmapiResponseOutputContent = {
|
|
498
|
+
/**
|
|
499
|
+
* Text is the text content
|
|
500
|
+
*/
|
|
501
|
+
text?: string;
|
|
502
|
+
/**
|
|
503
|
+
* Type is the content type (e.g., "output_text")
|
|
504
|
+
*/
|
|
505
|
+
type?: string;
|
|
506
|
+
};
|
|
507
|
+
type LlmapiResponseOutputItem = {
|
|
508
|
+
/**
|
|
509
|
+
* Arguments is the function arguments for function_call types
|
|
510
|
+
*/
|
|
511
|
+
arguments?: string;
|
|
512
|
+
/**
|
|
513
|
+
* CallID is the call ID for function_call types
|
|
514
|
+
*/
|
|
515
|
+
call_id?: string;
|
|
516
|
+
/**
|
|
517
|
+
* Content is the content array for message types
|
|
518
|
+
*/
|
|
519
|
+
content?: Array<LlmapiResponseOutputContent>;
|
|
520
|
+
/**
|
|
521
|
+
* ID is the unique identifier for this output item
|
|
522
|
+
*/
|
|
523
|
+
id?: string;
|
|
524
|
+
/**
|
|
525
|
+
* Name is the function name for function_call types
|
|
526
|
+
*/
|
|
527
|
+
name?: string;
|
|
528
|
+
/**
|
|
529
|
+
* Role is the role for message types (e.g., "assistant")
|
|
530
|
+
*/
|
|
531
|
+
role?: string;
|
|
532
|
+
/**
|
|
533
|
+
* Status is the status of this output item (e.g., "completed")
|
|
534
|
+
*/
|
|
535
|
+
status?: string;
|
|
536
|
+
/**
|
|
537
|
+
* Type is the output item type (e.g., "message", "function_call")
|
|
538
|
+
*/
|
|
539
|
+
type?: string;
|
|
540
|
+
};
|
|
541
|
+
type LlmapiResponseRequest = {
|
|
542
|
+
/**
|
|
543
|
+
* Background indicates if request should be processed in background
|
|
544
|
+
*/
|
|
545
|
+
background?: boolean;
|
|
546
|
+
/**
|
|
547
|
+
* Conversation is the conversation ID (optional)
|
|
548
|
+
*/
|
|
549
|
+
conversation?: string;
|
|
550
|
+
/**
|
|
551
|
+
* Input is the simple text input for the response
|
|
552
|
+
*/
|
|
553
|
+
input: string;
|
|
554
|
+
/**
|
|
555
|
+
* MaxOutputTokens is the maximum number of tokens to generate
|
|
556
|
+
*/
|
|
557
|
+
max_output_tokens?: number;
|
|
558
|
+
/**
|
|
559
|
+
* Model is the model identifier in 'provider/model' format
|
|
560
|
+
*/
|
|
561
|
+
model: string;
|
|
562
|
+
/**
|
|
563
|
+
* PreviousResponseID is the ID of a previous response to continue from
|
|
564
|
+
*/
|
|
565
|
+
previous_response_id?: string;
|
|
566
|
+
/**
|
|
567
|
+
* Store indicates if the response should be stored
|
|
568
|
+
*/
|
|
569
|
+
store?: boolean;
|
|
570
|
+
/**
|
|
571
|
+
* Stream indicates if response should be streamed
|
|
572
|
+
*/
|
|
573
|
+
stream?: boolean;
|
|
574
|
+
/**
|
|
575
|
+
* Temperature controls randomness (0.0 to 2.0)
|
|
576
|
+
*/
|
|
577
|
+
temperature?: number;
|
|
578
|
+
/**
|
|
579
|
+
* ToolChoice controls which tool to use (auto, any, none, required, or tool name)
|
|
580
|
+
*/
|
|
581
|
+
tool_choice?: string;
|
|
582
|
+
/**
|
|
583
|
+
* Tools is an array of tool definitions (passed through, no MCP loop)
|
|
584
|
+
*/
|
|
585
|
+
tools?: Array<LlmapiTool>;
|
|
586
|
+
};
|
|
587
|
+
type LlmapiResponseResponse = {
|
|
588
|
+
/**
|
|
589
|
+
* Created is the Unix timestamp of creation (created_at in OpenAI format)
|
|
590
|
+
*/
|
|
591
|
+
created_at?: number;
|
|
592
|
+
extra_fields?: LlmapiResponseExtraFields;
|
|
593
|
+
/**
|
|
594
|
+
* ID is the unique response identifier
|
|
595
|
+
*/
|
|
596
|
+
id?: string;
|
|
597
|
+
/**
|
|
598
|
+
* Model is the model used for generation
|
|
599
|
+
*/
|
|
600
|
+
model?: string;
|
|
601
|
+
/**
|
|
602
|
+
* Object is the response type (e.g., "response")
|
|
603
|
+
*/
|
|
604
|
+
object?: string;
|
|
605
|
+
/**
|
|
606
|
+
* Output is the array of output items (OpenAI Responses API format)
|
|
607
|
+
*/
|
|
608
|
+
output?: Array<LlmapiResponseOutputItem>;
|
|
609
|
+
usage?: LlmapiResponseUsage;
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Usage contains token usage information
|
|
613
|
+
*/
|
|
614
|
+
type LlmapiResponseUsage = {
|
|
615
|
+
/**
|
|
616
|
+
* CompletionTokens is the number of tokens in the completion
|
|
617
|
+
*/
|
|
618
|
+
completion_tokens?: number;
|
|
619
|
+
/**
|
|
620
|
+
* CostMicroUSD is the cost of this response in micro-dollars (USD × 1,000,000)
|
|
621
|
+
*/
|
|
622
|
+
cost_micro_usd?: number;
|
|
623
|
+
/**
|
|
624
|
+
* PromptTokens is the number of tokens in the prompt
|
|
625
|
+
*/
|
|
626
|
+
prompt_tokens?: number;
|
|
627
|
+
/**
|
|
628
|
+
* TotalTokens is the total number of tokens used
|
|
629
|
+
*/
|
|
630
|
+
total_tokens?: number;
|
|
631
|
+
};
|
|
472
632
|
/**
|
|
473
633
|
* Role is the message role (system, user, assistant)
|
|
474
634
|
*/
|
|
@@ -547,6 +707,52 @@ type LlmapiSearchUsage = {
|
|
|
547
707
|
*/
|
|
548
708
|
cost_micro_usd?: number;
|
|
549
709
|
};
|
|
710
|
+
type LlmapiTool = {
|
|
711
|
+
function?: LlmapiToolFunction;
|
|
712
|
+
/**
|
|
713
|
+
* Type is the tool type (function, code_interpreter, file_search, web_search)
|
|
714
|
+
*/
|
|
715
|
+
type?: string;
|
|
716
|
+
};
|
|
717
|
+
type LlmapiToolCall = {
|
|
718
|
+
function?: LlmapiToolCallFunction;
|
|
719
|
+
/**
|
|
720
|
+
* ID is the unique identifier for this tool call
|
|
721
|
+
*/
|
|
722
|
+
id?: string;
|
|
723
|
+
/**
|
|
724
|
+
* Type is the type of tool call (always "function" for now)
|
|
725
|
+
*/
|
|
726
|
+
type?: string;
|
|
727
|
+
};
|
|
728
|
+
/**
|
|
729
|
+
* Function contains the function call details
|
|
730
|
+
*/
|
|
731
|
+
type LlmapiToolCallFunction = {
|
|
732
|
+
/**
|
|
733
|
+
* Arguments is the JSON string of arguments to pass to the function
|
|
734
|
+
*/
|
|
735
|
+
arguments?: string;
|
|
736
|
+
/**
|
|
737
|
+
* Name is the name of the function to call
|
|
738
|
+
*/
|
|
739
|
+
name?: string;
|
|
740
|
+
};
|
|
741
|
+
/**
|
|
742
|
+
* Function is the function definition (when Type is "function")
|
|
743
|
+
*/
|
|
744
|
+
type LlmapiToolFunction = {
|
|
745
|
+
/**
|
|
746
|
+
* Arguments is the function arguments schema (JSON object)
|
|
747
|
+
*/
|
|
748
|
+
arguments?: {
|
|
749
|
+
[key: string]: unknown;
|
|
750
|
+
};
|
|
751
|
+
/**
|
|
752
|
+
* Name is the function name
|
|
753
|
+
*/
|
|
754
|
+
name?: string;
|
|
755
|
+
};
|
|
550
756
|
type ResponseErrorResponse = {
|
|
551
757
|
error?: string;
|
|
552
758
|
};
|
|
@@ -687,6 +893,33 @@ type GetApiV1ModelsResponses = {
|
|
|
687
893
|
200: LlmapiModelsListResponse;
|
|
688
894
|
};
|
|
689
895
|
type GetApiV1ModelsResponse = GetApiV1ModelsResponses[keyof GetApiV1ModelsResponses];
|
|
896
|
+
type PostApiV1ResponsesData = {
|
|
897
|
+
/**
|
|
898
|
+
* Response request
|
|
899
|
+
*/
|
|
900
|
+
body: LlmapiResponseRequest;
|
|
901
|
+
path?: never;
|
|
902
|
+
query?: never;
|
|
903
|
+
url: '/api/v1/responses';
|
|
904
|
+
};
|
|
905
|
+
type PostApiV1ResponsesErrors = {
|
|
906
|
+
/**
|
|
907
|
+
* Bad Request
|
|
908
|
+
*/
|
|
909
|
+
400: ResponseErrorResponse;
|
|
910
|
+
/**
|
|
911
|
+
* Internal Server Error
|
|
912
|
+
*/
|
|
913
|
+
500: ResponseErrorResponse;
|
|
914
|
+
};
|
|
915
|
+
type PostApiV1ResponsesError = PostApiV1ResponsesErrors[keyof PostApiV1ResponsesErrors];
|
|
916
|
+
type PostApiV1ResponsesResponses = {
|
|
917
|
+
/**
|
|
918
|
+
* OK
|
|
919
|
+
*/
|
|
920
|
+
200: LlmapiResponseResponse | string;
|
|
921
|
+
};
|
|
922
|
+
type PostApiV1ResponsesResponse = PostApiV1ResponsesResponses[keyof PostApiV1ResponsesResponses];
|
|
690
923
|
type PostApiV1SearchData = {
|
|
691
924
|
/**
|
|
692
925
|
* Search request
|
|
@@ -721,7 +954,7 @@ type PostAuthOauthByProviderExchangeData = {
|
|
|
721
954
|
body: HandlersExchangeRequest;
|
|
722
955
|
path: {
|
|
723
956
|
/**
|
|
724
|
-
* OAuth provider (google-drive)
|
|
957
|
+
* OAuth provider (google-drive, dropbox)
|
|
725
958
|
*/
|
|
726
959
|
provider: string;
|
|
727
960
|
};
|
|
@@ -753,7 +986,7 @@ type PostAuthOauthByProviderRefreshData = {
|
|
|
753
986
|
body: HandlersRefreshRequest;
|
|
754
987
|
path: {
|
|
755
988
|
/**
|
|
756
|
-
* OAuth provider (google-drive)
|
|
989
|
+
* OAuth provider (google-drive, dropbox)
|
|
757
990
|
*/
|
|
758
991
|
provider: string;
|
|
759
992
|
};
|
|
@@ -785,7 +1018,7 @@ type PostAuthOauthByProviderRevokeData = {
|
|
|
785
1018
|
body: HandlersRevokeRequest;
|
|
786
1019
|
path: {
|
|
787
1020
|
/**
|
|
788
|
-
* OAuth provider (google-drive)
|
|
1021
|
+
* OAuth provider (google-drive, dropbox)
|
|
789
1022
|
*/
|
|
790
1023
|
provider: string;
|
|
791
1024
|
};
|
|
@@ -1165,6 +1398,12 @@ declare const postApiV1ImagesGenerations: <ThrowOnError extends boolean = false>
|
|
|
1165
1398
|
* Returns a list of all available models from the configured gateway with optional filters. Models include modality information indicating their capabilities (e.g., llm, embedding, vision, image, audio, reasoning, code, reranker, multimodal, video).
|
|
1166
1399
|
*/
|
|
1167
1400
|
declare const getApiV1Models: <ThrowOnError extends boolean = false>(options?: Options<GetApiV1ModelsData, ThrowOnError>) => RequestResult<GetApiV1ModelsResponses, GetApiV1ModelsErrors, ThrowOnError>;
|
|
1401
|
+
/**
|
|
1402
|
+
* Create response
|
|
1403
|
+
*
|
|
1404
|
+
* Generates a response using the Responses API format. Supports streaming when stream=true.
|
|
1405
|
+
*/
|
|
1406
|
+
declare const postApiV1Responses: <ThrowOnError extends boolean = false>(options: Options<PostApiV1ResponsesData, ThrowOnError>) => RequestResult<PostApiV1ResponsesResponses, PostApiV1ResponsesErrors, ThrowOnError>;
|
|
1168
1407
|
/**
|
|
1169
1408
|
* Create search
|
|
1170
1409
|
*
|
|
@@ -1196,4 +1435,4 @@ declare const postAuthOauthByProviderRevoke: <ThrowOnError extends boolean = fal
|
|
|
1196
1435
|
*/
|
|
1197
1436
|
declare const getHealth: <ThrowOnError extends boolean = false>(options?: Options<GetHealthData, ThrowOnError>) => RequestResult<GetHealthResponses, GetHealthErrors, ThrowOnError>;
|
|
1198
1437
|
|
|
1199
|
-
export { type ClientOptions$1 as ClientOptions, type GetApiV1DocsSwaggerJsonData, type GetApiV1DocsSwaggerJsonResponse, type GetApiV1DocsSwaggerJsonResponses, type GetApiV1ModelsData, type GetApiV1ModelsError, type GetApiV1ModelsErrors, type GetApiV1ModelsResponse, type GetApiV1ModelsResponses, type GetHealthData, type GetHealthError, type GetHealthErrors, type GetHealthResponse, type GetHealthResponses, type HandlersExchangeRequest, type HandlersHealthResponse, type HandlersRefreshRequest, type HandlersRevokeRequest, type HandlersTokenResponse, 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 PostAuthOauthByProviderExchangeData, type PostAuthOauthByProviderExchangeError, type PostAuthOauthByProviderExchangeErrors, type PostAuthOauthByProviderExchangeResponse, type PostAuthOauthByProviderExchangeResponses, type PostAuthOauthByProviderRefreshData, type PostAuthOauthByProviderRefreshError, type PostAuthOauthByProviderRefreshErrors, type PostAuthOauthByProviderRefreshResponse, type PostAuthOauthByProviderRefreshResponses, type PostAuthOauthByProviderRevokeData, type PostAuthOauthByProviderRevokeError, type PostAuthOauthByProviderRevokeErrors, type PostAuthOauthByProviderRevokeResponse, type PostAuthOauthByProviderRevokeResponses, type ResponseErrorResponse, getApiV1DocsSwaggerJson, getApiV1Models, getHealth, postApiV1ChatCompletions, postApiV1Embeddings, postApiV1ImagesGenerations, postApiV1Search, postAuthOauthByProviderExchange, postAuthOauthByProviderRefresh, postAuthOauthByProviderRevoke };
|
|
1438
|
+
export { type ClientOptions$1 as ClientOptions, type GetApiV1DocsSwaggerJsonData, type GetApiV1DocsSwaggerJsonResponse, type GetApiV1DocsSwaggerJsonResponses, type GetApiV1ModelsData, type GetApiV1ModelsError, type GetApiV1ModelsErrors, type GetApiV1ModelsResponse, type GetApiV1ModelsResponses, type GetHealthData, type GetHealthError, type GetHealthErrors, type GetHealthResponse, type GetHealthResponses, type HandlersExchangeRequest, type HandlersHealthResponse, type HandlersRefreshRequest, type HandlersRevokeRequest, type HandlersTokenResponse, 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 LlmapiResponseExtraFields, type LlmapiResponseOutputContent, type LlmapiResponseOutputItem, type LlmapiResponseRequest, type LlmapiResponseResponse, type LlmapiResponseUsage, type LlmapiRole, type LlmapiSearchExtraFields, type LlmapiSearchRequest, type LlmapiSearchResponse, type LlmapiSearchResult, type LlmapiSearchUsage, type LlmapiTool, type LlmapiToolCall, type LlmapiToolCallFunction, type LlmapiToolFunction, 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 PostApiV1ResponsesData, type PostApiV1ResponsesError, type PostApiV1ResponsesErrors, type PostApiV1ResponsesResponse, type PostApiV1ResponsesResponses, type PostApiV1SearchData, type PostApiV1SearchError, type PostApiV1SearchErrors, type PostApiV1SearchResponse, type PostApiV1SearchResponses, type PostAuthOauthByProviderExchangeData, type PostAuthOauthByProviderExchangeError, type PostAuthOauthByProviderExchangeErrors, type PostAuthOauthByProviderExchangeResponse, type PostAuthOauthByProviderExchangeResponses, type PostAuthOauthByProviderRefreshData, type PostAuthOauthByProviderRefreshError, type PostAuthOauthByProviderRefreshErrors, type PostAuthOauthByProviderRefreshResponse, type PostAuthOauthByProviderRefreshResponses, type PostAuthOauthByProviderRevokeData, type PostAuthOauthByProviderRevokeError, type PostAuthOauthByProviderRevokeErrors, type PostAuthOauthByProviderRevokeResponse, type PostAuthOauthByProviderRevokeResponses, type ResponseErrorResponse, getApiV1DocsSwaggerJson, getApiV1Models, getHealth, postApiV1ChatCompletions, postApiV1Embeddings, postApiV1ImagesGenerations, postApiV1Responses, postApiV1Search, postAuthOauthByProviderExchange, postAuthOauthByProviderRefresh, postAuthOauthByProviderRevoke };
|
package/dist/index.mjs
CHANGED
|
@@ -856,6 +856,16 @@ var getApiV1Models = (options) => {
|
|
|
856
856
|
...options
|
|
857
857
|
});
|
|
858
858
|
};
|
|
859
|
+
var postApiV1Responses = (options) => {
|
|
860
|
+
return (options.client ?? client).post({
|
|
861
|
+
url: "/api/v1/responses",
|
|
862
|
+
...options,
|
|
863
|
+
headers: {
|
|
864
|
+
"Content-Type": "application/json",
|
|
865
|
+
...options.headers
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
};
|
|
859
869
|
var postApiV1Search = (options) => {
|
|
860
870
|
return (options.client ?? client).post({
|
|
861
871
|
url: "/api/v1/search",
|
|
@@ -909,6 +919,7 @@ export {
|
|
|
909
919
|
postApiV1ChatCompletions,
|
|
910
920
|
postApiV1Embeddings,
|
|
911
921
|
postApiV1ImagesGenerations,
|
|
922
|
+
postApiV1Responses,
|
|
912
923
|
postApiV1Search,
|
|
913
924
|
postAuthOauthByProviderExchange,
|
|
914
925
|
postAuthOauthByProviderRefresh,
|
package/dist/react/index.cjs
CHANGED
|
@@ -2085,6 +2085,37 @@ async function updateMessageErrorOp(ctx, uniqueId, error) {
|
|
|
2085
2085
|
});
|
|
2086
2086
|
return messageToStored(message);
|
|
2087
2087
|
}
|
|
2088
|
+
async function updateMessageOp(ctx, uniqueId, opts) {
|
|
2089
|
+
let message;
|
|
2090
|
+
try {
|
|
2091
|
+
message = await ctx.messagesCollection.find(uniqueId);
|
|
2092
|
+
} catch {
|
|
2093
|
+
return null;
|
|
2094
|
+
}
|
|
2095
|
+
await ctx.database.write(async () => {
|
|
2096
|
+
await message.update((msg) => {
|
|
2097
|
+
if (opts.content !== void 0) msg._setRaw("content", opts.content);
|
|
2098
|
+
if (opts.model !== void 0) msg._setRaw("model", opts.model);
|
|
2099
|
+
if (opts.files !== void 0)
|
|
2100
|
+
msg._setRaw("files", JSON.stringify(opts.files));
|
|
2101
|
+
if (opts.usage !== void 0)
|
|
2102
|
+
msg._setRaw("usage", JSON.stringify(opts.usage));
|
|
2103
|
+
if (opts.sources !== void 0)
|
|
2104
|
+
msg._setRaw("sources", JSON.stringify(opts.sources));
|
|
2105
|
+
if (opts.responseDuration !== void 0)
|
|
2106
|
+
msg._setRaw("response_duration", opts.responseDuration);
|
|
2107
|
+
if (opts.vector !== void 0)
|
|
2108
|
+
msg._setRaw("vector", JSON.stringify(opts.vector));
|
|
2109
|
+
if (opts.embeddingModel !== void 0)
|
|
2110
|
+
msg._setRaw("embedding_model", opts.embeddingModel);
|
|
2111
|
+
if (opts.wasStopped !== void 0)
|
|
2112
|
+
msg._setRaw("was_stopped", opts.wasStopped);
|
|
2113
|
+
if (opts.error !== void 0)
|
|
2114
|
+
msg._setRaw("error", opts.error === null ? "" : opts.error);
|
|
2115
|
+
});
|
|
2116
|
+
});
|
|
2117
|
+
return messageToStored(message);
|
|
2118
|
+
}
|
|
2088
2119
|
function cosineSimilarity(a, b) {
|
|
2089
2120
|
if (a.length !== b.length) return 0;
|
|
2090
2121
|
let dotProduct = 0;
|
|
@@ -2483,6 +2514,12 @@ function useChatStorage(options) {
|
|
|
2483
2514
|
},
|
|
2484
2515
|
[storageCtx]
|
|
2485
2516
|
);
|
|
2517
|
+
const updateMessage = (0, import_react2.useCallback)(
|
|
2518
|
+
async (uniqueId, options2) => {
|
|
2519
|
+
return updateMessageOp(storageCtx, uniqueId, options2);
|
|
2520
|
+
},
|
|
2521
|
+
[storageCtx]
|
|
2522
|
+
);
|
|
2486
2523
|
return {
|
|
2487
2524
|
isLoading,
|
|
2488
2525
|
isSelectingTool,
|
|
@@ -2499,7 +2536,8 @@ function useChatStorage(options) {
|
|
|
2499
2536
|
getMessageCount,
|
|
2500
2537
|
clearMessages,
|
|
2501
2538
|
searchMessages,
|
|
2502
|
-
updateMessageEmbedding
|
|
2539
|
+
updateMessageEmbedding,
|
|
2540
|
+
updateMessage
|
|
2503
2541
|
};
|
|
2504
2542
|
}
|
|
2505
2543
|
|
package/dist/react/index.d.mts
CHANGED
|
@@ -173,6 +173,10 @@ type LlmapiMessage = {
|
|
|
173
173
|
*/
|
|
174
174
|
content?: Array<LlmapiMessageContentPart>;
|
|
175
175
|
role?: LlmapiRole;
|
|
176
|
+
/**
|
|
177
|
+
* ToolCalls contains tool/function calls made by the assistant (only for assistant role)
|
|
178
|
+
*/
|
|
179
|
+
tool_calls?: Array<LlmapiToolCall>;
|
|
176
180
|
};
|
|
177
181
|
/**
|
|
178
182
|
* ImageURL is used when Type=image_url
|
|
@@ -347,6 +351,30 @@ type LlmapiSearchUsage = {
|
|
|
347
351
|
*/
|
|
348
352
|
cost_micro_usd?: number;
|
|
349
353
|
};
|
|
354
|
+
type LlmapiToolCall = {
|
|
355
|
+
function?: LlmapiToolCallFunction;
|
|
356
|
+
/**
|
|
357
|
+
* ID is the unique identifier for this tool call
|
|
358
|
+
*/
|
|
359
|
+
id?: string;
|
|
360
|
+
/**
|
|
361
|
+
* Type is the type of tool call (always "function" for now)
|
|
362
|
+
*/
|
|
363
|
+
type?: string;
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* Function contains the function call details
|
|
367
|
+
*/
|
|
368
|
+
type LlmapiToolCallFunction = {
|
|
369
|
+
/**
|
|
370
|
+
* Arguments is the JSON string of arguments to pass to the function
|
|
371
|
+
*/
|
|
372
|
+
arguments?: string;
|
|
373
|
+
/**
|
|
374
|
+
* Name is the name of the function to call
|
|
375
|
+
*/
|
|
376
|
+
name?: string;
|
|
377
|
+
};
|
|
350
378
|
|
|
351
379
|
type AuthToken = string | undefined;
|
|
352
380
|
interface Auth {
|
|
@@ -1011,6 +1039,18 @@ interface CreateConversationOptions {
|
|
|
1011
1039
|
conversationId?: string;
|
|
1012
1040
|
title?: string;
|
|
1013
1041
|
}
|
|
1042
|
+
interface UpdateMessageOptions {
|
|
1043
|
+
content?: string;
|
|
1044
|
+
model?: string;
|
|
1045
|
+
files?: FileMetadata[];
|
|
1046
|
+
usage?: ChatCompletionUsage;
|
|
1047
|
+
sources?: SearchSource[];
|
|
1048
|
+
responseDuration?: number;
|
|
1049
|
+
vector?: number[];
|
|
1050
|
+
embeddingModel?: string;
|
|
1051
|
+
wasStopped?: boolean;
|
|
1052
|
+
error?: string | null;
|
|
1053
|
+
}
|
|
1014
1054
|
interface BaseUseChatStorageOptions {
|
|
1015
1055
|
database: Database;
|
|
1016
1056
|
conversationId?: string;
|
|
@@ -1150,6 +1190,8 @@ interface UseChatStorageResult extends BaseUseChatStorageResult {
|
|
|
1150
1190
|
searchMessages: (queryVector: number[], options?: SearchMessagesOptions) => Promise<StoredMessageWithSimilarity[]>;
|
|
1151
1191
|
/** Update a message's embedding vector. Returns updated message or null if not found. */
|
|
1152
1192
|
updateMessageEmbedding: (uniqueId: string, vector: number[], embeddingModel: string) => Promise<StoredMessage | null>;
|
|
1193
|
+
/** Update a message's fields (content, embedding, files, etc). Returns updated message or null if not found. */
|
|
1194
|
+
updateMessage: (uniqueId: string, options: UpdateMessageOptions) => Promise<StoredMessage | null>;
|
|
1153
1195
|
}
|
|
1154
1196
|
/**
|
|
1155
1197
|
* A React hook that wraps useChat with automatic message persistence using WatermelonDB.
|
package/dist/react/index.d.ts
CHANGED
|
@@ -173,6 +173,10 @@ type LlmapiMessage = {
|
|
|
173
173
|
*/
|
|
174
174
|
content?: Array<LlmapiMessageContentPart>;
|
|
175
175
|
role?: LlmapiRole;
|
|
176
|
+
/**
|
|
177
|
+
* ToolCalls contains tool/function calls made by the assistant (only for assistant role)
|
|
178
|
+
*/
|
|
179
|
+
tool_calls?: Array<LlmapiToolCall>;
|
|
176
180
|
};
|
|
177
181
|
/**
|
|
178
182
|
* ImageURL is used when Type=image_url
|
|
@@ -347,6 +351,30 @@ type LlmapiSearchUsage = {
|
|
|
347
351
|
*/
|
|
348
352
|
cost_micro_usd?: number;
|
|
349
353
|
};
|
|
354
|
+
type LlmapiToolCall = {
|
|
355
|
+
function?: LlmapiToolCallFunction;
|
|
356
|
+
/**
|
|
357
|
+
* ID is the unique identifier for this tool call
|
|
358
|
+
*/
|
|
359
|
+
id?: string;
|
|
360
|
+
/**
|
|
361
|
+
* Type is the type of tool call (always "function" for now)
|
|
362
|
+
*/
|
|
363
|
+
type?: string;
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* Function contains the function call details
|
|
367
|
+
*/
|
|
368
|
+
type LlmapiToolCallFunction = {
|
|
369
|
+
/**
|
|
370
|
+
* Arguments is the JSON string of arguments to pass to the function
|
|
371
|
+
*/
|
|
372
|
+
arguments?: string;
|
|
373
|
+
/**
|
|
374
|
+
* Name is the name of the function to call
|
|
375
|
+
*/
|
|
376
|
+
name?: string;
|
|
377
|
+
};
|
|
350
378
|
|
|
351
379
|
type AuthToken = string | undefined;
|
|
352
380
|
interface Auth {
|
|
@@ -1011,6 +1039,18 @@ interface CreateConversationOptions {
|
|
|
1011
1039
|
conversationId?: string;
|
|
1012
1040
|
title?: string;
|
|
1013
1041
|
}
|
|
1042
|
+
interface UpdateMessageOptions {
|
|
1043
|
+
content?: string;
|
|
1044
|
+
model?: string;
|
|
1045
|
+
files?: FileMetadata[];
|
|
1046
|
+
usage?: ChatCompletionUsage;
|
|
1047
|
+
sources?: SearchSource[];
|
|
1048
|
+
responseDuration?: number;
|
|
1049
|
+
vector?: number[];
|
|
1050
|
+
embeddingModel?: string;
|
|
1051
|
+
wasStopped?: boolean;
|
|
1052
|
+
error?: string | null;
|
|
1053
|
+
}
|
|
1014
1054
|
interface BaseUseChatStorageOptions {
|
|
1015
1055
|
database: Database;
|
|
1016
1056
|
conversationId?: string;
|
|
@@ -1150,6 +1190,8 @@ interface UseChatStorageResult extends BaseUseChatStorageResult {
|
|
|
1150
1190
|
searchMessages: (queryVector: number[], options?: SearchMessagesOptions) => Promise<StoredMessageWithSimilarity[]>;
|
|
1151
1191
|
/** Update a message's embedding vector. Returns updated message or null if not found. */
|
|
1152
1192
|
updateMessageEmbedding: (uniqueId: string, vector: number[], embeddingModel: string) => Promise<StoredMessage | null>;
|
|
1193
|
+
/** Update a message's fields (content, embedding, files, etc). Returns updated message or null if not found. */
|
|
1194
|
+
updateMessage: (uniqueId: string, options: UpdateMessageOptions) => Promise<StoredMessage | null>;
|
|
1153
1195
|
}
|
|
1154
1196
|
/**
|
|
1155
1197
|
* A React hook that wraps useChat with automatic message persistence using WatermelonDB.
|
package/dist/react/index.mjs
CHANGED
|
@@ -1994,6 +1994,37 @@ async function updateMessageErrorOp(ctx, uniqueId, error) {
|
|
|
1994
1994
|
});
|
|
1995
1995
|
return messageToStored(message);
|
|
1996
1996
|
}
|
|
1997
|
+
async function updateMessageOp(ctx, uniqueId, opts) {
|
|
1998
|
+
let message;
|
|
1999
|
+
try {
|
|
2000
|
+
message = await ctx.messagesCollection.find(uniqueId);
|
|
2001
|
+
} catch {
|
|
2002
|
+
return null;
|
|
2003
|
+
}
|
|
2004
|
+
await ctx.database.write(async () => {
|
|
2005
|
+
await message.update((msg) => {
|
|
2006
|
+
if (opts.content !== void 0) msg._setRaw("content", opts.content);
|
|
2007
|
+
if (opts.model !== void 0) msg._setRaw("model", opts.model);
|
|
2008
|
+
if (opts.files !== void 0)
|
|
2009
|
+
msg._setRaw("files", JSON.stringify(opts.files));
|
|
2010
|
+
if (opts.usage !== void 0)
|
|
2011
|
+
msg._setRaw("usage", JSON.stringify(opts.usage));
|
|
2012
|
+
if (opts.sources !== void 0)
|
|
2013
|
+
msg._setRaw("sources", JSON.stringify(opts.sources));
|
|
2014
|
+
if (opts.responseDuration !== void 0)
|
|
2015
|
+
msg._setRaw("response_duration", opts.responseDuration);
|
|
2016
|
+
if (opts.vector !== void 0)
|
|
2017
|
+
msg._setRaw("vector", JSON.stringify(opts.vector));
|
|
2018
|
+
if (opts.embeddingModel !== void 0)
|
|
2019
|
+
msg._setRaw("embedding_model", opts.embeddingModel);
|
|
2020
|
+
if (opts.wasStopped !== void 0)
|
|
2021
|
+
msg._setRaw("was_stopped", opts.wasStopped);
|
|
2022
|
+
if (opts.error !== void 0)
|
|
2023
|
+
msg._setRaw("error", opts.error === null ? "" : opts.error);
|
|
2024
|
+
});
|
|
2025
|
+
});
|
|
2026
|
+
return messageToStored(message);
|
|
2027
|
+
}
|
|
1997
2028
|
function cosineSimilarity(a, b) {
|
|
1998
2029
|
if (a.length !== b.length) return 0;
|
|
1999
2030
|
let dotProduct = 0;
|
|
@@ -2392,6 +2423,12 @@ function useChatStorage(options) {
|
|
|
2392
2423
|
},
|
|
2393
2424
|
[storageCtx]
|
|
2394
2425
|
);
|
|
2426
|
+
const updateMessage = useCallback2(
|
|
2427
|
+
async (uniqueId, options2) => {
|
|
2428
|
+
return updateMessageOp(storageCtx, uniqueId, options2);
|
|
2429
|
+
},
|
|
2430
|
+
[storageCtx]
|
|
2431
|
+
);
|
|
2395
2432
|
return {
|
|
2396
2433
|
isLoading,
|
|
2397
2434
|
isSelectingTool,
|
|
@@ -2408,7 +2445,8 @@ function useChatStorage(options) {
|
|
|
2408
2445
|
getMessageCount,
|
|
2409
2446
|
clearMessages,
|
|
2410
2447
|
searchMessages,
|
|
2411
|
-
updateMessageEmbedding
|
|
2448
|
+
updateMessageEmbedding,
|
|
2449
|
+
updateMessage
|
|
2412
2450
|
};
|
|
2413
2451
|
}
|
|
2414
2452
|
|
package/dist/vercel/index.d.mts
CHANGED
|
@@ -9,6 +9,10 @@ type LlmapiMessage = {
|
|
|
9
9
|
*/
|
|
10
10
|
content?: Array<LlmapiMessageContentPart>;
|
|
11
11
|
role?: LlmapiRole;
|
|
12
|
+
/**
|
|
13
|
+
* ToolCalls contains tool/function calls made by the assistant (only for assistant role)
|
|
14
|
+
*/
|
|
15
|
+
tool_calls?: Array<LlmapiToolCall>;
|
|
12
16
|
};
|
|
13
17
|
/**
|
|
14
18
|
* ImageURL is used when Type=image_url
|
|
@@ -38,6 +42,30 @@ type LlmapiMessageContentPart = {
|
|
|
38
42
|
* Role is the message role (system, user, assistant)
|
|
39
43
|
*/
|
|
40
44
|
type LlmapiRole = string;
|
|
45
|
+
type LlmapiToolCall = {
|
|
46
|
+
function?: LlmapiToolCallFunction;
|
|
47
|
+
/**
|
|
48
|
+
* ID is the unique identifier for this tool call
|
|
49
|
+
*/
|
|
50
|
+
id?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Type is the type of tool call (always "function" for now)
|
|
53
|
+
*/
|
|
54
|
+
type?: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Function contains the function call details
|
|
58
|
+
*/
|
|
59
|
+
type LlmapiToolCallFunction = {
|
|
60
|
+
/**
|
|
61
|
+
* Arguments is the JSON string of arguments to pass to the function
|
|
62
|
+
*/
|
|
63
|
+
arguments?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Name is the name of the function to call
|
|
66
|
+
*/
|
|
67
|
+
name?: string;
|
|
68
|
+
};
|
|
41
69
|
|
|
42
70
|
/**
|
|
43
71
|
* Converts an array of Vercel AI {@link UIMessage} objects into the
|
package/dist/vercel/index.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ type LlmapiMessage = {
|
|
|
9
9
|
*/
|
|
10
10
|
content?: Array<LlmapiMessageContentPart>;
|
|
11
11
|
role?: LlmapiRole;
|
|
12
|
+
/**
|
|
13
|
+
* ToolCalls contains tool/function calls made by the assistant (only for assistant role)
|
|
14
|
+
*/
|
|
15
|
+
tool_calls?: Array<LlmapiToolCall>;
|
|
12
16
|
};
|
|
13
17
|
/**
|
|
14
18
|
* ImageURL is used when Type=image_url
|
|
@@ -38,6 +42,30 @@ type LlmapiMessageContentPart = {
|
|
|
38
42
|
* Role is the message role (system, user, assistant)
|
|
39
43
|
*/
|
|
40
44
|
type LlmapiRole = string;
|
|
45
|
+
type LlmapiToolCall = {
|
|
46
|
+
function?: LlmapiToolCallFunction;
|
|
47
|
+
/**
|
|
48
|
+
* ID is the unique identifier for this tool call
|
|
49
|
+
*/
|
|
50
|
+
id?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Type is the type of tool call (always "function" for now)
|
|
53
|
+
*/
|
|
54
|
+
type?: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Function contains the function call details
|
|
58
|
+
*/
|
|
59
|
+
type LlmapiToolCallFunction = {
|
|
60
|
+
/**
|
|
61
|
+
* Arguments is the JSON string of arguments to pass to the function
|
|
62
|
+
*/
|
|
63
|
+
arguments?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Name is the name of the function to call
|
|
66
|
+
*/
|
|
67
|
+
name?: string;
|
|
68
|
+
};
|
|
41
69
|
|
|
42
70
|
/**
|
|
43
71
|
* Converts an array of Vercel AI {@link UIMessage} objects into the
|
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.20251220010649",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"homepage": "https://github.com/zeta-chain/ai-sdk#readme",
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@huggingface/transformers": "^3.8.0",
|
|
75
|
-
"@reverbia/portal": "1.0.0-next.
|
|
75
|
+
"@reverbia/portal": "1.0.0-next.20251219155822",
|
|
76
76
|
"ai": "5.0.93",
|
|
77
77
|
"pdfjs-dist": "^4.10.38",
|
|
78
78
|
"tesseract.js": "^6.0.1"
|