objectiveai 1.1.1 → 1.1.3
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 +132 -0
- 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
|
@@ -469,6 +469,7 @@ export declare namespace Chat {
|
|
|
469
469
|
}
|
|
470
470
|
interface ListItem {
|
|
471
471
|
id: string;
|
|
472
|
+
preview: string | null;
|
|
472
473
|
created: string;
|
|
473
474
|
}
|
|
474
475
|
function list(openai: OpenAI, listOptions?: ListOptions, options?: OpenAI.RequestOptions): Promise<{
|
|
@@ -633,6 +634,99 @@ export declare namespace Score {
|
|
|
633
634
|
function create(openai: OpenAI, body: Request.ChatCompletionCreateParamsNonStreaming, options?: OpenAI.RequestOptions): Promise<Response.Unary.ChatCompletion>;
|
|
634
635
|
}
|
|
635
636
|
}
|
|
637
|
+
export declare namespace Multichat {
|
|
638
|
+
namespace Completions {
|
|
639
|
+
namespace Request {
|
|
640
|
+
interface ChatCompletionCreateParamsBase {
|
|
641
|
+
messages: Chat.Completions.Request.Message[];
|
|
642
|
+
model: Model;
|
|
643
|
+
seed?: number | null;
|
|
644
|
+
service_tier?: Chat.Completions.Request.ServiceTier | null;
|
|
645
|
+
stream_options?: Chat.Completions.Request.StreamOptions | null;
|
|
646
|
+
tools?: Chat.Completions.Request.Tool[] | null;
|
|
647
|
+
usage?: Chat.Completions.Request.Usage | null;
|
|
648
|
+
response_format?: Chat.Completions.Request.ResponseFormat | null;
|
|
649
|
+
}
|
|
650
|
+
interface ChatCompletionCreateParamsStreaming extends ChatCompletionCreateParamsBase {
|
|
651
|
+
stream: true;
|
|
652
|
+
}
|
|
653
|
+
interface ChatCompletionCreateParamsNonStreaming extends ChatCompletionCreateParamsBase {
|
|
654
|
+
stream?: false | null;
|
|
655
|
+
}
|
|
656
|
+
type ChatCompletionCreateParams = ChatCompletionCreateParamsStreaming | ChatCompletionCreateParamsNonStreaming;
|
|
657
|
+
type Model = string | MultichatModelBase;
|
|
658
|
+
}
|
|
659
|
+
namespace Response {
|
|
660
|
+
namespace Streaming {
|
|
661
|
+
interface ChatCompletionChunk {
|
|
662
|
+
id: string;
|
|
663
|
+
choices: Choice[];
|
|
664
|
+
created: number;
|
|
665
|
+
model: string;
|
|
666
|
+
object: "chat.completion.chunk";
|
|
667
|
+
usage?: Chat.Completions.Response.Usage;
|
|
668
|
+
}
|
|
669
|
+
namespace ChatCompletionChunk {
|
|
670
|
+
function merged(a: ChatCompletionChunk, b: ChatCompletionChunk): [ChatCompletionChunk, boolean];
|
|
671
|
+
}
|
|
672
|
+
interface Choice {
|
|
673
|
+
delta: Chat.Completions.Response.Streaming.Delta;
|
|
674
|
+
finish_reason: Chat.Completions.Response.FinishReason | null;
|
|
675
|
+
index: number;
|
|
676
|
+
logprobs?: Chat.Completions.Response.Logprobs;
|
|
677
|
+
error?: ObjectiveAIError;
|
|
678
|
+
model?: string;
|
|
679
|
+
model_index?: number | null;
|
|
680
|
+
completion_metadata?: Score.Completions.Response.CompletionMetadata;
|
|
681
|
+
}
|
|
682
|
+
namespace Choice {
|
|
683
|
+
function merged(a: Choice, b: Choice): [Choice, boolean];
|
|
684
|
+
function mergedList(a: Choice[], b: Choice[]): [Choice[], boolean];
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
namespace Unary {
|
|
688
|
+
interface ChatCompletion {
|
|
689
|
+
id: string;
|
|
690
|
+
choices: Choice[];
|
|
691
|
+
created: number;
|
|
692
|
+
model: string;
|
|
693
|
+
object: "chat.completion";
|
|
694
|
+
usage?: Chat.Completions.Response.Usage;
|
|
695
|
+
}
|
|
696
|
+
interface Choice {
|
|
697
|
+
message: Chat.Completions.Response.Unary.Message;
|
|
698
|
+
finish_reason: Chat.Completions.Response.FinishReason;
|
|
699
|
+
index: number;
|
|
700
|
+
logprobs: Chat.Completions.Response.Logprobs | null;
|
|
701
|
+
error: ObjectiveAIError | null;
|
|
702
|
+
model: string | null;
|
|
703
|
+
model_index: number | null;
|
|
704
|
+
completion_metadata: Score.Completions.Response.CompletionMetadata | null;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
function list(openai: OpenAI, listOptions?: Chat.Completions.ListOptions, options?: OpenAI.RequestOptions): Promise<{
|
|
709
|
+
data: Chat.Completions.ListItem[];
|
|
710
|
+
}>;
|
|
711
|
+
function publish(openai: OpenAI, id: string, options?: OpenAI.RequestOptions): Promise<void>;
|
|
712
|
+
function retrieve(openai: OpenAI, id: string, options?: OpenAI.RequestOptions): Promise<{
|
|
713
|
+
request: Request.ChatCompletionCreateParams;
|
|
714
|
+
response: Response.Unary.ChatCompletion;
|
|
715
|
+
}>;
|
|
716
|
+
function create(openai: OpenAI, body: Request.ChatCompletionCreateParamsStreaming, options?: OpenAI.RequestOptions): Promise<Stream<Response.Streaming.ChatCompletionChunk | ObjectiveAIError>>;
|
|
717
|
+
function create(openai: OpenAI, body: Request.ChatCompletionCreateParamsNonStreaming, options?: OpenAI.RequestOptions): Promise<Response.Unary.ChatCompletion>;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
export declare namespace Conversation {
|
|
721
|
+
namespace Completions {
|
|
722
|
+
interface ListItem extends Chat.Completions.ListItem {
|
|
723
|
+
type: "score" | "multichat";
|
|
724
|
+
}
|
|
725
|
+
function list(openai: OpenAI, listOptions?: Chat.Completions.ListOptions, options?: OpenAI.RequestOptions): Promise<{
|
|
726
|
+
data: ListItem[];
|
|
727
|
+
}>;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
636
730
|
export declare namespace Models {
|
|
637
731
|
interface Model {
|
|
638
732
|
id: string;
|
|
@@ -761,6 +855,10 @@ export interface Metadata {
|
|
|
761
855
|
chat_completion_tokens: number;
|
|
762
856
|
chat_prompt_tokens: number;
|
|
763
857
|
chat_total_cost: number;
|
|
858
|
+
multichat_requests: number;
|
|
859
|
+
multichat_completion_tokens: number;
|
|
860
|
+
multichat_prompt_tokens: number;
|
|
861
|
+
multichat_total_cost: number;
|
|
764
862
|
}
|
|
765
863
|
export declare namespace Metadata {
|
|
766
864
|
function get(openai: OpenAI, options?: OpenAI.RequestOptions): Promise<Metadata>;
|
|
@@ -792,6 +890,7 @@ export interface ScoreLlmBase {
|
|
|
792
890
|
}
|
|
793
891
|
export interface ScoreLlmWithoutIndices extends ScoreLlmBase {
|
|
794
892
|
id: string;
|
|
893
|
+
multichat_id: string;
|
|
795
894
|
training_table_id?: string;
|
|
796
895
|
}
|
|
797
896
|
export interface ScoreLlmWithoutIndicesWithMetadata extends ScoreLlmWithoutIndices {
|
|
@@ -803,6 +902,7 @@ export interface ScoreLlmWithoutIndicesWithMetadata extends ScoreLlmWithoutIndic
|
|
|
803
902
|
}
|
|
804
903
|
export interface ScoreLlm extends ScoreLlmWithoutIndices {
|
|
805
904
|
index: number;
|
|
905
|
+
multichat_index: number;
|
|
806
906
|
training_table_index?: number;
|
|
807
907
|
}
|
|
808
908
|
export declare namespace ScoreLlm {
|
|
@@ -831,12 +931,29 @@ export declare namespace ScoreLlm {
|
|
|
831
931
|
function retrieveValidate(openai: OpenAI, model: ScoreLlmBase, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<ScoreLlmWithoutIndices>;
|
|
832
932
|
function retrieveValidate(openai: OpenAI, model: ScoreLlmBase, retrieveOptions: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<ScoreLlmWithoutIndicesWithMetadata>;
|
|
833
933
|
}
|
|
934
|
+
export type MultichatLlmBase = ScoreLlmBase;
|
|
935
|
+
export type MultichatLlmWithoutIndices = ScoreLlmWithoutIndices;
|
|
936
|
+
export type MultichatLlmWithoutIndicesWithMetadata = ScoreLlmWithoutIndicesWithMetadata;
|
|
937
|
+
export type MultichatLlm = ScoreLlm;
|
|
938
|
+
export declare namespace MultichatLlm {
|
|
939
|
+
function list(openai: OpenAI, listOptions?: Models.ListOptions, options?: OpenAI.RequestOptions): Promise<{
|
|
940
|
+
data: string[];
|
|
941
|
+
}>;
|
|
942
|
+
function count(openai: OpenAI, options?: OpenAI.RequestOptions): Promise<{
|
|
943
|
+
data: number;
|
|
944
|
+
}>;
|
|
945
|
+
function retrieve(openai: OpenAI, model: string, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<ScoreLlmWithoutIndices>;
|
|
946
|
+
function retrieve(openai: OpenAI, model: string, retrieveOptions: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<ScoreLlmWithoutIndicesWithMetadata>;
|
|
947
|
+
function retrieveValidate(openai: OpenAI, model: ScoreLlmBase, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<ScoreLlmWithoutIndices>;
|
|
948
|
+
function retrieveValidate(openai: OpenAI, model: ScoreLlmBase, retrieveOptions: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<ScoreLlmWithoutIndicesWithMetadata>;
|
|
949
|
+
}
|
|
834
950
|
export interface ScoreModelBase {
|
|
835
951
|
llms: ScoreLlmBase[];
|
|
836
952
|
weight: ScoreModel.Weight;
|
|
837
953
|
}
|
|
838
954
|
export interface ScoreModel {
|
|
839
955
|
id: string;
|
|
956
|
+
multichat_id: string;
|
|
840
957
|
training_table_id?: string;
|
|
841
958
|
llms: ScoreLlm[];
|
|
842
959
|
weight: ScoreModel.Weight;
|
|
@@ -875,6 +992,21 @@ export declare namespace ScoreModel {
|
|
|
875
992
|
function retrieveValidate(openai: OpenAI, model: ScoreModelBase, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<ScoreModel>;
|
|
876
993
|
function retrieveValidate(openai: OpenAI, model: ScoreModelBase, retrieveOptions: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<ScoreModelWithMetadata>;
|
|
877
994
|
}
|
|
995
|
+
export type MultichatModelBase = ScoreModelBase;
|
|
996
|
+
export type MultichatModel = ScoreModel;
|
|
997
|
+
export type MultichatModelWithMetadata = ScoreModelWithMetadata;
|
|
998
|
+
export declare namespace MultichatModel {
|
|
999
|
+
function list(openai: OpenAI, listOptions?: Models.ListOptions, options?: OpenAI.RequestOptions): Promise<{
|
|
1000
|
+
data: string[];
|
|
1001
|
+
}>;
|
|
1002
|
+
function count(openai: OpenAI, options?: OpenAI.RequestOptions): Promise<{
|
|
1003
|
+
count: number;
|
|
1004
|
+
}>;
|
|
1005
|
+
function retrieve(openai: OpenAI, model: string, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<MultichatModel>;
|
|
1006
|
+
function retrieve(openai: OpenAI, model: string, retrieveOptions: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<MultichatModelWithMetadata>;
|
|
1007
|
+
function retrieveValidate(openai: OpenAI, model: MultichatModelBase, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<MultichatModel>;
|
|
1008
|
+
function retrieveValidate(openai: OpenAI, model: MultichatModelBase, retrieveOptions: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<MultichatModelWithMetadata>;
|
|
1009
|
+
}
|
|
878
1010
|
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
879
1011
|
[key: string]: JsonValue;
|
|
880
1012
|
};
|
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];
|