Skip to content

Commit

Permalink
SDK regeneration (#21)
Browse files Browse the repository at this point in the history
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
  • Loading branch information
fern-api[bot] authored Nov 4, 2024
1 parent 8f595f0 commit 2a2b73b
Show file tree
Hide file tree
Showing 57 changed files with 1,145 additions and 266 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@credal/sdk",
"version": "0.0.13",
"version": "0.0.14",
"private": false,
"repository": "https://github.com/credal-ai/credal-typescript-sdk",
"main": "./index.js",
Expand Down
71 changes: 71 additions & 0 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,16 @@ await credal.copilots.sendMessage({
agentId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
message: "Is Credal SOC 2 compliant?",
userEmail: "[email protected]",
inputVariables: [
{
name: "input1",
urls: ["https://drive.google.com/file/d/123456/view"],
},
{
name: "input2",
urls: ["https://drive.google.com/file/d/123457/view", "https://drive.google.com/file/d/123458/view"],
},
],
});
```

Expand Down Expand Up @@ -316,6 +326,67 @@ await credal.copilots.sendMessage({
</dl>
</details>

<details><summary> <code>credal.copilots.<a href="./src/api/resources/copilots/client/Client.ts">streamMessage</a>({ ...params }) -> core.Stream<Credal.StreamingChunk></code> </summary>

<dl>

<dd>

#### 📝 Description

<dl>

<dd>

<dl>

<dd>

This endpoint allows you to send a message to a specific copilot and get the response back as a streamed set of Server-Sent Events.

</dd>

</dl>

</dd>

</dl>

#### ⚙️ Parameters

<dl>

<dd>

<dl>

<dd>

**request: `Credal.StreamMessageRequest`**

</dd>

</dl>

<dl>

<dd>

**requestOptions: `Copilots.RequestOptions`**

</dd>

</dl>

</dd>

</dl>

</dd>

</dl>
</details>

<details><summary> <code>credal.copilots.<a href="./src/api/resources/copilots/client/Client.ts">addCollectionToCopilot</a>({ ...params }) -> void</code> </summary>

<dl>
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/api/resources/common/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from "./Url";
export * from "./ResourceType";
export * from "./Collaborator";
export * from "./Role";
export * from "./Operator";
95 changes: 86 additions & 9 deletions src/api/resources/copilots/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as Credal from "../../../index";
import * as serializers from "../../../../serialization/index";
import urlJoin from "url-join";
import * as errors from "../../../../errors/index";
import * as stream from "stream";

export declare namespace Copilots {
interface Options {
Expand Down Expand Up @@ -56,7 +57,7 @@ export class Copilots {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@credal/sdk",
"X-Fern-SDK-Version": "0.0.13",
"X-Fern-SDK-Version": "0.0.14",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -123,7 +124,7 @@ export class Copilots {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@credal/sdk",
"X-Fern-SDK-Version": "0.0.13",
"X-Fern-SDK-Version": "0.0.14",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -193,7 +194,7 @@ export class Copilots {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@credal/sdk",
"X-Fern-SDK-Version": "0.0.13",
"X-Fern-SDK-Version": "0.0.14",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -239,7 +240,14 @@ export class Copilots {
* await credal.copilots.sendMessage({
* agentId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
* message: "Is Credal SOC 2 compliant?",
* userEmail: "[email protected]"
* userEmail: "[email protected]",
* inputVariables: [{
* name: "input1",
* urls: ["https://drive.google.com/file/d/123456/view"]
* }, {
* name: "input2",
* urls: ["https://drive.google.com/file/d/123457/view", "https://drive.google.com/file/d/123458/view"]
* }]
* })
*/
public async sendMessage(
Expand All @@ -256,7 +264,7 @@ export class Copilots {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@credal/sdk",
"X-Fern-SDK-Version": "0.0.13",
"X-Fern-SDK-Version": "0.0.14",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -297,6 +305,75 @@ export class Copilots {
}
}

/**
* This endpoint allows you to send a message to a specific copilot and get the response back as a streamed set of Server-Sent Events.
*/
public async streamMessage(
request: Credal.StreamMessageRequest,
requestOptions?: Copilots.RequestOptions
): Promise<core.Stream<Credal.StreamingChunk>> {
const _response = await (this._options.fetcher ?? core.fetcher)<stream.Readable>({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.CredalEnvironment.Production,
"/v0/copilots/streamMessage"
),
method: "POST",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@credal/sdk",
"X-Fern-SDK-Version": "0.0.14",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
body: await serializers.StreamMessageRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
responseType: "streaming",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
return new core.Stream({
stream: _response.body,
parse: async (data) => {
return await serializers.StreamingChunk.parseOrThrow(data, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
breadcrumbsPrefix: ["response"],
});
},
signal: requestOptions?.abortSignal,
eventShape: {
type: "sse",
streamTerminator: "[DONE]",
},
});
}

if (_response.error.reason === "status-code") {
throw new errors.CredalError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
}

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

/**
* Link a collection with a copilot. The API Key used must be added to both the collection and the copilot beforehand.
*
Expand All @@ -323,7 +400,7 @@ export class Copilots {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@credal/sdk",
"X-Fern-SDK-Version": "0.0.13",
"X-Fern-SDK-Version": "0.0.14",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -387,7 +464,7 @@ export class Copilots {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@credal/sdk",
"X-Fern-SDK-Version": "0.0.13",
"X-Fern-SDK-Version": "0.0.14",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -459,7 +536,7 @@ export class Copilots {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@credal/sdk",
"X-Fern-SDK-Version": "0.0.13",
"X-Fern-SDK-Version": "0.0.14",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -520,7 +597,7 @@ export class Copilots {
Authorization: await this._getAuthorizationHeader(),
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@credal/sdk",
"X-Fern-SDK-Version": "0.0.13",
"X-Fern-SDK-Version": "0.0.14",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down
16 changes: 15 additions & 1 deletion src/api/resources/copilots/client/requests/SendMessageRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@
* This file was auto-generated by Fern from our API Definition.
*/

import * as Credal from "../../../../index";

/**
* @example
* {
* agentId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
* message: "Is Credal SOC 2 compliant?",
* userEmail: "[email protected]"
* userEmail: "[email protected]",
* inputVariables: [{
* name: "input1",
* urls: ["https://drive.google.com/file/d/123456/view"]
* }, {
* name: "input2",
* urls: ["https://drive.google.com/file/d/123457/view", "https://drive.google.com/file/d/123458/view"]
* }]
* }
*/
export interface SendMessageRequest {
Expand All @@ -31,4 +40,9 @@ export interface SendMessageRequest {
*
*/
conversationId?: string;
/**
* Optional input variables to be used in the message. Map the name of the variable to a list of urls.
*
*/
inputVariables?: Credal.InputVariable[];
}
62 changes: 62 additions & 0 deletions src/api/resources/copilots/client/requests/StreamMessageRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as Credal from "../../../../index";

/**
* @example
* {
* copilotId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
* message: "Is Credal SOC 2 compliant?",
* email: "[email protected]",
* inputVariables: [{
* name: "input1",
* urls: ["https://drive.google.com/file/d/123456/view"]
* }, {
* name: "input2",
* urls: ["https://drive.google.com/file/d/123457/view", "https://drive.google.com/file/d/123458/view"]
* }]
* }
*
* @example
* {
* copilotId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
* message: "Is this user eligible for benefits based on their date of birth?",
* email: "[email protected]",
* inputVariables: [{
* name: "input1",
* urls: ["https://drive.google.com/file/d/123456/view"]
* }, {
* name: "input2",
* urls: ["https://drive.google.com/file/d/123457/view", "https://drive.google.com/file/d/123458/view"]
* }]
* }
*/
export interface StreamMessageRequest {
/**
* Credal-generated Copilot ID to specify which agent to route the request to.
*
*/
copilotId: string;
/**
* The message you want to send to your copilot.
*
*/
message: string;
/**
* The user profile you want to use when sending the message.
*
*/
email: string;
/**
* Credal-generated conversation ID for sending follow up messages. Conversation ID is returned after initial message. Optional, to be left off for first messages on new conversations.
*
*/
conversationId?: string;
/**
* Optional input variables to be used in the message. Map the name of the variable to a list of urls.
*
*/
inputVariables?: Credal.InputVariable[];
}
1 change: 1 addition & 0 deletions src/api/resources/copilots/client/requests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export { type CreateCopilotRequest } from "./CreateCopilotRequest";
export { type CreateConversationRequest } from "./CreateConversationRequest";
export { type ProvideMessageFeedbackRequest } from "./ProvideMessageFeedbackRequest";
export { type SendMessageRequest } from "./SendMessageRequest";
export { type StreamMessageRequest } from "./StreamMessageRequest";
export { type AddCollectionToCopilotRequest } from "./AddCollectionToCopilotRequest";
export { type RemoveCollectionFromCopilotRequest } from "./RemoveCollectionFromCopilotRequest";
export { type UpdateConfigurationRequest } from "./UpdateConfigurationRequest";
Expand Down
12 changes: 12 additions & 0 deletions src/api/resources/copilots/types/BlockedChunk.ts
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 Credal from "../../../index";

export interface BlockedChunk {
conversationId: string;
warnings: string[];
blocks: string[];
policyTriggers: Credal.PolicyTrigger[];
}
9 changes: 9 additions & 0 deletions src/api/resources/copilots/types/BooleanFieldSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

export interface BooleanFieldSchema {
field: string;
operator: "==";
value: boolean;
}
Loading

0 comments on commit 2a2b73b

Please sign in to comment.