-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
- Loading branch information
1 parent
8f595f0
commit 2a2b73b
Showing
57 changed files
with
1,145 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"], | ||
}, | ||
], | ||
}); | ||
``` | ||
|
||
|
@@ -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> | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -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, | ||
}, | ||
|
@@ -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, | ||
}, | ||
|
@@ -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, | ||
}, | ||
|
@@ -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( | ||
|
@@ -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, | ||
}, | ||
|
@@ -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. | ||
* | ||
|
@@ -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, | ||
}, | ||
|
@@ -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, | ||
}, | ||
|
@@ -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, | ||
}, | ||
|
@@ -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, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -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
62
src/api/resources/copilots/client/requests/StreamMessageRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.