Skip to content

Commit

Permalink
Release v0.1.63
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Jan 23, 2024
1 parent 781d57b commit 81b60b7
Show file tree
Hide file tree
Showing 30 changed files with 310 additions and 195 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superagentai-js",
"version": "v0.1.62",
"version": "v0.1.63",
"private": false,
"repository": "https://github.com/homanp/superagent-js",
"main": "./index.js",
Expand Down
7 changes: 0 additions & 7 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { Datasource } from "./api/resources/datasource/client/Client";
import { Tool } from "./api/resources/tool/client/Client";
import { Workflow } from "./api/resources/workflow/client/Client";
import { VectorDatabase } from "./api/resources/vectorDatabase/client/Client";
import { Telemetry } from "./api/resources/telemetry/client/Client";

export declare namespace SuperAgentClient {
interface Options {
Expand Down Expand Up @@ -69,10 +68,4 @@ export class SuperAgentClient {
public get vectorDatabase(): VectorDatabase {
return (this._vectorDatabase ??= new VectorDatabase(this._options));
}

protected _telemetry: Telemetry | undefined;

public get telemetry(): Telemetry {
return (this._telemetry ??= new Telemetry(this._options));
}
}
122 changes: 103 additions & 19 deletions src/api/resources/agent/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as SuperAgent from "../../..";
import urlJoin from "url-join";
import * as serializers from "../../../../serialization";
import * as errors from "../../../../errors";
import * as stream from "stream";

export declare namespace Agent {
interface Options {
Expand Down Expand Up @@ -55,7 +56,7 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
queryParameters: _queryParams,
Expand Down Expand Up @@ -130,7 +131,7 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
body: await serializers.AppModelsRequestAgent.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
Expand Down Expand Up @@ -201,7 +202,7 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -268,7 +269,7 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -338,7 +339,7 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
body: await serializers.AppModelsRequestAgent.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
Expand Down Expand Up @@ -388,14 +389,94 @@ export class Agent {
}
}

/**
* Invoke an agent
*/
public async invokeApiV1AgentsAgentIdInvokePostStream(
agentId: string,
request: SuperAgent.InvokeApiV1AgentsAgentIdInvokePostStreamRequest,
requestOptions?: Agent.RequestOptions
): Promise<core.Stream<SuperAgent.AppModelsResponseAgentInvokeStream>> {
const _response = await core.fetcher<stream.Readable>({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.SuperAgentEnvironment.Default,
`api/v1/agents/${agentId}/invoke`
),
method: "POST",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
body: {
...(await serializers.InvokeApiV1AgentsAgentIdInvokePostStreamRequest.jsonOrThrow(request, {
unrecognizedObjectKeys: "strip",
})),
enableStreaming: true,
},
responseType: "streaming",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
});
if (_response.ok) {
return new core.Stream({
stream: _response.body,
terminator: "\n",
parse: async (data) => {
return await serializers.AppModelsResponseAgentInvokeStream.parseOrThrow(data, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
});
},
});
}

if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 422:
throw new SuperAgent.UnprocessableEntityError(
await serializers.HttpValidationError.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
})
);
default:
throw new errors.SuperAgentError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
}
}

switch (_response.error.reason) {
case "non-json":
throw new errors.SuperAgentError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
});
case "timeout":
throw new errors.SuperAgentTimeoutError();
case "unknown":
throw new errors.SuperAgentError({
message: _response.error.errorMessage,
});
}
}

