Skip to content

Commit a77b2f5

Browse files
SDK regeneration (#24)
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
1 parent 4ad0eec commit a77b2f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1008
-270
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@credal/sdk",
3-
"version": "0.0.16",
3+
"version": "0.0.17",
44
"private": false,
55
"repository": "https://github.com/credal-ai/credal-typescript-sdk",
66
"main": "./index.js",

reference.md

Lines changed: 145 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,80 @@
11
# Reference
22

3+
## Actions
4+
5+
<details><summary><code>client.actions.<a href="/src/api/resources/actions/client/Client.ts">invokeAction</a>({ ...params }) -> Credal.InvokeActionResponse</code></summary>
6+
<dl>
7+
<dd>
8+
9+
#### 📝 Description
10+
11+
<dl>
12+
<dd>
13+
14+
<dl>
15+
<dd>
16+
17+
Invoke an action, asking for human confirmation if necessary
18+
19+
</dd>
20+
</dl>
21+
</dd>
22+
</dl>
23+
24+
#### 🔌 Usage
25+
26+
<dl>
27+
<dd>
28+
29+
<dl>
30+
<dd>
31+
32+
```typescript
33+
await client.actions.invokeAction({
34+
actionId: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
35+
userEmail: "string",
36+
requireHumanConfirmation: true,
37+
humanConfirmationChannel: {
38+
type: "directMessage",
39+
channelId: "string",
40+
},
41+
justification: "string",
42+
auditLogId: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
43+
});
44+
```
45+
46+
</dd>
47+
</dl>
48+
</dd>
49+
</dl>
50+
51+
#### ⚙️ Parameters
52+
53+
<dl>
54+
<dd>
55+
56+
<dl>
57+
<dd>
58+
59+
**request:** `Credal.InvokeActionRequest`
60+
61+
</dd>
62+
</dl>
63+
64+
<dl>
65+
<dd>
66+
67+
**requestOptions:** `Actions.RequestOptions`
68+
69+
</dd>
70+
</dl>
71+
</dd>
72+
</dl>
73+
74+
</dd>
75+
</dl>
76+
</details>
77+
378
## Copilots
479

580
<details><summary><code>client.copilots.<a href="/src/api/resources/copilots/client/Client.ts">createCopilot</a>({ ...params }) -> Credal.CreateCopilotResponse</code></summary>
@@ -216,11 +291,11 @@ await client.copilots.sendMessage({
216291
inputVariables: [
217292
{
218293
name: "input1",
219-
urls: ["https://drive.google.com/file/d/123456/view"],
294+
ids: ["82e4b12a-6990-45d4-8ebd-85c00e030c24"],
220295
},
221296
{
222297
name: "input2",
223-
urls: ["https://drive.google.com/file/d/123457/view", "https://drive.google.com/file/d/123458/view"],
298+
ids: ["82e4b12a-6990-45d4-8ebd-85c00e030c25", "82e4b12a-6990-45d4-8ebd-85c00e030c26"],
224299
},
225300
],
226301
});
@@ -293,11 +368,11 @@ const response = await client.copilots.streamMessage({
293368
inputVariables: [
294369
{
295370
name: "input1",
296-
urls: ["https://drive.google.com/file/d/123456/view"],
371+
ids: ["82e4b12a-6990-45d4-8ebd-85c00e030c24"],
297372
},
298373
{
299374
name: "input2",
300-
urls: ["https://drive.google.com/file/d/123457/view", "https://drive.google.com/file/d/123458/view"],
375+
ids: ["82e4b12a-6990-45d4-8ebd-85c00e030c25", "82e4b12a-6990-45d4-8ebd-85c00e030c26"],
301376
},
302377
],
303378
});
@@ -651,6 +726,72 @@ await client.documentCatalog.uploadDocumentContents({
651726
</dl>
652727
</details>
653728

729+
<details><summary><code>client.documentCatalog.<a href="/src/api/resources/documentCatalog/client/Client.ts">syncSourceByUrl</a>({ ...params }) -> Credal.SyncSourceByUrlResponse</code></summary>
730+
<dl>
731+
<dd>
732+
733+
#### 📝 Description
734+
735+
<dl>
736+
<dd>
737+
738+
<dl>
739+
<dd>
740+
741+
Sync a document from a source URL. Does not support recursive web search. Reach out to a Credal representative for access.
742+
743+
</dd>
744+
</dl>
745+
</dd>
746+
</dl>
747+
748+
#### 🔌 Usage
749+
750+
<dl>
751+
<dd>
752+
753+
<dl>
754+
<dd>
755+
756+
```typescript
757+
await client.documentCatalog.syncSourceByUrl({
758+
sourceUrl: "https://drive.google.com/file/d/123456/view",
759+
uploadAsUserEmail: "[email protected]",
760+
});
761+
```
762+
763+
</dd>
764+
</dl>
765+
</dd>
766+
</dl>
767+
768+
#### ⚙️ Parameters
769+
770+
<dl>
771+
<dd>
772+
773+
<dl>
774+
<dd>
775+
776+
**request:** `Credal.SyncSourceByUrlRequest`
777+
778+
</dd>
779+
</dl>
780+
781+
<dl>
782+
<dd>
783+
784+
**requestOptions:** `DocumentCatalog.RequestOptions`
785+
786+
</dd>
787+
</dl>
788+
</dd>
789+
</dl>
790+
791+
</dd>
792+
</dl>
793+
</details>
794+
654795
<details><summary><code>client.documentCatalog.<a href="/src/api/resources/documentCatalog/client/Client.ts">metadata</a>({ ...params }) -> void</code></summary>
655796
<dl>
656797
<dd>

src/Client.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import * as environments from "./environments";
66
import * as core from "./core";
7+
import { Actions } from "./api/resources/actions/client/Client";
78
import { Copilots } from "./api/resources/copilots/client/Client";
89
import { DocumentCatalog } from "./api/resources/documentCatalog/client/Client";
910
import { DocumentCollections } from "./api/resources/documentCollections/client/Client";
@@ -31,6 +32,12 @@ export declare namespace CredalClient {
3132
export class CredalClient {
3233
constructor(protected readonly _options: CredalClient.Options = {}) {}
3334

35+
protected _actions: Actions | undefined;
36+
37+
public get actions(): Actions {
38+
return (this._actions ??= new Actions(this._options));
39+
}
40+
3441
protected _copilots: Copilots | undefined;
3542

3643
public get copilots(): Copilots {
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
5+
import * as environments from "../../../../environments";
6+
import * as core from "../../../../core";
7+
import * as Credal from "../../../index";
8+
import * as serializers from "../../../../serialization/index";
9+
import urlJoin from "url-join";
10+
import * as errors from "../../../../errors/index";
11+
12+
export declare namespace Actions {
13+
interface Options {
14+
environment?: core.Supplier<environments.CredalEnvironment | string>;
15+
apiKey?: core.Supplier<core.BearerToken | undefined>;
16+
fetcher?: core.FetchFunction;
17+
}
18+
19+
interface RequestOptions {
20+
/** The maximum time to wait for a response in seconds. */
21+
timeoutInSeconds?: number;
22+
/** The number of times to retry the request. Defaults to 2. */
23+
maxRetries?: number;
24+
/** A hook to abort the request. */
25+
abortSignal?: AbortSignal;
26+
}
27+
}
28+
29+
export class Actions {
30+
constructor(protected readonly _options: Actions.Options = {}) {}
31+
32+
/**
33+
* Invoke an action, asking for human confirmation if necessary
34+
*
35+
* @param {Credal.InvokeActionRequest} request
36+
* @param {Actions.RequestOptions} requestOptions - Request-specific configuration.
37+
*
38+
* @example
39+
* await client.actions.invokeAction({
40+
* actionId: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
41+
* userEmail: "string",
42+
* requireHumanConfirmation: true,
43+
* humanConfirmationChannel: {
44+
* type: "directMessage",
45+
* channelId: "string"
46+
* },
47+
* justification: "string",
48+
* auditLogId: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
49+
* })
50+
*/
51+
public async invokeAction(
52+
request: Credal.InvokeActionRequest,
53+
requestOptions?: Actions.RequestOptions
54+
): Promise<Credal.InvokeActionResponse> {
55+
const _response = await (this._options.fetcher ?? core.fetcher)({
56+
url: urlJoin(
57+
(await core.Supplier.get(this._options.environment)) ?? environments.CredalEnvironment.Production,
58+
"/v0/actions/invokeAction"
59+
),
60+
method: "POST",
61+
headers: {
62+
Authorization: await this._getAuthorizationHeader(),
63+
"X-Fern-Language": "JavaScript",
64+
"X-Fern-SDK-Name": "@credal/sdk",
65+
"X-Fern-SDK-Version": "0.0.17",
66+
"User-Agent": "@credal/sdk/0.0.17",
67+
"X-Fern-Runtime": core.RUNTIME.type,
68+
"X-Fern-Runtime-Version": core.RUNTIME.version,
69+
},
70+
contentType: "application/json",
71+
requestType: "json",
72+
body: serializers.InvokeActionRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
73+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
74+
maxRetries: requestOptions?.maxRetries,
75+
abortSignal: requestOptions?.abortSignal,
76+
});
77+
if (_response.ok) {
78+
return serializers.InvokeActionResponse.parseOrThrow(_response.body, {
79+
unrecognizedObjectKeys: "passthrough",
80+
allowUnrecognizedUnionMembers: true,
81+
allowUnrecognizedEnumValues: true,
82+
breadcrumbsPrefix: ["response"],
83+
});
84+
}
85+
86+
if (_response.error.reason === "status-code") {
87+
throw new errors.CredalError({
88+
statusCode: _response.error.statusCode,
89+
body: _response.error.body,
90+
});
91+
}
92+
93+
switch (_response.error.reason) {
94+
case "non-json":
95+
throw new errors.CredalError({
96+
statusCode: _response.error.statusCode,
97+
body: _response.error.rawBody,
98+
});
99+
case "timeout":
100+
throw new errors.CredalTimeoutError();
101+
case "unknown":
102+
throw new errors.CredalError({
103+
message: _response.error.errorMessage,
104+
});
105+
}
106+
}
107+
108+
protected async _getAuthorizationHeader(): Promise<string> {
109+
const bearer = (await core.Supplier.get(this._options.apiKey)) ?? process?.env["CREDAL_API_KEY"];
110+
if (bearer == null) {
111+
throw new errors.CredalError({
112+
message: "Please specify CREDAL_API_KEY when instantiating the client.",
113+
});
114+
}
115+
116+
return `Bearer ${bearer}`;
117+
}
118+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./requests";
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
5+
import * as Credal from "../../../../index";
6+
7+
/**
8+
* @example
9+
* {
10+
* actionId: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
11+
* userEmail: "string",
12+
* requireHumanConfirmation: true,
13+
* humanConfirmationChannel: {
14+
* type: "directMessage",
15+
* channelId: "string"
16+
* },
17+
* justification: "string",
18+
* auditLogId: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
19+
* }
20+
*/
21+
export interface InvokeActionRequest {
22+
actionId: string;
23+
/**
24+
* The user who we should take the action on behalf of
25+
*
26+
*/
27+
userEmail: string;
28+
/**
29+
* If true, then before executing the action we will ask for a human confirmation in Slack. If false, we may still ask for human confirmation if it's required by your organization admin.
30+
*
31+
*/
32+
requireHumanConfirmation?: boolean;
33+
/**
34+
* Where we should ask for human confirmation if necessary
35+
*
36+
*/
37+
humanConfirmationChannel: Credal.HumanConfirmationChannel;
38+
/**
39+
* The justification for requesting this action. This is likely generated by the LLM that requested the action.
40+
*
41+
*/
42+
justification: string;
43+
/**
44+
* Audit log for the message that called for this action
45+
*
46+
*/
47+
auditLogId: string;
48+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { type InvokeActionRequest } from "./InvokeActionRequest";

src/api/resources/actions/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./types";
2+
export * from "./client";

0 commit comments

Comments
 (0)