objectiveai 1.1.7 → 1.1.9
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 +134 -1
- package/dist/index.d.ts +293 -0
- package/dist/index.js +133 -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.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,291 @@ 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
|
+
required?: boolean | null;
|
|
753
|
+
items: Array.ItemsProperty | Record<string, Array.ItemsProperty>;
|
|
754
|
+
}
|
|
755
|
+
namespace Array {
|
|
756
|
+
type ItemsProperty = InputProperty.String | InputProperty.Number | InputProperty.Integer | InputProperty.Boolean;
|
|
757
|
+
}
|
|
758
|
+
interface String {
|
|
759
|
+
type: "string";
|
|
760
|
+
description?: string | null;
|
|
761
|
+
required?: boolean | null;
|
|
762
|
+
enum?: string[] | null;
|
|
763
|
+
}
|
|
764
|
+
interface Number {
|
|
765
|
+
type: "number";
|
|
766
|
+
description?: string | null;
|
|
767
|
+
required?: boolean | null;
|
|
768
|
+
}
|
|
769
|
+
interface Integer {
|
|
770
|
+
type: "integer";
|
|
771
|
+
description?: string | null;
|
|
772
|
+
required?: boolean | null;
|
|
773
|
+
}
|
|
774
|
+
interface Boolean {
|
|
775
|
+
type: "boolean";
|
|
776
|
+
description?: string | null;
|
|
777
|
+
required?: boolean | null;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
type OutputProperty = OutputProperty.Object | InputProperty.Array | InputProperty.String | InputProperty.Number | InputProperty.Integer | InputProperty.Boolean;
|
|
781
|
+
namespace OutputProperty {
|
|
782
|
+
interface Object {
|
|
783
|
+
type: "object";
|
|
784
|
+
required?: boolean | null;
|
|
785
|
+
properties: Record<string, OutputProperty>;
|
|
786
|
+
}
|
|
787
|
+
interface Array {
|
|
788
|
+
type: "array";
|
|
789
|
+
required?: boolean | null;
|
|
790
|
+
items: OutputProperty;
|
|
791
|
+
}
|
|
792
|
+
interface String {
|
|
793
|
+
type: "string";
|
|
794
|
+
required?: boolean | null;
|
|
795
|
+
}
|
|
796
|
+
interface Number {
|
|
797
|
+
type: "number";
|
|
798
|
+
required?: boolean | null;
|
|
799
|
+
}
|
|
800
|
+
interface Integer {
|
|
801
|
+
type: "integer";
|
|
802
|
+
required?: boolean | null;
|
|
803
|
+
}
|
|
804
|
+
interface Boolean {
|
|
805
|
+
type: "boolean";
|
|
806
|
+
required?: boolean | null;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
type Step = Step.Score | Step.Multichat;
|
|
810
|
+
namespace Step {
|
|
811
|
+
type Message = Message.Developer | Message.System | Message.User | Message.Assistant | Message.Tool | Message.ChatCompletion | Message.ScoreCompletion | Message.MultichatCompletion;
|
|
812
|
+
namespace Message {
|
|
813
|
+
interface Developer {
|
|
814
|
+
role: Chat.Completions.Request.Message.Developer["role"];
|
|
815
|
+
content: WithExpression<SimpleContent>;
|
|
816
|
+
name?: WithExpression<Chat.Completions.Request.Message.Developer["name"]>;
|
|
817
|
+
}
|
|
818
|
+
interface System {
|
|
819
|
+
role: Chat.Completions.Request.Message.System["role"];
|
|
820
|
+
content: WithExpression<SimpleContent>;
|
|
821
|
+
name?: WithExpression<Chat.Completions.Request.Message.System["name"]>;
|
|
822
|
+
}
|
|
823
|
+
interface User {
|
|
824
|
+
role: Chat.Completions.Request.Message.User["role"];
|
|
825
|
+
content: WithExpression<RichContent>;
|
|
826
|
+
name?: WithExpression<Chat.Completions.Request.Message.User["name"]>;
|
|
827
|
+
}
|
|
828
|
+
interface Assistant {
|
|
829
|
+
role: Chat.Completions.Request.Message.Assistant["role"];
|
|
830
|
+
content?: WithExpression<RichContent> | null;
|
|
831
|
+
name?: WithExpression<Chat.Completions.Request.Message.Assistant["name"]>;
|
|
832
|
+
refusal?: WithExpression<Chat.Completions.Request.Message.Assistant["refusal"]>;
|
|
833
|
+
tool_calls?: WithExpression<WithExpression<Assistant.ToolCall>[]> | null;
|
|
834
|
+
}
|
|
835
|
+
namespace Assistant {
|
|
836
|
+
type ToolCall = ToolCall.Function;
|
|
837
|
+
namespace ToolCall {
|
|
838
|
+
interface Function {
|
|
839
|
+
id: WithExpression<Chat.Completions.Request.Message.Assistant.ToolCall.Function["id"]>;
|
|
840
|
+
function: WithExpression<Function.Definition>;
|
|
841
|
+
type: Chat.Completions.Request.Message.Assistant.ToolCall.Function["type"];
|
|
842
|
+
}
|
|
843
|
+
namespace Function {
|
|
844
|
+
interface Definition {
|
|
845
|
+
name: WithExpression<Chat.Completions.Request.Message.Assistant.ToolCall.Function.Definition["name"]>;
|
|
846
|
+
arguments: WithExpression<Chat.Completions.Request.Message.Assistant.ToolCall.Function.Definition["arguments"]>;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
interface Tool {
|
|
852
|
+
role: Chat.Completions.Request.Message.Tool["role"];
|
|
853
|
+
content: WithExpression<RichContent>;
|
|
854
|
+
tool_call_id: WithExpression<Chat.Completions.Request.Message.Tool["tool_call_id"]>;
|
|
855
|
+
}
|
|
856
|
+
interface ChatCompletion {
|
|
857
|
+
role: Chat.Completions.Request.Message.ChatCompletion["role"];
|
|
858
|
+
id: WithExpression<Chat.Completions.Request.Message.ChatCompletion["id"]>;
|
|
859
|
+
choice_index: WithExpression<Chat.Completions.Request.Message.ChatCompletion["choice_index"]>;
|
|
860
|
+
name?: WithExpression<Chat.Completions.Request.Message.ChatCompletion["name"]>;
|
|
861
|
+
}
|
|
862
|
+
interface ScoreCompletion {
|
|
863
|
+
role: Chat.Completions.Request.Message.ScoreCompletion["role"];
|
|
864
|
+
id: WithExpression<Chat.Completions.Request.Message.ScoreCompletion["id"]>;
|
|
865
|
+
choice_index: WithExpression<Chat.Completions.Request.Message.ScoreCompletion["choice_index"]>;
|
|
866
|
+
name?: WithExpression<Chat.Completions.Request.Message.ScoreCompletion["name"]>;
|
|
867
|
+
}
|
|
868
|
+
interface MultichatCompletion {
|
|
869
|
+
role: Chat.Completions.Request.Message.MultichatCompletion["role"];
|
|
870
|
+
id: WithExpression<Chat.Completions.Request.Message.MultichatCompletion["id"]>;
|
|
871
|
+
choice_index: WithExpression<Chat.Completions.Request.Message.MultichatCompletion["choice_index"]>;
|
|
872
|
+
name?: WithExpression<Chat.Completions.Request.Message.MultichatCompletion["name"]>;
|
|
873
|
+
}
|
|
874
|
+
type SimpleContent = string | WithExpression<Chat.Completions.Request.Message.SimpleContentPart>[];
|
|
875
|
+
type RichContent = string | WithExpression<Chat.Completions.Request.Message.RichContentPart>[];
|
|
876
|
+
}
|
|
877
|
+
type ResponseFormat = ResponseFormat.Text | ResponseFormat.JsonObject | ResponseFormat.JsonSchema;
|
|
878
|
+
namespace ResponseFormat {
|
|
879
|
+
interface Text {
|
|
880
|
+
type: "text";
|
|
881
|
+
}
|
|
882
|
+
interface JsonObject {
|
|
883
|
+
type: "json_object";
|
|
884
|
+
}
|
|
885
|
+
interface JsonSchema {
|
|
886
|
+
type: "json_schema";
|
|
887
|
+
json_schema: WithExpression<JsonSchema.JsonSchema>;
|
|
888
|
+
}
|
|
889
|
+
namespace JsonSchema {
|
|
890
|
+
interface JsonSchema {
|
|
891
|
+
name: WithExpression<Chat.Completions.Request.ResponseFormat.JsonSchema.JsonSchema["name"]>;
|
|
892
|
+
description?: WithExpression<Chat.Completions.Request.ResponseFormat.JsonSchema.JsonSchema["description"]>;
|
|
893
|
+
schema?: WithExpression<Chat.Completions.Request.ResponseFormat.JsonSchema.JsonSchema["schema"]>;
|
|
894
|
+
strict?: WithExpression<Chat.Completions.Request.ResponseFormat.JsonSchema.JsonSchema["strict"]>;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
interface Multichat {
|
|
899
|
+
type: "multichat";
|
|
900
|
+
messages: WithExpression<WithExpression<Message>[]>;
|
|
901
|
+
model: WithExpression<Multichat.Completions.Request.ChatCompletionCreateParams["model"]>;
|
|
902
|
+
response_format?: WithExpression<ResponseFormat> | null;
|
|
903
|
+
}
|
|
904
|
+
interface Score {
|
|
905
|
+
type: "score";
|
|
906
|
+
messages: WithExpression<WithExpression<Message>[]>;
|
|
907
|
+
model: WithExpression<Score.Completions.Request.ChatCompletionCreateParams["model"]>;
|
|
908
|
+
choices: WithExpression<WithExpression<Score.Completions.Request.Choice>[]>;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
namespace Request {
|
|
912
|
+
interface ExecuteByIdRequestBase {
|
|
913
|
+
arguments?: JsonValue;
|
|
914
|
+
retry_token?: string;
|
|
915
|
+
seed?: Chat.Completions.Request.ChatCompletionCreateParamsBase["seed"];
|
|
916
|
+
service_tier?: Chat.Completions.Request.ChatCompletionCreateParamsBase["service_tier"];
|
|
917
|
+
stream_options?: Chat.Completions.Request.ChatCompletionCreateParamsBase["stream_options"];
|
|
918
|
+
usage?: Chat.Completions.Request.ChatCompletionCreateParamsBase["usage"];
|
|
919
|
+
}
|
|
920
|
+
interface ExecuteByIdRequestStreaming extends ExecuteByIdRequestBase {
|
|
921
|
+
stream: true;
|
|
922
|
+
}
|
|
923
|
+
interface ExecuteByIdRequestNonStreaming extends ExecuteByIdRequestBase {
|
|
924
|
+
stream?: false | null;
|
|
925
|
+
}
|
|
926
|
+
type ExecuteByIdRequest = ExecuteByIdRequestStreaming | ExecuteByIdRequestNonStreaming;
|
|
927
|
+
interface ExecuteByDefinitionRequestBase extends ExecuteByIdRequestBase {
|
|
928
|
+
steps: WithExpression<WithExpression<Step>[]>;
|
|
929
|
+
output: Expression | Record<string, Expression>;
|
|
930
|
+
publish?: {
|
|
931
|
+
id: string;
|
|
932
|
+
description: string;
|
|
933
|
+
input: Record<string, InputProperty>;
|
|
934
|
+
output: OutputProperty;
|
|
935
|
+
} | null;
|
|
936
|
+
}
|
|
937
|
+
interface ExecuteByDefinitionRequestStreaming extends ExecuteByDefinitionRequestBase {
|
|
938
|
+
stream: true;
|
|
939
|
+
}
|
|
940
|
+
interface ExecuteByDefinitionRequestNonStreaming extends ExecuteByDefinitionRequestBase {
|
|
941
|
+
stream?: false | null;
|
|
942
|
+
}
|
|
943
|
+
type ExecuteByDefinitionRequest = ExecuteByDefinitionRequestStreaming | ExecuteByDefinitionRequestNonStreaming;
|
|
944
|
+
}
|
|
945
|
+
namespace Response {
|
|
946
|
+
namespace Streaming {
|
|
947
|
+
interface ExecuteResponseChunk {
|
|
948
|
+
completions: CompletionChunk[];
|
|
949
|
+
output?: JsonValue;
|
|
950
|
+
retry_token?: string;
|
|
951
|
+
error?: ObjectiveAIError;
|
|
952
|
+
app_published?: boolean;
|
|
953
|
+
}
|
|
954
|
+
type CompletionChunk = CompletionChunk.ScoreCompletionChunk | CompletionChunk.MultichatCompletionChunk;
|
|
955
|
+
namespace CompletionChunk {
|
|
956
|
+
interface ScoreCompletionChunk extends Score.Completions.Response.Streaming.ChatCompletionChunk {
|
|
957
|
+
type: "score";
|
|
958
|
+
index: number;
|
|
959
|
+
}
|
|
960
|
+
namespace ScoreCompletionChunk {
|
|
961
|
+
function merged(a: ScoreCompletionChunk, b: ScoreCompletionChunk): [ScoreCompletionChunk, boolean];
|
|
962
|
+
}
|
|
963
|
+
interface MultichatCompletionChunk extends Multichat.Completions.Response.Streaming.ChatCompletionChunk {
|
|
964
|
+
type: "multichat";
|
|
965
|
+
index: number;
|
|
966
|
+
}
|
|
967
|
+
namespace MultichatCompletionChunk {
|
|
968
|
+
function merged(a: MultichatCompletionChunk, b: MultichatCompletionChunk): [MultichatCompletionChunk, boolean];
|
|
969
|
+
}
|
|
970
|
+
function mergedList(a: CompletionChunk[], b: CompletionChunk[]): [CompletionChunk[], boolean];
|
|
971
|
+
}
|
|
972
|
+
function merged(a: ExecuteResponseChunk, b: ExecuteResponseChunk): [ExecuteResponseChunk, boolean];
|
|
973
|
+
}
|
|
974
|
+
namespace Unary {
|
|
975
|
+
interface ExecuteResponse {
|
|
976
|
+
completions: Completion[];
|
|
977
|
+
output: JsonValue;
|
|
978
|
+
retry_token: string | null;
|
|
979
|
+
error: ObjectiveAIError | null;
|
|
980
|
+
app_published?: boolean;
|
|
981
|
+
}
|
|
982
|
+
type Completion = Completion.Score | Completion.Multichat;
|
|
983
|
+
namespace Completion {
|
|
984
|
+
interface Score extends Score.Completions.Response.Unary.ChatCompletion {
|
|
985
|
+
type: "score";
|
|
986
|
+
index: number;
|
|
987
|
+
}
|
|
988
|
+
interface Multichat extends Multichat.Completions.Response.Unary.ChatCompletion {
|
|
989
|
+
type: "multichat";
|
|
990
|
+
index: number;
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
interface AppHeader {
|
|
996
|
+
author: string;
|
|
997
|
+
id: string;
|
|
998
|
+
version: number;
|
|
999
|
+
description: string;
|
|
1000
|
+
}
|
|
1001
|
+
interface App extends AppHeader {
|
|
1002
|
+
input_schema: Record<string, InputProperty>;
|
|
1003
|
+
output_schema: OutputProperty;
|
|
1004
|
+
steps: WithExpression<WithExpression<Step>[]>;
|
|
1005
|
+
output: Expression | Record<string, Expression>;
|
|
1006
|
+
}
|
|
1007
|
+
interface AppWithMetadata extends App {
|
|
1008
|
+
created: string;
|
|
1009
|
+
requests: number;
|
|
1010
|
+
completion_tokens: number;
|
|
1011
|
+
prompt_tokens: number;
|
|
1012
|
+
total_cost: number;
|
|
1013
|
+
}
|
|
1014
|
+
function list(openai: OpenAI, listOptions?: Models.ListOptions, options?: OpenAI.RequestOptions): Promise<{
|
|
1015
|
+
data: AppHeader[];
|
|
1016
|
+
}>;
|
|
1017
|
+
function count(openai: OpenAI, options?: OpenAI.RequestOptions): Promise<{
|
|
1018
|
+
data: number;
|
|
1019
|
+
}>;
|
|
1020
|
+
function retrieve(openai: OpenAI, author: string, id: string, version?: number | null, retrieveOptions?: Models.RetrieveOptionsWithoutMetadata, options?: OpenAI.RequestOptions): Promise<App>;
|
|
1021
|
+
function retrieve(openai: OpenAI, author: string, id: string, version?: number | null, retrieveOptions?: Models.RetrieveOptionsWithMetadata, options?: OpenAI.RequestOptions): Promise<AppWithMetadata>;
|
|
1022
|
+
function executeById(openai: OpenAI, author: string, id: string, version: number | null | undefined, body: Request.ExecuteByIdRequestStreaming, options?: OpenAI.RequestOptions): Promise<Stream<Response.Streaming.ExecuteResponseChunk>>;
|
|
1023
|
+
function executeById(openai: OpenAI, author: string, id: string, version: number | null | undefined, body: Request.ExecuteByIdRequestNonStreaming, options?: OpenAI.RequestOptions): Promise<Response.Unary.ExecuteResponse>;
|
|
1024
|
+
function executeByDefinition(openai: OpenAI, body: Request.ExecuteByDefinitionRequestStreaming, options?: OpenAI.RequestOptions): Promise<Stream<Response.Streaming.ExecuteResponseChunk>>;
|
|
1025
|
+
function executeByDefinition(openai: OpenAI, body: Request.ExecuteByDefinitionRequestNonStreaming, options?: OpenAI.RequestOptions): Promise<Response.Unary.ExecuteResponse>;
|
|
1026
|
+
}
|
|
742
1027
|
export declare namespace Models {
|
|
743
1028
|
interface Model {
|
|
744
1029
|
id: string;
|
|
@@ -857,6 +1142,14 @@ export declare namespace Auth {
|
|
|
857
1142
|
namespace Credits {
|
|
858
1143
|
function retrieve(openai: OpenAI, options?: OpenAI.RequestOptions): Promise<Credits>;
|
|
859
1144
|
}
|
|
1145
|
+
namespace Username {
|
|
1146
|
+
function retrieve(openai: OpenAI, options?: OpenAI.RequestOptions): Promise<{
|
|
1147
|
+
username: string | null;
|
|
1148
|
+
}>;
|
|
1149
|
+
function set(openai: OpenAI, username: string, options?: OpenAI.RequestOptions): Promise<{
|
|
1150
|
+
username: string;
|
|
1151
|
+
}>;
|
|
1152
|
+
}
|
|
860
1153
|
}
|
|
861
1154
|
export interface Metadata {
|
|
862
1155
|
score_requests: number;
|
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) {
|