/**
* Invoke an agent
* @throws {@link SuperAgent.UnprocessableEntityError}
*
* @example
* await superAgent.agent.invoke("string", {
* input: "string",
* enableStreaming: true,
* enableStreaming: false,
* llmParams: {
* maxTokens: 1,
* temperature: 1.1
Expand All @@ -404,7 +485,7 @@ export class Agent {
*/
public async invoke(
agentId: string,
request: SuperAgent.AppModelsRequestAgentInvoke,
request: SuperAgent.InvokeApiV1AgentsAgentIdInvokePostRequest,
requestOptions?: Agent.RequestOptions
): Promise<SuperAgent.AppModelsResponseAgentInvoke> {
const _response = await core.fetcher({
Expand All @@ -417,12 +498,15 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
body: await serializers.AppModelsRequestAgentInvoke.jsonOrThrow(request, {
unrecognizedObjectKeys: "strip",
}),
body: {
...(await serializers.InvokeApiV1AgentsAgentIdInvokePostRequest.jsonOrThrow(request, {
unrecognizedObjectKeys: "strip",
})),
enableStreaming: false,
},
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
});
Expand Down Expand Up @@ -493,7 +577,7 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
body: await serializers.AppModelsRequestAgentLlm.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
Expand Down Expand Up @@ -561,7 +645,7 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -623,7 +707,7 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -696,7 +780,7 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
body: await serializers.AppModelsRequestAgentTool.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
Expand Down Expand Up @@ -764,7 +848,7 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -829,7 +913,7 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -902,7 +986,7 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
body: await serializers.AppModelsRequestAgentDatasource.jsonOrThrow(request, {
Expand Down Expand Up @@ -976,7 +1060,7 @@ export class Agent {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ import * as SuperAgent from "../../../..";
* @example
* {
* input: "string",
* enableStreaming: true,
* enableStreaming: false,
* llmParams: {
* maxTokens: 1,
* temperature: 1.1
* }
* }
*/
export interface AppModelsRequestAgentInvoke {
export interface InvokeApiV1AgentsAgentIdInvokePostRequest {
input: string;
sessionId?: string;
enableStreaming: boolean;
outputSchema?: string;
llmParams?: SuperAgent.LlmParams;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as SuperAgent from "../../../..";

export interface InvokeApiV1AgentsAgentIdInvokePostStreamRequest {
input: string;
sessionId?: string;
outputSchema?: string;
llmParams?: SuperAgent.LlmParams;
}
3 changes: 2 additions & 1 deletion src/api/resources/agent/client/requests/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { ListApiV1AgentsGetRequest } from "./ListApiV1AgentsGetRequest";
export { AppModelsRequestAgentInvoke } from "./AppModelsRequestAgentInvoke";
export { InvokeApiV1AgentsAgentIdInvokePostStreamRequest } from "./InvokeApiV1AgentsAgentIdInvokePostStreamRequest";
export { InvokeApiV1AgentsAgentIdInvokePostRequest } from "./InvokeApiV1AgentsAgentIdInvokePostRequest";
export { AppModelsRequestAgentLlm } from "./AppModelsRequestAgentLlm";
export { AppModelsRequestAgentTool } from "./AppModelsRequestAgentTool";
export { AppModelsRequestAgentDatasource } from "./AppModelsRequestAgentDatasource";
6 changes: 3 additions & 3 deletions src/api/resources/apiUser/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class ApiUser {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
body: await serializers.AppModelsRequestApiUser.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
Expand Down Expand Up @@ -114,7 +114,7 @@ export class ApiUser {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -168,7 +168,7 @@ export class ApiUser {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down
10 changes: 5 additions & 5 deletions src/api/resources/datasource/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class Datasource {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
queryParameters: _queryParams,
Expand Down Expand Up @@ -130,7 +130,7 @@ export class Datasource {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
body: await serializers.AppModelsRequestDatasource.jsonOrThrow(request, {
Expand Down Expand Up @@ -203,7 +203,7 @@ export class Datasource {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -270,7 +270,7 @@ export class Datasource {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -340,7 +340,7 @@ export class Datasource {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "superagentai-js",
"X-Fern-SDK-Version": "v0.1.62",
"X-Fern-SDK-Version": "v0.1.63",
},
contentType: "application/json",
body: await serializers.AppModelsRequestDatasource.jsonOrThrow(request, {
Expand Down
Loading

0 comments on commit 81b60b7

Please sign in to comment.