objectiveai 1.1.6 → 1.1.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ exports.MultichatModel = exports.ScoreModel = exports.MultichatLlm = exports.ScoreLlm = exports.Metadata = exports.Auth = exports.Models = exports.Apps = exports.Conversation = exports.Multichat = exports.Score = exports.Chat = void 0;
4
4
  var Chat;
5
5
  (function (Chat) {
6
6
  let Completions;
@@ -663,6 +663,126 @@ var Conversation;
663
663
  Completions.list = list;
664
664
  })(Completions = Conversation.Completions || (Conversation.Completions = {}));
665
665
  })(Conversation || (exports.Conversation = Conversation = {}));
666
+ var Apps;
667
+ (function (Apps) {
668
+ let Response;
669
+ (function (Response) {
670
+ let Streaming;
671
+ (function (Streaming) {
672
+ let CompletionChunk;
673
+ (function (CompletionChunk) {
674
+ let ScoreCompletionChunk;
675
+ (function (ScoreCompletionChunk) {
676
+ function merged(a, b) {
677
+ const [base, baseChanged] = Score.Completions.Response.Streaming.ChatCompletionChunk.merged(a, b);
678
+ return baseChanged
679
+ ? [Object.assign(Object.assign({ type: a.type }, base), { index: a.index }), true]
680
+ : [a, false];
681
+ }
682
+ ScoreCompletionChunk.merged = merged;
683
+ })(ScoreCompletionChunk = CompletionChunk.ScoreCompletionChunk || (CompletionChunk.ScoreCompletionChunk = {}));
684
+ let MultichatCompletionChunk;
685
+ (function (MultichatCompletionChunk) {
686
+ function merged(a, b) {
687
+ const [base, baseChanged] = Multichat.Completions.Response.Streaming.ChatCompletionChunk.merged(a, b);
688
+ return baseChanged
689
+ ? [Object.assign(Object.assign({ type: a.type }, base), { index: a.index }), true]
690
+ : [a, false];
691
+ }
692
+ MultichatCompletionChunk.merged = merged;
693
+ })(MultichatCompletionChunk = CompletionChunk.MultichatCompletionChunk || (CompletionChunk.MultichatCompletionChunk = {}));
694
+ function mergedList(a, b) {
695
+ let merged = undefined;
696
+ for (const chunk of b) {
697
+ const existingIndex = a.findIndex((c) => c.index === chunk.index && c.type === chunk.type);
698
+ if (existingIndex === -1) {
699
+ if (merged === undefined) {
700
+ merged = [...a, chunk];
701
+ }
702
+ else {
703
+ merged.push(chunk);
704
+ }
705
+ }
706
+ else if (chunk.type === "score") {
707
+ const [mergedChunk, chunkChanged] = ScoreCompletionChunk.merged(a[existingIndex], chunk);
708
+ if (chunkChanged) {
709
+ if (merged === undefined) {
710
+ merged = [...a];
711
+ }
712
+ merged[existingIndex] = mergedChunk;
713
+ }
714
+ }
715
+ else if (chunk.type === "multichat") {
716
+ const [mergedChunk, chunkChanged] = MultichatCompletionChunk.merged(a[existingIndex], chunk);
717
+ if (chunkChanged) {
718
+ if (merged === undefined) {
719
+ merged = [...a];
720
+ }
721
+ merged[existingIndex] = mergedChunk;
722
+ }
723
+ }
724
+ }
725
+ return merged ? [merged, true] : [a, false];
726
+ }
727
+ CompletionChunk.mergedList = mergedList;
728
+ })(CompletionChunk = Streaming.CompletionChunk || (Streaming.CompletionChunk = {}));
729
+ function merged(a, b) {
730
+ const [completions, completionsChanged] = CompletionChunk.mergedList(a.completions, b.completions);
731
+ const [output, outputChanged] = merge(a.output, b.output);
732
+ const [retry_token, retry_tokenChanged] = merge(a.retry_token, b.retry_token);
733
+ const [error, errorChanged] = merge(a.error, b.error);
734
+ const [app_published, app_publishedChanged] = merge(a.app_published, b.app_published);
735
+ if (completionsChanged ||
736
+ outputChanged ||
737
+ retry_tokenChanged ||
738
+ errorChanged ||
739
+ app_publishedChanged) {
740
+ return [
741
+ Object.assign(Object.assign(Object.assign(Object.assign({ completions }, (output !== undefined ? { output } : {})), (retry_token !== undefined ? { retry_token } : {})), (error !== undefined ? { error } : {})), (app_published !== undefined ? { app_published } : {})),
742
+ true,
743
+ ];
744
+ }
745
+ else {
746
+ return [a, false];
747
+ }
748
+ }
749
+ Streaming.merged = merged;
750
+ })(Streaming = Response.Streaming || (Response.Streaming = {}));
751
+ })(Response = Apps.Response || (Apps.Response = {}));
752
+ async function list(openai, listOptions, options) {
753
+ const response = await openai.get("/apps", Object.assign({ query: listOptions }, options));
754
+ return response;
755
+ }
756
+ Apps.list = list;
757
+ async function count(openai, options) {
758
+ const response = await openai.get("/apps/count", options);
759
+ return response;
760
+ }
761
+ Apps.count = count;
762
+ async function retrieve(openai, author, id, version, retrieveOptions, options) {
763
+ const url = version !== null && version !== undefined
764
+ ? `/apps/${author}/${id}/${version}`
765
+ : `/apps/${author}/${id}`;
766
+ const response = await openai.get(url, Object.assign({ query: retrieveOptions }, options));
767
+ return response;
768
+ }
769
+ Apps.retrieve = retrieve;
770
+ async function executeById(openai, author, id, version, body, options) {
771
+ var _a;
772
+ const url = version !== null && version !== undefined
773
+ ? `/apps/${author}/${id}/${version}`
774
+ : `/apps/${author}/${id}`;
775
+ const response = await openai.post(url, Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
776
+ return response;
777
+ }
778
+ Apps.executeById = executeById;
779
+ async function executeByDefinition(openai, body, options) {
780
+ var _a;
781
+ const response = await openai.post("/apps", Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
782
+ return response;
783
+ }
784
+ Apps.executeByDefinition = executeByDefinition;
785
+ })(Apps || (exports.Apps = Apps = {}));
666
786
  var Models;
667
787
  (function (Models) {
668
788
  async function list(openai, listOptions, options) {
@@ -730,6 +850,19 @@ var Auth;
730
850
  }
731
851
  Credits.retrieve = retrieve;
732
852
  })(Credits = Auth.Credits || (Auth.Credits = {}));
853
+ let Username;
854
+ (function (Username) {
855
+ async function retrieve(openai, options) {
856
+ const response = await openai.get("/auth/username", options);
857
+ return response;
858
+ }
859
+ Username.retrieve = retrieve;
860
+ async function set(openai, username, options) {
861
+ const response = await openai.post("/auth/username", Object.assign({ body: { username } }, options));
862
+ return response;
863
+ }
864
+ Username.set = set;
865
+ })(Username = Auth.Username || (Auth.Username = {}));
733
866
  })(Auth || (exports.Auth = Auth = {}));
