objectiveai 1.1.2 → 1.1.4
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 +173 -1
- package/dist/index.d.ts +145 -8
- package/dist/index.js +172 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ScoreModel = exports.ScoreLlm = exports.Metadata = exports.Auth = exports.Models = exports.Score = exports.Chat = void 0;
|
|
3
|
+
exports.MultichatModel = exports.ScoreModel = exports.MultichatLlm = exports.ScoreLlm = exports.Metadata = exports.Auth = exports.Models = exports.Conversation = exports.Multichat = exports.Score = exports.Chat = void 0;
|
|
4
4
|
var Chat;
|
|
5
5
|
(function (Chat) {
|
|
6
6
|
let Completions;
|
|
@@ -537,6 +537,132 @@ var Score;
|
|
|
537
537
|
Completions.create = create;
|
|
538
538
|
})(Completions = Score.Completions || (Score.Completions = {}));
|
|
539
539
|
})(Score || (exports.Score = Score = {}));
|
|
540
|
+
var Multichat;
|
|
541
|
+
(function (Multichat) {
|
|
542
|
+
let Completions;
|
|
543
|
+
(function (Completions) {
|
|
544
|
+
let Response;
|
|
545
|
+
(function (Response) {
|
|
546
|
+
let Streaming;
|
|
547
|
+
(function (Streaming) {
|
|
548
|
+
let ChatCompletionChunk;
|
|
549
|
+
(function (ChatCompletionChunk) {
|
|
550
|
+
function merged(a, b) {
|
|
551
|
+
const id = a.id;
|
|
552
|
+
const [choices, choicesChanged] = Choice.mergedList(a.choices, b.choices);
|
|
553
|
+
const created = a.created;
|
|
554
|
+
const model = a.model;
|
|
555
|
+
const object = a.object;
|
|
556
|
+
const [usage, usageChanged] = merge(a.usage, b.usage, Chat.Completions.Response.Usage.merged);
|
|
557
|
+
if (choicesChanged || usageChanged) {
|
|
558
|
+
return [
|
|
559
|
+
Object.assign({ id,
|
|
560
|
+
choices,
|
|
561
|
+
created,
|
|
562
|
+
model,
|
|
563
|
+
object }, (usage !== undefined ? { usage } : {})),
|
|
564
|
+
true,
|
|
565
|
+
];
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
return [a, false];
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
ChatCompletionChunk.merged = merged;
|
|
572
|
+
})(ChatCompletionChunk = Streaming.ChatCompletionChunk || (Streaming.ChatCompletionChunk = {}));
|
|
573
|
+
let Choice;
|
|
574
|
+
(function (Choice) {
|
|
575
|
+
function merged(a, b) {
|
|
576
|
+
const [delta, deltaChanged] = merge(a.delta, b.delta, Chat.Completions.Response.Streaming.Delta.merged);
|
|
577
|
+
const [finish_reason, finish_reasonChanged] = merge(a.finish_reason, b.finish_reason);
|
|
578
|
+
const index = a.index;
|
|
579
|
+
const [logprobs, logprobsChanged] = merge(a.logprobs, b.logprobs, Chat.Completions.Response.Logprobs.merged);
|
|
580
|
+
const [error, errorChanged] = merge(a.error, b.error);
|
|
581
|
+
const [model, modelChanged] = merge(a.model, b.model);
|
|
582
|
+
const [model_index, model_indexChanged] = merge(a.model_index, b.model_index);
|
|
583
|
+
const [completion_metadata, completion_metadataChanged] = merge(a.completion_metadata, b.completion_metadata, Score.Completions.Response.CompletionMetadata.merged);
|
|
584
|
+
if (deltaChanged ||
|
|
585
|
+
finish_reasonChanged ||
|
|
586
|
+
logprobsChanged ||
|
|
587
|
+
errorChanged ||
|
|
588
|
+
modelChanged ||
|
|
589
|
+
model_indexChanged ||
|
|
590
|
+
completion_metadataChanged) {
|
|
591
|
+
return [
|
|
592
|
+
Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ delta,
|
|
593
|
+
finish_reason,
|
|
594
|
+
index }, (logprobs !== undefined ? { logprobs } : {})), (error !== undefined ? { error } : {})), (model !== undefined ? { model } : {})), (model_index !== undefined ? { model_index } : {})), (completion_metadata !== undefined
|
|
595
|
+
? { completion_metadata }
|
|
596
|
+
: {})),
|
|
597
|
+
true,
|
|
598
|
+
];
|
|
599
|
+
}
|
|
600
|
+
else {
|
|
601
|
+
return [a, false];
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
Choice.merged = merged;
|
|
605
|
+
function mergedList(a, b) {
|
|
606
|
+
let merged = undefined;
|
|
607
|
+
for (const choice of b) {
|
|
608
|
+
const existingIndex = a.findIndex(({ index }) => index === choice.index);
|
|
609
|
+
if (existingIndex === -1) {
|
|
610
|
+
if (merged === undefined) {
|
|
611
|
+
merged = [...a, choice];
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
merged.push(choice);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
const [mergedChoice, choiceChanged] = Choice.merged(a[existingIndex], choice);
|
|
619
|
+
if (choiceChanged) {
|
|
620
|
+
if (merged === undefined) {
|
|
621
|
+
merged = [...a];
|
|
622
|
+
}
|
|
623
|
+
merged[existingIndex] = mergedChoice;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return merged ? [merged, true] : [a, false];
|
|
628
|
+
}
|
|
629
|
+
Choice.mergedList = mergedList;
|
|
630
|
+
})(Choice = Streaming.Choice || (Streaming.Choice = {}));
|
|
631
|
+
})(Streaming = Response.Streaming || (Response.Streaming = {}));
|
|
632
|
+
})(Response = Completions.Response || (Completions.Response = {}));
|
|
633
|
+
async function list(openai, listOptions, options) {
|
|
634
|
+
const response = await openai.get("/multichat/completions", Object.assign({ query: listOptions }, options));
|
|
635
|
+
return response;
|
|
636
|
+
}
|
|
637
|
+
Completions.list = list;
|
|
638
|
+
async function publish(openai, id, options) {
|
|
639
|
+
await openai.post(`/multichat/completions/${id}/publish`, options);
|
|
640
|
+
}
|
|
641
|
+
Completions.publish = publish;
|
|
642
|
+
async function retrieve(openai, id, options) {
|
|
643
|
+
const response = await openai.get(`/multichat/completions/${id}`, options);
|
|
644
|
+
return response;
|
|
645
|
+
}
|
|
646
|
+
Completions.retrieve = retrieve;
|
|
647
|
+
async function create(openai, body, options) {
|
|
648
|
+
var _a;
|
|
649
|
+
const response = await openai.post("/multichat/completions", Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
|
|
650
|
+
return response;
|
|
651
|
+
}
|
|
652
|
+
Completions.create = create;
|
|
653
|
+
})(Completions = Multichat.Completions || (Multichat.Completions = {}));
|
|
654
|
+
})(Multichat || (exports.Multichat = Multichat = {}));
|
|
655
|
+
var Conversation;
|
|
656
|
+
(function (Conversation) {
|
|
657
|
+
let Completions;
|
|
658
|
+
(function (Completions) {
|
|
659
|
+
async function list(openai, listOptions, options) {
|
|
660
|
+
const response = await openai.get("/conversation/completions", Object.assign({ query: listOptions }, options));
|
|
661
|
+
return response;
|
|
662
|
+
}
|
|
663
|
+
Completions.list = list;
|
|
664
|
+
})(Completions = Conversation.Completions || (Conversation.Completions = {}));
|
|
665
|
+
})(Conversation || (exports.Conversation = Conversation = {}));
|
|
540
666
|
var Models;
|
|
541
667
|
(function (Models) {
|
|
542
668
|
async function list(openai, listOptions, options) {
|
|
@@ -636,6 +762,29 @@ var ScoreLlm;
|
|
|
636
762
|
}
|
|
637
763
|
ScoreLlm.retrieveValidate = retrieveValidate;
|
|
638
764
|
})(ScoreLlm || (exports.ScoreLlm = ScoreLlm = {}));
|
|
765
|
+
var MultichatLlm;
|
|
766
|
+
(function (MultichatLlm) {
|
|
767
|
+
async function list(openai, listOptions, options) {
|
|
768
|
+
const response = await openai.get("/multichat/llms", Object.assign({ query: listOptions }, options));
|
|
769
|
+
return response;
|
|
770
|
+
}
|
|
771
|
+
MultichatLlm.list = list;
|
|
772
|
+
async function count(openai, options) {
|
|
773
|
+
const response = await openai.get("/multichat/llms/count", options);
|
|
774
|
+
return response;
|
|
775
|
+
}
|
|
776
|
+
MultichatLlm.count = count;
|
|
777
|
+
async function retrieve(openai, model, retrieveOptions, options) {
|
|
778
|
+
const response = await openai.get(`/multichat/llms/${model}`, Object.assign({ query: retrieveOptions }, options));
|
|
779
|
+
return response;
|
|
780
|
+
}
|
|
781
|
+
MultichatLlm.retrieve = retrieve;
|
|
782
|
+
async function retrieveValidate(openai, model, retrieveOptions, options) {
|
|
783
|
+
const response = await openai.post("/multichat/llms", Object.assign({ query: retrieveOptions, body: model }, options));
|
|
784
|
+
return response;
|
|
785
|
+
}
|
|
786
|
+
MultichatLlm.retrieveValidate = retrieveValidate;
|
|
787
|
+
})(MultichatLlm || (exports.MultichatLlm = MultichatLlm = {}));
|
|
639
788
|
var ScoreModel;
|
|
640
789
|
(function (ScoreModel) {
|
|
641
790
|
async function list(openai, listOptions, options) {
|
|
@@ -659,6 +808,29 @@ var ScoreModel;
|
|
|
659
808
|
}
|
|
660
809
|
ScoreModel.retrieveValidate = retrieveValidate;
|
|
661
810
|
})(ScoreModel || (exports.ScoreModel = ScoreModel = {}));
|
|
811
|
+
var MultichatModel;
|
|
812
|
+
(function (MultichatModel) {
|
|
813
|
+
async function list(openai, listOptions, options) {
|
|
814
|
+
const response = await openai.get("/multichat/models", Object.assign({ query: listOptions }, options));
|
|
815
|
+
return response;
|
|
816
|
+
}
|
|
817
|
+
MultichatModel.list = list;
|
|
818
|
+
async function count(openai, options) {
|
|
819
|
+
const response = await openai.get("/multichat/models/count", options);
|
|
820
|
+
return response;
|
|
821
|
+
}
|
|
822
|
+
MultichatModel.count = count;
|
|
823
|
+
async function retrieve(openai, model, retrieveOptions, options) {
|
|
824
|
+
const response = await openai.get(`/multichat/models/${model}`, Object.assign({ query: retrieveOptions }, options));
|
|
825
|
+
return response;
|
|
826
|
+
}
|
|
827
|
+
MultichatModel.retrieve = retrieve;
|
|
828
|
+
async function retrieveValidate(openai, model, retrieveOptions, options) {
|
|
829
|
+
const response = await openai.post("/multichat/models", Object.assign({ query: retrieveOptions, body: model }, options));
|
|
830
|
+
return response;
|
|
831
|
+
}
|
|
832
|
+
MultichatModel.retrieveValidate = retrieveValidate;
|
|
833
|
+
})(MultichatModel || (exports.MultichatModel = MultichatModel = {}));
|
|
662
834
|
function merge(a, b, combine) {
|
|
663
835
|
if (a !== null && a !== undefined && b !== null && b !== undefined) {
|
|
664
836
|
return combine ? combine(a, b) : [a, false];
|
package/dist/index.d.ts
CHANGED
|
@@ -132,7 +132,7 @@ export declare namespace Chat {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
type Message = Message.Developer | Message.System | Message.User | Message.Assistant | Message.Tool | Message.ChatCompletion | Message.ScoreCompletion;
|
|
135
|
+
type Message = Message.Developer | Message.System | Message.User | Message.Assistant | Message.Tool | Message.ChatCompletion | Message.ScoreCompletion | Message.MultichatCompletion;
|
|
136
136
|
namespace Message {
|
|
137
137
|
type SimpleContent = string | SimpleContentPart[];
|
|
138
138
|
interface SimpleContentPart {
|
|
@@ -243,6 +243,12 @@ export declare namespace Chat {
|
|
|
243
243
|
choice_index: number;
|
|
244
244
|
name?: string | null;
|
|
245
245
|
}
|
|
246
|
+
interface MultichatCompletion {
|
|
247
|
+
role: "multichat_completion";
|
|
248
|
+
id: string;
|
|
249
|
+
choice_index: number;
|
|
250
|
+
name?: string | null;
|
|
251
|
+
}
|
|
246
252
|
}
|
|
247
253
|
interface ProviderPreferences {
|
|
248
254
|
order?: string[] | null;
|
|
@@ -505,7 +511,7 @@ export declare namespace Score {
|
|
|
505
511
|
}
|
|
506
512
|
type ChatCompletionCreateParams = ChatCompletionCreateParamsStreaming | ChatCompletionCreateParamsNonStreaming;
|
|
507
513
|
type Model = string | ScoreModelBase;
|
|
508
|
-
type Choice = string | Choice.ChatCompletion | Choice.ScoreCompletion;
|
|
514
|
+
type Choice = string | Chat.Completions.Response.Unary.Message | Choice.ChatCompletion | Choice.ScoreCompletion | Choice.MultichatCompletion;
|
|
509
515
|
namespace Choice {
|
|
510
516
|
interface ChatCompletion {
|
|
511
517
|
type: "chat_completion";
|
|
@@ -517,6 +523,11 @@ export declare namespace Score {
|
|
|
517
523
|
id: string;
|
|
518
524
|
choice_index: number;
|
|
519
525
|
}
|
|
526
|
+
interface MultichatCompletion {
|
|
527
|
+
type: "multichat_completion";
|
|
528
|
+
id: string;
|
|
529
|
+
choice_index: number;
|
|
530
|
+
}
|
|
520
531
|
}
|
|
521
532
|
}
|
|
522
533
|
namespace Response {
|
|
@@ -618,12 +629,7 @@ export declare namespace Score {
|
|
|
618
629
|
function merged(a: CompletionMetadata, b: CompletionMetadata): [CompletionMetadata, boolean];
|
|
619
630
|
}
|
|
620
631
|
}
|
|
621
|
-
|
|
622
|
-
count?: number | null;
|
|
623
|
-
offset?: number | null;
|
|
624
|
-
chat_filter?: boolean | null;
|
|
625
|
-
}
|
|
626
|
-
function list(openai: OpenAI, listOptions?: ListOptions, options?: OpenAI.RequestOptions): Promise<{
|
|
632
|
+
function list(openai: OpenAI, listOptions?: Chat.Completions.ListOptions, options?: OpenAI.RequestOptions): Promise<{
|
|
627
633
|
data: Chat.Completions.ListItem[];
|
|
628
634
|
}>;
|
|
629
635
|
function publish(openai: OpenAI, id: string, options?: OpenAI.RequestOptions): Promise<void>;
|
|
@@ -639,6 +645,99 @@ export declare namespace Score {
|
|
|
639
645
|
function create(openai: OpenAI, body: Request.ChatCompletionCreateParamsNonStreaming, options?: OpenAI.RequestOptions): Promise<Response.Unary.ChatCompletion>;
|
|
640
646
|
}
|
|
641
647
|
}
|
|
648
|
+
export declare namespace Multichat {
|
|
649
|
+
namespace Completions {
|
|
650
|
+
namespace Request {
|
|
651
|
+
interface ChatCompletionCreateParamsBase {
|
|
652
|
+
messages: Chat.Completions.Request.Message[];
|
|
653
|
+
model: Model;
|
|
654
|
+
seed?: number | null;
|
|
655
|
+
service_tier?: Chat.Completions.Request.ServiceTier | null;
|
|
656
|
+
stream_options?: Chat.Completions.Request.StreamOptions | null;
|
|
657
|
+
tools?: Chat.Completions.Request.Tool[] | null;
|
|
658
|
+
usage?: Chat.Completions.Request.Usage | null;
|
|
659
|
+
response_format?: Chat.Completions.Request.ResponseFormat | null;
|
|
660
|
+
}
|
|
661
|
+
interface ChatCompletionCreateParamsStreaming extends ChatCompletionCreateParamsBase {
|
|
662
|
+
stream: true;
|
|
663
|
+
}
|
|
664
|
+
interface ChatCompletionCreateParamsNonStreaming extends ChatCompletionCreateParamsBase {
|
|
665
|
+
stream?: false | null;
|
|
666
|
+
}
|
|
667
|
+
type ChatCompletionCreateParams = ChatCompletionCreateParamsStreaming | ChatCompletionCreateParamsNonStreaming;
|
|
668
|
+
type Model = string | MultichatModelBase;
|
|
669
|
+
}
|
|
670
|
+
namespace Response {
|
|
671
|
+
namespace Streaming {
|
|
672
|
+
interface ChatCompletionChunk {
|
|
673
|
+
id: string;
|
|
674
|
+
choices: Choice[];
|
|
675
|
+
created: number;
|
|
676
|
+
model: string;
|
|
677
|
+
object: "chat.completion.chunk";
|
|
678
|
+
usage?: Chat.Completions.Response.Usage;
|
|
679
|
+
}
|
|
680
|
+
namespace ChatCompletionChunk {
|
|
681
|
+
function merged(a: ChatCompletionChunk, b: ChatCompletionChunk): [ChatCompletionChunk, boolean];
|
|
682
|
+
}
|
|
683
|
+
interface Choice {
|
|
684
|
+
delta: Chat.Completions.Response.Streaming.Delta;
|
|
685
|
+
finish_reason: Chat.Completions.Response.FinishReason | null;
|
|
686
|
+
index: number;
|
|
687
|
+
logprobs?: Chat.Completions.Response.Logprobs;
|
|
688
|
+
error?: ObjectiveAIError;
|
|
689
|
+
model?: string;
|
|
690
|
+
model_index?: number | null;
|
|
691
|
+
completion_metadata?: Score.Completions.Response.CompletionMetadata;
|
|
692
|
+
}
|
|
693
|
+
namespace Choice {
|
|
694
|
+
function merged(a: Choice, b: Choice): [Choice, boolean];
|
|
695
|
+
function mergedList(a: Choice[], b: Choice[]): [Choice[], boolean];
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
namespace Unary {
|
|
699
|
+
interface ChatCompletion {
|
|
700
|
+
id: string;
|
|
701
|
+
choices: Choice[];
|
|
702
|
+
created: number;
|
|
703
|
+
model: string;
|
|
704
|
+
object: "chat.completion";
|
|
705
|
+
usage?: Chat.Completions.Response.Usage;
|
|
706
|
+
}
|
|
707
|
+
interface Choice {
|
|
708
|
+
message: Chat.Completions.Response.Unary.Message;
|
|
709
|
+
finish_reason: Chat.Completions.Response.FinishReason;
|
|
710
|
+
index: number;
|
|
711
|
+
logprobs: Chat.Completions.Response.Logprobs | null;
|
|
712
|
+
error: ObjectiveAIError | null;
|
|
713
|
+
model: string | null;
|
|
714
|
+
model_index: number | null;
|
|
715
|
+
completion_metadata: Score.Completions.Response.CompletionMetadata | null;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
function list(openai: OpenAI, listOptions?: Chat.Completions.ListOptions, options?: OpenAI.RequestOptions): Promise<{
|
|
720
|
+
data: Chat.Completions.ListItem[];
|
|
721
|
+
}>;
|
|
722
|
+
function publish(openai: OpenAI, id: string, options?: OpenAI.RequestOptions): Promise<void>;
|
|
723
|
+
function retrieve(openai: OpenAI, id: string, options?: OpenAI.RequestOptions): Promise<{
|
|
724
|
+
request: Request.ChatCompletionCreateParams;
|
|
725
|
+
response: Response.Unary.ChatCompletion;
|
|
726
|
+
}>;
|
|
727
|
+
function create(openai: OpenAI, body: Request.ChatCompletionCreateParamsStreaming, options?: OpenAI.RequestOptions): Promise<Stream<Response.Streaming.ChatCompletionChunk | ObjectiveAIError>>;
|
|
728
|
+
function create(openai: OpenAI, body: Request.ChatCompletionCreateParamsNonStreaming, options?: OpenAI.RequestOptions): Promise<Response.Unary.ChatCompletion>;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
export declare namespace Conversation {
|
|
732
|
+
namespace Completions {
|
|
733
|
+
interface ListItem extends Chat.Completions.ListItem {
|
|
734
|
+
type: "score" | "multichat";
|
|
735
|
+
}
|
|
736
|
+
function list(openai: OpenAI, listOptions?: Chat.Completions.ListOptions, options?: OpenAI.RequestOptions): Promise<{
|
|
737
|
+
data: ListItem[];
|
|
738
|
+
}>;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
642
741
|
export declare namespace Models {
|
|
643
742
|
interface Model {
|
|
644
743
|
id: string;
|
|
@@ -767,6 +866,10 @@ export interface Metadata {
|
|
|
767
866
|
chat_completion_tokens: number;
|
|
768
867
|
chat_prompt_tokens: number;
|
|
769
868
|
chat_total_cost: number;
|
|
869
|
+
multichat_requests: number;
|
|
870
|
+
multichat_completion_tokens: number;
|
|
871
|
+
multichat_prompt_tokens: number;
|
|
872
|
+
multichat_total_cost: number;
|
|
770
873
|
}
|
|
771
874
|
export declare namespace Metadata {
|
|
772
875
|
function get(openai: OpenAI, options?: OpenAI.RequestOptions): Promise<Metadata>;
|
|
@@ -798,6 +901,7 @@ export interface ScoreLlmBase {
|
|
|
798
901
|
}
|
|
799
902
|
export interface ScoreLlmWithoutIndices extends ScoreLlmBase {
|
|
800
903
|
id: string;
|
|
904
|
+
multichat_id: string;
|
|
801
905
|
training_table_id?: string;
|
|
802
906
|
}
|
|
803
907
|
export interface ScoreLlmWithoutIndicesWithMetadata extends ScoreLlmWithoutIndices {
|
|
@@ -809,6 +913,7 @@ export interface ScoreLlmWithoutIndicesWithMetadata extends ScoreLlmWithoutIndic
|
|
|
809
913
|
}
|
|
810
914
|
export interface ScoreLlm extends ScoreLlmWithoutIndices {
|
|
811
915
|
index: number;
|
|
916
|
+
multichat_index: number;
|
|
812
917
|
training_table_index?: number;
|
|
813
918
|
}
|
|
814
919
|
export declare namespace ScoreLlm {
|
|
@@ -837,12 +942,29 @@ export declare namespace ScoreLlm {
|
|
|
837
942
|
function retrieveValidate(openai: OpenAI, model: ScoreLlmBase, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<ScoreLlmWithoutIndices>;
|
|
838
943
|
function retrieveValidate(openai: OpenAI, model: ScoreLlmBase, retrieveOptions: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<ScoreLlmWithoutIndicesWithMetadata>;
|
|
839
944
|
}
|
|
945
|
+
export type MultichatLlmBase = ScoreLlmBase;
|
|
946
|
+
export type MultichatLlmWithoutIndices = ScoreLlmWithoutIndices;
|
|
947
|
+
export type MultichatLlmWithoutIndicesWithMetadata = ScoreLlmWithoutIndicesWithMetadata;
|
|
948
|
+
export type MultichatLlm = ScoreLlm;
|
|
949
|
+
export declare namespace MultichatLlm {
|
|
950
|
+
function list(openai: OpenAI, listOptions?: Models.ListOptions, options?: OpenAI.RequestOptions): Promise<{
|
|
951
|
+
data: string[];
|
|
952
|
+
}>;
|
|
953
|
+
function count(openai: OpenAI, options?: OpenAI.RequestOptions): Promise<{
|
|
954
|
+
data: number;
|
|
955
|
+
}>;
|
|
956
|
+
function retrieve(openai: OpenAI, model: string, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<ScoreLlmWithoutIndices>;
|
|
957
|
+
function retrieve(openai: OpenAI, model: string, retrieveOptions: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<ScoreLlmWithoutIndicesWithMetadata>;
|
|
958
|
+
function retrieveValidate(openai: OpenAI, model: ScoreLlmBase, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<ScoreLlmWithoutIndices>;
|
|
959
|
+
function retrieveValidate(openai: OpenAI, model: ScoreLlmBase, retrieveOptions: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<ScoreLlmWithoutIndicesWithMetadata>;
|
|
960
|
+
}
|
|
840
961
|
export interface ScoreModelBase {
|
|
841
962
|
llms: ScoreLlmBase[];
|
|
842
963
|
weight: ScoreModel.Weight;
|
|
843
964
|
}
|
|
844
965
|
export interface ScoreModel {
|
|
845
966
|
id: string;
|
|
967
|
+
multichat_id: string;
|
|
846
968
|
training_table_id?: string;
|
|
847
969
|
llms: ScoreLlm[];
|
|
848
970
|
weight: ScoreModel.Weight;
|
|
@@ -881,6 +1003,21 @@ export declare namespace ScoreModel {
|
|
|
881
1003
|
function retrieveValidate(openai: OpenAI, model: ScoreModelBase, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<ScoreModel>;
|
|
882
1004
|
function retrieveValidate(openai: OpenAI, model: ScoreModelBase, retrieveOptions: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<ScoreModelWithMetadata>;
|
|
883
1005
|
}
|
|
1006
|
+
export type MultichatModelBase = ScoreModelBase;
|
|
1007
|
+
export type MultichatModel = ScoreModel;
|
|
1008
|
+
export type MultichatModelWithMetadata = ScoreModelWithMetadata;
|
|
1009
|
+
export declare namespace MultichatModel {
|
|
1010
|
+
function list(openai: OpenAI, listOptions?: Models.ListOptions, options?: OpenAI.RequestOptions): Promise<{
|
|
1011
|
+
data: string[];
|
|
1012
|
+
}>;
|
|
1013
|
+
function count(openai: OpenAI, options?: OpenAI.RequestOptions): Promise<{
|
|
1014
|
+
count: number;
|
|
1015
|
+
}>;
|
|
1016
|
+
function retrieve(openai: OpenAI, model: string, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<MultichatModel>;
|
|
1017
|
+
function retrieve(openai: OpenAI, model: string, retrieveOptions: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<MultichatModelWithMetadata>;
|
|
1018
|
+
function retrieveValidate(openai: OpenAI, model: MultichatModelBase, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<MultichatModel>;
|
|
1019
|
+
function retrieveValidate(openai: OpenAI, model: MultichatModelBase, retrieveOptions: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<MultichatModelWithMetadata>;
|
|
1020
|
+
}
|
|
884
1021
|
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
885
1022
|
[key: string]: JsonValue;
|
|
886
1023
|
};
|
package/dist/index.js
CHANGED
|
@@ -534,6 +534,132 @@ export var Score;
|
|
|
534
534
|
Completions.create = create;
|
|
535
535
|
})(Completions = Score.Completions || (Score.Completions = {}));
|
|
536
536
|
})(Score || (Score = {}));
|
|
537
|
+
export var Multichat;
|
|
538
|
+
(function (Multichat) {
|
|
539
|
+
let Completions;
|
|
540
|
+
(function (Completions) {
|
|
541
|
+
let Response;
|
|
542
|
+
(function (Response) {
|
|
543
|
+
let Streaming;
|
|
544
|
+
(function (Streaming) {
|
|
545
|
+
let ChatCompletionChunk;
|
|
546
|
+
(function (ChatCompletionChunk) {
|
|
547
|
+
function merged(a, b) {
|
|
548
|
+
const id = a.id;
|
|
549
|
+
const [choices, choicesChanged] = Choice.mergedList(a.choices, b.choices);
|
|
550
|
+
const created = a.created;
|
|
551
|
+
const model = a.model;
|
|
552
|
+
const object = a.object;
|
|
553
|
+
const [usage, usageChanged] = merge(a.usage, b.usage, Chat.Completions.Response.Usage.merged);
|
|
554
|
+
if (choicesChanged || usageChanged) {
|
|
555
|
+
return [
|
|
556
|
+
Object.assign({ id,
|
|
557
|
+
choices,
|
|
558
|
+
created,
|
|
559
|
+
model,
|
|
560
|
+
object }, (usage !== undefined ? { usage } : {})),
|
|
561
|
+
true,
|
|
562
|
+
];
|
|
563
|
+
}
|
|
564
|
+
else {
|
|
565
|
+
return [a, false];
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
ChatCompletionChunk.merged = merged;
|
|
569
|
+
})(ChatCompletionChunk = Streaming.ChatCompletionChunk || (Streaming.ChatCompletionChunk = {}));
|
|
570
|
+
let Choice;
|
|
571
|
+
(function (Choice) {
|
|
572
|
+
function merged(a, b) {
|
|
573
|
+
const [delta, deltaChanged] = merge(a.delta, b.delta, Chat.Completions.Response.Streaming.Delta.merged);
|
|
574
|
+
const [finish_reason, finish_reasonChanged] = merge(a.finish_reason, b.finish_reason);
|
|
575
|
+
const index = a.index;
|
|
576
|
+
const [logprobs, logprobsChanged] = merge(a.logprobs, b.logprobs, Chat.Completions.Response.Logprobs.merged);
|
|
577
|
+
const [error, errorChanged] = merge(a.error, b.error);
|
|
578
|
+
const [model, modelChanged] = merge(a.model, b.model);
|
|
579
|
+
const [model_index, model_indexChanged] = merge(a.model_index, b.model_index);
|
|
580
|
+
const [completion_metadata, completion_metadataChanged] = merge(a.completion_metadata, b.completion_metadata, Score.Completions.Response.CompletionMetadata.merged);
|
|
581
|
+
if (deltaChanged ||
|
|
582
|
+
finish_reasonChanged ||
|
|
583
|
+
logprobsChanged ||
|
|
584
|
+
errorChanged ||
|
|
585
|
+
modelChanged ||
|
|
586
|
+
model_indexChanged ||
|
|
587
|
+
completion_metadataChanged) {
|
|
588
|
+
return [
|
|
589
|
+
Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ delta,
|
|
590
|
+
finish_reason,
|
|
591
|
+
index }, (logprobs !== undefined ? { logprobs } : {})), (error !== undefined ? { error } : {})), (model !== undefined ? { model } : {})), (model_index !== undefined ? { model_index } : {})), (completion_metadata !== undefined
|
|
592
|
+
? { completion_metadata }
|
|
593
|
+
: {})),
|
|
594
|
+
true,
|
|
595
|
+
];
|
|
596
|
+
}
|
|
597
|
+
else {
|
|
598
|
+
return [a, false];
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
Choice.merged = merged;
|
|
602
|
+
function mergedList(a, b) {
|
|
603
|
+
let merged = undefined;
|
|
604
|
+
for (const choice of b) {
|
|
605
|
+
const existingIndex = a.findIndex(({ index }) => index === choice.index);
|
|
606
|
+
if (existingIndex === -1) {
|
|
607
|
+
if (merged === undefined) {
|
|
608
|
+
merged = [...a, choice];
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
merged.push(choice);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
const [mergedChoice, choiceChanged] = Choice.merged(a[existingIndex], choice);
|
|
616
|
+
if (choiceChanged) {
|
|
617
|
+
if (merged === undefined) {
|
|
618
|
+
merged = [...a];
|
|
619
|
+
}
|
|
620
|
+
merged[existingIndex] = mergedChoice;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
return merged ? [merged, true] : [a, false];
|
|
625
|
+
}
|
|
626
|
+
Choice.mergedList = mergedList;
|
|
627
|
+
})(Choice = Streaming.Choice || (Streaming.Choice = {}));
|
|
628
|
+
})(Streaming = Response.Streaming || (Response.Streaming = {}));
|
|
629
|
+
})(Response = Completions.Response || (Completions.Response = {}));
|
|
630
|
+
async function list(openai, listOptions, options) {
|
|
631
|
+
const response = await openai.get("/multichat/completions", Object.assign({ query: listOptions }, options));
|
|
632
|
+
return response;
|
|
633
|
+
}
|
|
634
|
+
Completions.list = list;
|
|
635
|
+
async function publish(openai, id, options) {
|
|
636
|
+
await openai.post(`/multichat/completions/${id}/publish`, options);
|
|
637
|
+
}
|
|
638
|
+
Completions.publish = publish;
|
|
639
|
+
async function retrieve(openai, id, options) {
|
|
640
|
+
const response = await openai.get(`/multichat/completions/${id}`, options);
|
|
641
|
+
return response;
|
|
642
|
+
}
|
|
643
|
+
Completions.retrieve = retrieve;
|
|
644
|
+
async function create(openai, body, options) {
|
|
645
|
+
var _a;
|
|
646
|
+
const response = await openai.post("/multichat/completions", Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
|
|
647
|
+
return response;
|
|
648
|
+
}
|
|
649
|
+
Completions.create = create;
|
|
650
|
+
})(Completions = Multichat.Completions || (Multichat.Completions = {}));
|
|
651
|
+
})(Multichat || (Multichat = {}));
|
|
652
|
+
export var Conversation;
|
|
653
|
+
(function (Conversation) {
|
|
654
|
+
let Completions;
|
|
655
|
+
(function (Completions) {
|
|
656
|
+
async function list(openai, listOptions, options) {
|
|
657
|
+
const response = await openai.get("/conversation/completions", Object.assign({ query: listOptions }, options));
|
|
658
|
+
return response;
|
|
659
|
+
}
|
|
660
|
+
Completions.list = list;
|
|
661
|
+
})(Completions = Conversation.Completions || (Conversation.Completions = {}));
|
|
662
|
+
})(Conversation || (Conversation = {}));
|
|
537
663
|
export var Models;
|
|
538
664
|
(function (Models) {
|
|
539
665
|
async function list(openai, listOptions, options) {
|
|
@@ -633,6 +759,29 @@ export var ScoreLlm;
|
|
|
633
759
|
}
|
|
634
760
|
ScoreLlm.retrieveValidate = retrieveValidate;
|
|
635
761
|
})(ScoreLlm || (ScoreLlm = {}));
|
|
762
|
+
export var MultichatLlm;
|
|
763
|
+
(function (MultichatLlm) {
|
|
764
|
+
async function list(openai, listOptions, options) {
|
|
765
|
+
const response = await openai.get("/multichat/llms", Object.assign({ query: listOptions }, options));
|
|
766
|
+
return response;
|
|
767
|
+
}
|
|
768
|
+
MultichatLlm.list = list;
|
|
769
|
+
async function count(openai, options) {
|
|
770
|
+
const response = await openai.get("/multichat/llms/count", options);
|
|
771
|
+
return response;
|
|
772
|
+
}
|
|
773
|
+
MultichatLlm.count = count;
|
|
774
|
+
async function retrieve(openai, model, retrieveOptions, options) {
|
|
775
|
+
const response = await openai.get(`/multichat/llms/${model}`, Object.assign({ query: retrieveOptions }, options));
|
|
776
|
+
return response;
|
|
777
|
+
}
|
|
778
|
+
MultichatLlm.retrieve = retrieve;
|
|
779
|
+
async function retrieveValidate(openai, model, retrieveOptions, options) {
|
|
780
|
+
const response = await openai.post("/multichat/llms", Object.assign({ query: retrieveOptions, body: model }, options));
|
|
781
|
+
return response;
|
|
782
|
+
}
|
|
783
|
+
MultichatLlm.retrieveValidate = retrieveValidate;
|
|
784
|
+
})(MultichatLlm || (MultichatLlm = {}));
|
|
636
785
|
export var ScoreModel;
|
|
637
786
|
(function (ScoreModel) {
|
|
638
787
|
async function list(openai, listOptions, options) {
|
|
@@ -656,6 +805,29 @@ export var ScoreModel;
|
|
|
656
805
|
}
|
|
657
806
|
ScoreModel.retrieveValidate = retrieveValidate;
|
|
658
807
|
})(ScoreModel || (ScoreModel = {}));
|
|
808
|
+
export var MultichatModel;
|
|
809
|
+
(function (MultichatModel) {
|
|
810
|
+
async function list(openai, listOptions, options) {
|
|
811
|
+
const response = await openai.get("/multichat/models", Object.assign({ query: listOptions }, options));
|
|
812
|
+
return response;
|
|
813
|
+
}
|
|
814
|
+
MultichatModel.list = list;
|
|
815
|
+
async function count(openai, options) {
|
|
816
|
+
const response = await openai.get("/multichat/models/count", options);
|
|
817
|
+
return response;
|
|
818
|
+
}
|
|
819
|
+
MultichatModel.count = count;
|
|
820
|
+
async function retrieve(openai, model, retrieveOptions, options) {
|
|
821
|
+
const response = await openai.get(`/multichat/models/${model}`, Object.assign({ query: retrieveOptions }, options));
|
|
822
|
+
return response;
|
|
823
|
+
}
|
|
824
|
+
MultichatModel.retrieve = retrieve;
|
|
825
|
+
async function retrieveValidate(openai, model, retrieveOptions, options) {
|
|
826
|
+
const response = await openai.post("/multichat/models", Object.assign({ query: retrieveOptions, body: model }, options));
|
|
827
|
+
return response;
|
|
828
|
+
}
|
|
829
|
+
MultichatModel.retrieveValidate = retrieveValidate;
|
|
830
|
+
})(MultichatModel || (MultichatModel = {}));
|
|
659
831
|
function merge(a, b, combine) {
|
|
660
832
|
if (a !== null && a !== undefined && b !== null && b !== undefined) {
|
|
661
833
|
return combine ? combine(a, b) : [a, false];
|