734
867
  var Metadata;
735
868
  (function (Metadata) {
package/dist/index.d.ts CHANGED
@@ -739,6 +739,255 @@ export declare namespace Conversation {
739
739
  }>;
740
740
  }
741
741
  }
742
+ export declare namespace Apps {
743
+ interface Expression {
744
+ $jmespath: string;
745
+ }
746
+ type WithExpression<T> = T | Expression;
747
+ type InputProperty = InputProperty.Array | InputProperty.String | InputProperty.Number | InputProperty.Integer | InputProperty.Boolean;
748
+ namespace InputProperty {
749
+ interface Array {
750
+ type: "array";
751
+ description?: string | null;
752
+ items: Record<string, Array.ItemsProperty>;
753
+ }
754
+ namespace Array {
755
+ type ItemsProperty = InputProperty.String | InputProperty.Number | InputProperty.Integer | InputProperty.Boolean;
756
+ }
757
+ interface String {
758
+ type: "string";
759
+ description?: string | null;
760
+ enum?: string[] | null;
761
+ }
762
+ interface Number {
763
+ type: "number";
764
+ description?: string | null;
765
+ }
766
+ interface Integer {
767
+ type: "integer";
768
+ description?: string | null;
769
+ }
770
+ interface Boolean {
771
+ type: "boolean";
772
+ description?: string | null;
773
+ }
774
+ }
775
+ type Step = Step.Score | Step.Multichat;
776
+ namespace Step {
777
+ type Message = Message.Developer | Message.System | Message.User | Message.Assistant | Message.Tool | Message.ChatCompletion | Message.ScoreCompletion | Message.MultichatCompletion;
778
+ namespace Message {
779
+ interface Developer {
780
+ role: Chat.Completions.Request.Message.Developer["role"];
781
+ content: WithExpression<SimpleContent>;
782
+ name?: WithExpression<Chat.Completions.Request.Message.Developer["name"]>;
783
+ }
784
+ interface System {
785
+ role: Chat.Completions.Request.Message.System["role"];
786
+ content: WithExpression<SimpleContent>;
787
+ name?: WithExpression<Chat.Completions.Request.Message.System["name"]>;
788
+ }
789
+ interface User {
790
+ role: Chat.Completions.Request.Message.User["role"];
791
+ content: WithExpression<RichContent>;
792
+ name?: WithExpression<Chat.Completions.Request.Message.User["name"]>;
793
+ }
794
+ interface Assistant {
795
+ role: Chat.Completions.Request.Message.Assistant["role"];
796
+ content?: WithExpression<RichContent> | null;
797
+ name?: WithExpression<Chat.Completions.Request.Message.Assistant["name"]>;
798
+ refusal?: WithExpression<Chat.Completions.Request.Message.Assistant["refusal"]>;
799
+ tool_calls?: WithExpression<WithExpression<Assistant.ToolCall>[]> | null;
800
+ }
801
+ namespace Assistant {
802
+ type ToolCall = ToolCall.Function;
803
+ namespace ToolCall {
804
+ interface Function {
805
+ id: WithExpression<Chat.Completions.Request.Message.Assistant.ToolCall.Function["id"]>;
806
+ function: WithExpression<Function.Definition>;
807
+ type: Chat.Completions.Request.Message.Assistant.ToolCall.Function["type"];
808
+ }
809
+ namespace Function {
810
+ interface Definition {
811
+ name: WithExpression<Chat.Completions.Request.Message.Assistant.ToolCall.Function.Definition["name"]>;
812
+ arguments: WithExpression<Chat.Completions.Request.Message.Assistant.ToolCall.Function.Definition["arguments"]>;
813
+ }
814
+ }
815
+ }
816
+ }
817
+ interface Tool {
818
+ role: Chat.Completions.Request.Message.Tool["role"];
819
+ content: WithExpression<RichContent>;
820
+ tool_call_id: WithExpression<Chat.Completions.Request.Message.Tool["tool_call_id"]>;
821
+ }
822
+ interface ChatCompletion {
823
+ role: Chat.Completions.Request.Message.ChatCompletion["role"];
824
+ id: WithExpression<Chat.Completions.Request.Message.ChatCompletion["id"]>;
825
+ choice_index: WithExpression<Chat.Completions.Request.Message.ChatCompletion["choice_index"]>;
826
+ name?: WithExpression<Chat.Completions.Request.Message.ChatCompletion["name"]>;
827
+ }
828
+ interface ScoreCompletion {
829
+ role: Chat.Completions.Request.Message.ScoreCompletion["role"];
830
+ id: WithExpression<Chat.Completions.Request.Message.ScoreCompletion["id"]>;
831
+ choice_index: WithExpression<Chat.Completions.Request.Message.ScoreCompletion["choice_index"]>;
832
+ name?: WithExpression<Chat.Completions.Request.Message.ScoreCompletion["name"]>;
833
+ }
834
+ interface MultichatCompletion {
835
+ role: Chat.Completions.Request.Message.MultichatCompletion["role"];
836
+ id: WithExpression<Chat.Completions.Request.Message.MultichatCompletion["id"]>;
837
+ choice_index: WithExpression<Chat.Completions.Request.Message.MultichatCompletion["choice_index"]>;
838
+ name?: WithExpression<Chat.Completions.Request.Message.MultichatCompletion["name"]>;
839
+ }
840
+ type SimpleContent = string | WithExpression<Chat.Completions.Request.Message.SimpleContentPart>[];
841
+ type RichContent = string | WithExpression<Chat.Completions.Request.Message.RichContentPart>[];
842
+ }
843
+ type ResponseFormat = ResponseFormat.Text | ResponseFormat.JsonObject | ResponseFormat.JsonSchema;
844
+ namespace ResponseFormat {
845
+ interface Text {
846
+ type: "text";
847
+ }
848
+ interface JsonObject {
849
+ type: "json_object";
850
+ }
851
+ interface JsonSchema {
852
+ type: "json_schema";
853
+ json_schema: WithExpression<JsonSchema.JsonSchema>;
854
+ }
855
+ namespace JsonSchema {
856
+ interface JsonSchema {
857
+ name: WithExpression<Chat.Completions.Request.ResponseFormat.JsonSchema.JsonSchema["name"]>;
858
+ description?: WithExpression<Chat.Completions.Request.ResponseFormat.JsonSchema.JsonSchema["description"]>;
859
+ schema?: WithExpression<Chat.Completions.Request.ResponseFormat.JsonSchema.JsonSchema["schema"]>;
860
+ strict?: WithExpression<Chat.Completions.Request.ResponseFormat.JsonSchema.JsonSchema["strict"]>;
861
+ }
862
+ }
863
+ }
864
+ interface Multichat {
865
+ type: "multichat";
866
+ messages: WithExpression<WithExpression<Message>[]>;
867
+ model: WithExpression<Multichat.Completions.Request.ChatCompletionCreateParams["model"]>;
868
+ response_format?: WithExpression<ResponseFormat> | null;
869
+ }
870
+ interface Score {
871
+ type: "score";
872
+ messages: WithExpression<WithExpression<Message>[]>;
873
+ model: WithExpression<Score.Completions.Request.ChatCompletionCreateParams["model"]>;
874
+ choices: WithExpression<WithExpression<Score.Completions.Request.Choice>[]>;
875
+ }
876
+ }
877
+ namespace Request {
878
+ interface ExecuteByIdRequestBase {
879
+ arguments?: JsonValue;
880
+ retry_token?: string;
881
+ seed?: Chat.Completions.Request.ChatCompletionCreateParamsBase["seed"];
882
+ service_tier?: Chat.Completions.Request.ChatCompletionCreateParamsBase["service_tier"];
883
+ stream_options?: Chat.Completions.Request.ChatCompletionCreateParamsBase["stream_options"];
884
+ usage?: Chat.Completions.Request.ChatCompletionCreateParamsBase["usage"];
885
+ }
886
+ interface ExecuteByIdRequestStreaming extends ExecuteByIdRequestBase {
887
+ stream: true;
888
+ }
889
+ interface ExecuteByIdRequestNonStreaming extends ExecuteByIdRequestBase {
890
+ stream?: false | null;
891
+ }
892
+ type ExecuteByIdRequest = ExecuteByIdRequestStreaming | ExecuteByIdRequestNonStreaming;
893
+ interface ExecuteByDefinitionRequestBase extends ExecuteByIdRequestBase {
894
+ steps: WithExpression<WithExpression<Step>[]>;
895
+ output: Expression;
896
+ publish?: {
897
+ id: string;
898
+ description: string;
899
+ input: Record<string, InputProperty>;
900
+ } | null;
901
+ }
902
+ interface ExecuteByDefinitionRequestStreaming extends ExecuteByDefinitionRequestBase {
903
+ stream: true;
904
+ }
905
+ interface ExecuteByDefinitionRequestNonStreaming extends ExecuteByDefinitionRequestBase {
906
+ stream?: false | null;
907
+ }
908
+ type ExecuteByDefinitionRequest = ExecuteByDefinitionRequestStreaming | ExecuteByDefinitionRequestNonStreaming;
909
+ }
910
+ namespace Response {
911
+ namespace Streaming {
912
+ interface ExecuteResponseChunk {
913
+ completions: CompletionChunk[];
914
+ output?: JsonValue;
915
+ retry_token?: string;
916
+ error?: ObjectiveAIError;
917
+ app_published?: boolean;
918
+ }
919
+ type CompletionChunk = CompletionChunk.ScoreCompletionChunk | CompletionChunk.MultichatCompletionChunk;
920
+ namespace CompletionChunk {
921
+ interface ScoreCompletionChunk extends Score.Completions.Response.Streaming.ChatCompletionChunk {
922
+ type: "score";
923
+ index: number;
924
+ }
925
+ namespace ScoreCompletionChunk {
926
+ function merged(a: ScoreCompletionChunk, b: ScoreCompletionChunk): [ScoreCompletionChunk, boolean];
927
+ }
928
+ interface MultichatCompletionChunk extends Multichat.Completions.Response.Streaming.ChatCompletionChunk {
929
+ type: "multichat";
930
+ index: number;
931
+ }
932
+ namespace MultichatCompletionChunk {
933
+ function merged(a: MultichatCompletionChunk, b: MultichatCompletionChunk): [MultichatCompletionChunk, boolean];
934
+ }
935
+ function mergedList(a: CompletionChunk[], b: CompletionChunk[]): [CompletionChunk[], boolean];
936
+ }
937
+ function merged(a: ExecuteResponseChunk, b: ExecuteResponseChunk): [ExecuteResponseChunk, boolean];
938
+ }
939
+ namespace Unary {
940
+ interface ExecuteResponse {
941
+ completions: Completion[];
942
+ output: JsonValue;
943
+ retry_token: string | null;
944
+ error: ObjectiveAIError | null;
945
+ app_published?: boolean;
946
+ }
947
+ type Completion = Completion.Score | Completion.Multichat;
948
+ namespace Completion {
949
+ interface Score extends Score.Completions.Response.Unary.ChatCompletion {
950
+ type: "score";
951
+ index: number;
952
+ }
953
+ interface Multichat extends Multichat.Completions.Response.Unary.ChatCompletion {
954
+ type: "multichat";
955
+ index: number;
956
+ }
957
+ }
958
+ }
959
+ }
960
+ interface AppHeader {
961
+ author: string;
962
+ id: string;
963
+ version: number;
964
+ description: string;
965
+ }
966
+ interface App extends AppHeader {
967
+ input: Record<string, InputProperty>;
968
+ steps: WithExpression<WithExpression<Step>[]>;
969
+ output: Expression;
970
+ }
971
+ interface AppWithMetadata extends App {
972
+ created: string;
973
+ requests: number;
974
+ completion_tokens: number;
975
+ prompt_tokens: number;
976
+ total_cost: number;
977
+ }
978
+ function list(openai: OpenAI, listOptions?: Models.ListOptions, options?: OpenAI.RequestOptions): Promise<{
979
+ data: AppHeader[];
980
+ }>;
981
+ function count(openai: OpenAI, options?: OpenAI.RequestOptions): Promise<{
982
+ data: number;
983
+ }>;
984
+ function retrieve(openai: OpenAI, author: string, id: string, version?: number | null, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<App>;
985
+ function retrieve(openai: OpenAI, author: string, id: string, version?: number | null, retrieveOptions?: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<AppWithMetadata>;
986
+ function executeById(openai: OpenAI, author: string, id: string, version: number | null | undefined, body: Request.ExecuteByIdRequestStreaming, options?: OpenAI.RequestOptions): Promise<Stream<Response.Streaming.ExecuteResponseChunk>>;
987
+ function executeById(openai: OpenAI, author: string, id: string, version: number | null | undefined, body: Request.ExecuteByIdRequestNonStreaming, options?: OpenAI.RequestOptions): Promise<Response.Unary.ExecuteResponse>;
988
+ function executeByDefinition(openai: OpenAI, body: Request.ExecuteByDefinitionRequestStreaming, options?: OpenAI.RequestOptions): Promise<Stream<Response.Streaming.ExecuteResponseChunk>>;
989
+ function executeByDefinition(openai: OpenAI, body: Request.ExecuteByDefinitionRequestNonStreaming, options?: OpenAI.RequestOptions): Promise<Response.Unary.ExecuteResponse>;
990
+ }
742
991
  export declare namespace Models {
743
992
  interface Model {
744
993
  id: string;
@@ -857,6 +1106,14 @@ export declare namespace Auth {
857
1106
  namespace Credits {
858
1107
  function retrieve(openai: OpenAI, options?: OpenAI.RequestOptions): Promise<Credits>;
859
1108
  }
1109
+ namespace Username {
1110
+ function retrieve(openai: OpenAI, options?: OpenAI.RequestOptions): Promise<{
1111
+ username: string | null;
1112
+ }>;
1113
+ function set(openai: OpenAI, username: string, options?: OpenAI.RequestOptions): Promise<{
1114
+ username: string;
1115
+ }>;
1116
+ }
860
1117
  }
861
1118
  export interface Metadata {
862
1119
  score_requests: number;
@@ -911,6 +1168,8 @@ export interface ScoreLlmWithoutIndicesWithMetadata extends ScoreLlmWithoutIndic
911
1168
  completion_tokens: number;
912
1169
  prompt_tokens: number;
913
1170
  total_cost: number;
1171
+ average_confidence: number;
1172
+ conformity: number;
914
1173
  }
915
1174
  export interface ScoreLlm extends ScoreLlmWithoutIndices {
916
1175
  index: number;
@@ -945,7 +1204,13 @@ export declare namespace ScoreLlm {
945
1204
  }
946
1205
  export type MultichatLlmBase = ScoreLlmBase;
947
1206
  export type MultichatLlmWithoutIndices = ScoreLlmWithoutIndices;
948
- export type MultichatLlmWithoutIndicesWithMetadata = ScoreLlmWithoutIndicesWithMetadata;
1207
+ export interface MultichatLlmWithoutIndicesWithMetadata extends MultichatLlmWithoutIndices {
1208
+ created: string;
1209
+ requests: number;
1210
+ completion_tokens: number;
1211
+ prompt_tokens: number;
1212
+ total_cost: number;
1213
+ }
949
1214
  export type MultichatLlm = ScoreLlm;
950
1215
  export declare namespace MultichatLlm {
951
1216
  function list(openai: OpenAI, listOptions?: Models.ListOptions, options?: OpenAI.RequestOptions): Promise<{
@@ -976,6 +1241,8 @@ export interface ScoreModelWithMetadata extends ScoreModel {
976
1241
  completion_tokens: number;
977
1242
  prompt_tokens: number;
978
1243
  total_cost: number;
1244
+ average_winner_confidence: number;
1245
+ decisiveness: number;
979
1246
  }
980
1247
  export declare namespace ScoreModel {
981
1248
  type Weight = Weight.Static | Weight.TrainingTable;
@@ -1006,7 +1273,13 @@ export declare namespace ScoreModel {
1006
1273
  }
1007
1274
  export type MultichatModelBase = ScoreModelBase;
1008
1275
  export type MultichatModel = ScoreModel;
1009
- export type MultichatModelWithMetadata = ScoreModelWithMetadata;
1276
+ export interface MultichatModelWithMetadata extends MultichatModel {
1277
+ created: string;
1278
+ requests: number;
1279
+ completion_tokens: number;
1280
+ prompt_tokens: number;
1281
+ total_cost: number;
1282
+ }
1010
1283
  export declare namespace MultichatModel {
1011
1284
  function list(openai: OpenAI, listOptions?: Models.ListOptions, options?: OpenAI.RequestOptions): Promise<{
1012
1285
  data: string[];
package/dist/index.js CHANGED
@@ -660,6 +660,126 @@ export var Conversation;
660
660
  Completions.list = list;
661
661
  })(Completions = Conversation.Completions || (Conversation.Completions = {}));
662
662
  })(Conversation || (Conversation = {}));
663
+ export var Apps;
664
+ (function (Apps) {
665
+ let Response;
666
+ (function (Response) {
667
+ let Streaming;
668
+ (function (Streaming) {
669
+ let CompletionChunk;
670
+ (function (CompletionChunk) {
671
+ let ScoreCompletionChunk;
672
+ (function (ScoreCompletionChunk) {
673
+ function merged(a, b) {
674
+ const [base, baseChanged] = Score.Completions.Response.Streaming.ChatCompletionChunk.merged(a, b);
675
+ return baseChanged
676
+ ? [Object.assign(Object.assign({ type: a.type }, base), { index: a.index }), true]
677
+ : [a, false];
678
+ }
679
+ ScoreCompletionChunk.merged = merged;
680
+ })(ScoreCompletionChunk = CompletionChunk.ScoreCompletionChunk || (CompletionChunk.ScoreCompletionChunk = {}));
681
+ let MultichatCompletionChunk;
682
+ (function (MultichatCompletionChunk) {
683
+ function merged(a, b) {
684
+ const [base, baseChanged] = Multichat.Completions.Response.Streaming.ChatCompletionChunk.merged(a, b);
685
+ return baseChanged
686
+ ? [Object.assign(Object.assign({ type: a.type }, base), { index: a.index }), true]
687
+ : [a, false];
688
+ }
689
+ MultichatCompletionChunk.merged = merged;
690
+ })(MultichatCompletionChunk = CompletionChunk.MultichatCompletionChunk || (CompletionChunk.MultichatCompletionChunk = {}));
691
+ function mergedList(a, b) {
692
+ let merged = undefined;
693
+ for (const chunk of b) {
694
+ const existingIndex = a.findIndex((c) => c.index === chunk.index && c.type === chunk.type);
695
+ if (existingIndex === -1) {
696
+ if (merged === undefined) {
697
+ merged = [...a, chunk];
698
+ }
699
+ else {
700
+ merged.push(chunk);
701
+ }
702
+ }
703
+ else if (chunk.type === "score") {
704
+ const [mergedChunk, chunkChanged] = ScoreCompletionChunk.merged(a[existingIndex], chunk);
705
+ if (chunkChanged) {
706
+ if (merged === undefined) {
707
+ merged = [...a];
708
+ }
709
+ merged[existingIndex] = mergedChunk;
710
+ }
711
+ }
712
+ else if (chunk.type === "multichat") {
713
+ const [mergedChunk, chunkChanged] = MultichatCompletionChunk.merged(a[existingIndex], chunk);
714
+ if (chunkChanged) {
715
+ if (merged === undefined) {
716
+ merged = [...a];
717
+ }
718
+ merged[existingIndex] = mergedChunk;
719
+ }
720
+ }
721
+ }
722
+ return merged ? [merged, true] : [a, false];
723
+ }
724
+ CompletionChunk.mergedList = mergedList;
725
+ })(CompletionChunk = Streaming.CompletionChunk || (Streaming.CompletionChunk = {}));
726
+ function merged(a, b) {
727
+ const [completions, completionsChanged] = CompletionChunk.mergedList(a.completions, b.completions);
728
+ const [output, outputChanged] = merge(a.output, b.output);
729
+ const [retry_token, retry_tokenChanged] = merge(a.retry_token, b.retry_token);
730
+ const [error, errorChanged] = merge(a.error, b.error);
731
+ const [app_published, app_publishedChanged] = merge(a.app_published, b.app_published);
732
+ if (completionsChanged ||
733
+ outputChanged ||
734
+ retry_tokenChanged ||
735
+ errorChanged ||
736
+ app_publishedChanged) {
737
+ return [
738
+ Object.assign(Object.assign(Object.assign(Object.assign({ completions }, (output !== undefined ? { output } : {})), (retry_token !== undefined ? { retry_token } : {})), (error !== undefined ? { error } : {})), (app_published !== undefined ? { app_published } : {})),
739
+ true,
740
+ ];
741
+ }
742
+ else {
743
+ return [a, false];
744
+ }
745
+ }
746
+ Streaming.merged = merged;
747
+ })(Streaming = Response.Streaming || (Response.Streaming = {}));
748
+ })(Response = Apps.Response || (Apps.Response = {}));
749
+ async function list(openai, listOptions, options) {
750
+ const response = await openai.get("/apps", Object.assign({ query: listOptions }, options));
751
+ return response;
752
+ }
753
+ Apps.list = list;
754
+ async function count(openai, options) {
755
+ const response = await openai.get("/apps/count", options);
756
+ return response;
757
+ }
758
+ Apps.count = count;
759
+ async function retrieve(openai, author, id, version, retrieveOptions, options) {
760
+ const url = version !== null && version !== undefined
761
+ ? `/apps/${author}/${id}/${version}`
762
+ : `/apps/${author}/${id}`;
763
+ const response = await openai.get(url, Object.assign({ query: retrieveOptions }, options));
764
+ return response;
765
+ }
766
+ Apps.retrieve = retrieve;
767
+ async function executeById(openai, author, id, version, body, options) {
768
+ var _a;
769
+ const url = version !== null && version !== undefined
770
+ ? `/apps/${author}/${id}/${version}`
771
+ : `/apps/${author}/${id}`;
772
+ const response = await openai.post(url, Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
773
+ return response;
774
+ }
775
+ Apps.executeById = executeById;
776
+ async function executeByDefinition(openai, body, options) {
777
+ var _a;
778
+ const response = await openai.post("/apps", Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
779
+ return response;
780
+ }
781
+ Apps.executeByDefinition = executeByDefinition;
782
+ })(Apps || (Apps = {}));
663
783
  export var Models;
664
784
  (function (Models) {
665
785
  async function list(openai, listOptions, options) {
@@ -727,6 +847,19 @@ export var Auth;
727
847
  }
728
848
  Credits.retrieve = retrieve;
729
849
  })(Credits = Auth.Credits || (Auth.Credits = {}));
850
+ let Username;
851
+ (function (Username) {
852
+ async function retrieve(openai, options) {
853
+ const response = await openai.get("/auth/username", options);
854
+ return response;
855
+ }
856
+ Username.retrieve = retrieve;
857
+ async function set(openai, username, options) {
858
+ const response = await openai.post("/auth/username", Object.assign({ body: { username } }, options));
859
+ return response;
860
+ }
861
+ Username.set = set;
862
+ })(Username = Auth.Username || (Auth.Username = {}));
730
863
  })(Auth || (Auth = {}));
731
864
  export var Metadata;
732
865
  (function (Metadata) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "objectiveai",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "SDK for the ObjectiveAI API.",
5
5
  "main": "dist/index.js",
6
6
  "repository": {