@credal/sdk 0.0.3 → 0.0.5
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/README.md +168 -0
- package/api/resources/copilots/client/Client.d.ts +15 -0
- package/api/resources/copilots/client/Client.js +62 -2
- package/api/resources/copilots/client/requests/ProvideMessageFeedbackRequest.d.ts +32 -0
- package/api/resources/copilots/client/requests/ProvideMessageFeedbackRequest.js +5 -0
- package/api/resources/copilots/client/requests/index.d.ts +1 -0
- package/api/resources/copilots/types/FeedbackEnum.d.ts +8 -0
- package/api/resources/copilots/types/FeedbackEnum.js +10 -0
- package/api/resources/copilots/types/MessageFeedback.d.ts +8 -0
- package/api/resources/copilots/types/MessageFeedback.js +5 -0
- package/api/resources/copilots/types/MessageReply.d.ts +2 -0
- package/api/resources/copilots/types/ReferencedSource.d.ts +10 -0
- package/api/resources/copilots/types/ReferencedSource.js +5 -0
- package/api/resources/copilots/types/index.d.ts +3 -0
- package/api/resources/copilots/types/index.js +3 -0
- package/api/resources/documentCatalog/client/Client.js +2 -2
- package/api/resources/documentCollections/client/Client.js +1 -1
- package/api/resources/permissionsService/client/Client.js +3 -3
- package/api/resources/search/client/Client.js +1 -1
- package/api/resources/search/client/requests/SearchDocumentCollectionRequest.d.ts +1 -1
- package/api/resources/users/client/Client.js +1 -1
- package/dist/api/resources/copilots/client/Client.d.ts +15 -0
- package/dist/api/resources/copilots/client/Client.js +62 -2
- package/dist/api/resources/copilots/client/requests/ProvideMessageFeedbackRequest.d.ts +32 -0
- package/dist/api/resources/copilots/client/requests/ProvideMessageFeedbackRequest.js +5 -0
- package/dist/api/resources/copilots/client/requests/index.d.ts +1 -0
- package/dist/api/resources/copilots/types/FeedbackEnum.d.ts +8 -0
- package/dist/api/resources/copilots/types/FeedbackEnum.js +10 -0
- package/dist/api/resources/copilots/types/MessageFeedback.d.ts +8 -0
- package/dist/api/resources/copilots/types/MessageFeedback.js +5 -0
- package/dist/api/resources/copilots/types/MessageReply.d.ts +2 -0
- package/dist/api/resources/copilots/types/ReferencedSource.d.ts +10 -0
- package/dist/api/resources/copilots/types/ReferencedSource.js +5 -0
- package/dist/api/resources/copilots/types/index.d.ts +3 -0
- package/dist/api/resources/copilots/types/index.js +3 -0
- package/dist/api/resources/documentCatalog/client/Client.js +2 -2
- package/dist/api/resources/documentCollections/client/Client.js +1 -1
- package/dist/api/resources/permissionsService/client/Client.js +3 -3
- package/dist/api/resources/search/client/Client.js +1 -1
- package/dist/api/resources/search/client/requests/SearchDocumentCollectionRequest.d.ts +1 -1
- package/dist/api/resources/users/client/Client.js +1 -1
- package/dist/serialization/resources/copilots/client/requests/ProvideMessageFeedbackRequest.d.ts +15 -0
- package/dist/serialization/resources/copilots/client/requests/ProvideMessageFeedbackRequest.js +36 -0
- package/dist/serialization/resources/copilots/client/requests/index.d.ts +1 -0
- package/dist/serialization/resources/copilots/client/requests/index.js +3 -1
- package/dist/serialization/resources/copilots/types/FeedbackEnum.d.ts +10 -0
- package/dist/serialization/resources/copilots/types/FeedbackEnum.js +31 -0
- package/dist/serialization/resources/copilots/types/MessageFeedback.d.ts +14 -0
- package/dist/serialization/resources/copilots/types/MessageFeedback.js +35 -0
- package/dist/serialization/resources/copilots/types/MessageReply.d.ts +3 -0
- package/dist/serialization/resources/copilots/types/MessageReply.js +3 -0
- package/dist/serialization/resources/copilots/types/ReferencedSource.d.ts +16 -0
- package/dist/serialization/resources/copilots/types/ReferencedSource.js +37 -0
- package/dist/serialization/resources/copilots/types/index.d.ts +3 -0
- package/dist/serialization/resources/copilots/types/index.js +3 -0
- package/dist/serialization/resources/search/client/requests/SearchDocumentCollectionRequest.d.ts +1 -1
- package/dist/serialization/resources/search/client/requests/SearchDocumentCollectionRequest.js +1 -1
- package/package.json +1 -1
- package/reference.md +70 -0
- package/serialization/resources/copilots/client/requests/ProvideMessageFeedbackRequest.d.ts +15 -0
- package/serialization/resources/copilots/client/requests/ProvideMessageFeedbackRequest.js +36 -0
- package/serialization/resources/copilots/client/requests/index.d.ts +1 -0
- package/serialization/resources/copilots/client/requests/index.js +3 -1
- package/serialization/resources/copilots/types/FeedbackEnum.d.ts +10 -0
- package/serialization/resources/copilots/types/FeedbackEnum.js +31 -0
- package/serialization/resources/copilots/types/MessageFeedback.d.ts +14 -0
- package/serialization/resources/copilots/types/MessageFeedback.js +35 -0
- package/serialization/resources/copilots/types/MessageReply.d.ts +3 -0
- package/serialization/resources/copilots/types/MessageReply.js +3 -0
- package/serialization/resources/copilots/types/ReferencedSource.d.ts +16 -0
- package/serialization/resources/copilots/types/ReferencedSource.js +37 -0
- package/serialization/resources/copilots/types/index.d.ts +3 -0
- package/serialization/resources/copilots/types/index.js +3 -0
- package/serialization/resources/search/client/requests/SearchDocumentCollectionRequest.d.ts +1 -1
- package/serialization/resources/search/client/requests/SearchDocumentCollectionRequest.js +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="./credal-dark-logo.svg" width="400" />
|
|
3
|
+
<h1>Credal Typescript SDK</h1>
|
|
4
|
+
|
|
5
|
+
<p>
|
|
6
|
+
<strong>The Credal Typescript Library provides convenient access to the Credal API from applications written in Typescript.</strong>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<br>
|
|
10
|
+
<div>
|
|
11
|
+
<a href="https://buildwithfern.com/"><img src="https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen">
|
|
12
|
+
</div>
|
|
13
|
+
<br>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
# Documentation
|
|
17
|
+
|
|
18
|
+
Docs for the API endpoints available through the SDK can be found [here](https://docs.credal.ai/getting-started/overview).
|
|
19
|
+
|
|
20
|
+
## Reference
|
|
21
|
+
|
|
22
|
+
A full reference of the SDK is available [here](./reference.md).
|
|
23
|
+
|
|
24
|
+
# Installation
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm install @credal/sdk
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
# Usage
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { CredalClient } from "@credal/sdk";
|
|
34
|
+
|
|
35
|
+
const credal = new CredalClient({
|
|
36
|
+
apiKey: process.env.CREDAL_API_KEY,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
await credal.copilots.sendMessage({
|
|
40
|
+
message: "Is Credal SOC 2 compliant?",
|
|
41
|
+
userEmail: "ravin@credal.ai"
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Docs for the API endpoints available through the SDK can be found [here](https://docs.credal.ai/getting-started/overview).
|
|
46
|
+
|
|
47
|
+
## Self Hosted
|
|
48
|
+
|
|
49
|
+
If you're on a self-hosted Credal instance, then you can customize the base url of the SDK.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
const credal = new CredalClient({
|
|
53
|
+
apiKey: process.env.CREDAL_API_KEY,
|
|
54
|
+
environment: "https://<custom-domain>/api",
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Request and Response Types
|
|
59
|
+
|
|
60
|
+
The SDK exports all request and response types as TypeScript interfaces. Simply
|
|
61
|
+
import them under the `Credal` namespace:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { Credal } from "@credal/sdk";
|
|
65
|
+
|
|
66
|
+
const metadata: Credal.DocumentMetadataPatch = {
|
|
67
|
+
resourceIdentifier: "..."
|
|
68
|
+
};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Exception Handling
|
|
72
|
+
|
|
73
|
+
When the API returns a non-success status code (4xx or 5xx response),
|
|
74
|
+
a subclass of [CredalError](./src/errors/CredalError.ts) will be thrown:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { CredalError } from "@credal/sdk";
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
await credal.copilots.sendMessage(...);
|
|
81
|
+
} catch (err) {
|
|
82
|
+
if (err instanceof CredalError) {
|
|
83
|
+
console.log(err.statusCode);
|
|
84
|
+
console.log(err.message);
|
|
85
|
+
console.log(err.body);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Retries
|
|
91
|
+
|
|
92
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be
|
|
93
|
+
retried as long as the request is deemed retriable and the number of retry attempts has not grown larger
|
|
94
|
+
than the configured retry limit (default: 2).
|
|
95
|
+
|
|
96
|
+
A request is deemed retriable when any of the following HTTP status codes is returned:
|
|
97
|
+
|
|
98
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
99
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
100
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
|
|
101
|
+
|
|
102
|
+
Use the `maxRetries` request option to configure this behavior.
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
const response = await credal.copilots.sendMessage(..., {
|
|
106
|
+
maxRetries: 0 // override maxRetries at the request level
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Timeouts
|
|
111
|
+
|
|
112
|
+
The SDK defaults to a 60 second timout. Use the `timeoutInSeconds` option to
|
|
113
|
+
configure this behavior.
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
const response = await credal.copilots.sendMessage(..., {
|
|
117
|
+
timeoutInSeconds: 30 // override timeout to 30s
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Aborting Requests
|
|
122
|
+
|
|
123
|
+
The SDK allows users to abort requests at any point by passing
|
|
124
|
+
in an abort signal.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
const controller = new AbortController();
|
|
128
|
+
const response = await credal.copilots.sendMessage(..., {
|
|
129
|
+
abortSignal: controller.signal,
|
|
130
|
+
});
|
|
131
|
+
controller.abort(); // aborts the request
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Runtime compatiblity
|
|
135
|
+
|
|
136
|
+
The SDK defaults to `node-fetch` but will use the global fetch client if present. The SDK
|
|
137
|
+
works in the following runtimes:
|
|
138
|
+
|
|
139
|
+
The following runtimes are supported:
|
|
140
|
+
|
|
141
|
+
- Node.js 18+
|
|
142
|
+
- Vercel
|
|
143
|
+
- Cloudflare Workers
|
|
144
|
+
- Deno v1.25+
|
|
145
|
+
- Bun 1.0+
|
|
146
|
+
- React Native
|
|
147
|
+
|
|
148
|
+
### Customizing Fetch client
|
|
149
|
+
|
|
150
|
+
The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're
|
|
151
|
+
running in an unsupported environment, this provides a way for you to break the glass and
|
|
152
|
+
ensure the SDK works.
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import { CredalClient } from "@credal/sdk";
|
|
156
|
+
|
|
157
|
+
const credal = new CredalClient({
|
|
158
|
+
apiKey: "...",
|
|
159
|
+
fetcher: // provide your implementation here
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# Beta Status
|
|
165
|
+
|
|
166
|
+
This SDK is in beta, and there may be breaking changes between versions without a major
|
|
167
|
+
version update. Therefore, we recommend pinning the package version to a specific version.
|
|
168
|
+
This way, you can install the same version each time without breaking changes.
|
|
@@ -31,6 +31,21 @@ export declare class Copilots {
|
|
|
31
31
|
* })
|
|
32
32
|
*/
|
|
33
33
|
createConversation(request: Credal.CreateConversationRequest, requestOptions?: Copilots.RequestOptions): Promise<Credal.CreateConversationResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* @param {Credal.ProvideMessageFeedbackRequest} request
|
|
36
|
+
* @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* await credal.copilots.provideMessageFeedback({
|
|
40
|
+
* userEmail: "ravin@credal.ai",
|
|
41
|
+
* messageId: "dd721cd8-4bf2-4b94-9869-258df3dab9dc",
|
|
42
|
+
* messageFeedback: {
|
|
43
|
+
* feedback: Credal.FeedbackEnum.Negative,
|
|
44
|
+
* suggestedAnswer: "Yes, Credal is SOC 2 compliant."
|
|
45
|
+
* }
|
|
46
|
+
* })
|
|
47
|
+
*/
|
|
48
|
+
provideMessageFeedback(request: Credal.ProvideMessageFeedbackRequest, requestOptions?: Copilots.RequestOptions): Promise<void>;
|
|
34
49
|
/**
|
|
35
50
|
* @param {Credal.SendMessageRequest} request
|
|
36
51
|
* @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -69,7 +69,7 @@ class Copilots {
|
|
|
69
69
|
Authorization: yield this._getAuthorizationHeader(),
|
|
70
70
|
"X-Fern-Language": "JavaScript",
|
|
71
71
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
72
|
-
"X-Fern-SDK-Version": "0.0.
|
|
72
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
73
73
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
74
74
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
75
75
|
},
|
|
@@ -108,6 +108,66 @@ class Copilots {
|
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* @param {Credal.ProvideMessageFeedbackRequest} request
|
|
113
|
+
* @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* await credal.copilots.provideMessageFeedback({
|
|
117
|
+
* userEmail: "ravin@credal.ai",
|
|
118
|
+
* messageId: "dd721cd8-4bf2-4b94-9869-258df3dab9dc",
|
|
119
|
+
* messageFeedback: {
|
|
120
|
+
* feedback: Credal.FeedbackEnum.Negative,
|
|
121
|
+
* suggestedAnswer: "Yes, Credal is SOC 2 compliant."
|
|
122
|
+
* }
|
|
123
|
+
* })
|
|
124
|
+
*/
|
|
125
|
+
provideMessageFeedback(request, requestOptions) {
|
|
126
|
+
var _a, _b;
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
129
|
+
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CredalEnvironment.Production, "/v0/copilots/provideMessageFeedback"),
|
|
130
|
+
method: "POST",
|
|
131
|
+
headers: {
|
|
132
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
133
|
+
"X-Fern-Language": "JavaScript",
|
|
134
|
+
"X-Fern-SDK-Name": "@credal/sdk",
|
|
135
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
136
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
137
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
138
|
+
},
|
|
139
|
+
contentType: "application/json",
|
|
140
|
+
body: yield serializers.ProvideMessageFeedbackRequest.jsonOrThrow(request, {
|
|
141
|
+
unrecognizedObjectKeys: "strip",
|
|
142
|
+
}),
|
|
143
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
144
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
145
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
146
|
+
});
|
|
147
|
+
if (_response.ok) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (_response.error.reason === "status-code") {
|
|
151
|
+
throw new errors.CredalError({
|
|
152
|
+
statusCode: _response.error.statusCode,
|
|
153
|
+
body: _response.error.body,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
switch (_response.error.reason) {
|
|
157
|
+
case "non-json":
|
|
158
|
+
throw new errors.CredalError({
|
|
159
|
+
statusCode: _response.error.statusCode,
|
|
160
|
+
body: _response.error.rawBody,
|
|
161
|
+
});
|
|
162
|
+
case "timeout":
|
|
163
|
+
throw new errors.CredalTimeoutError();
|
|
164
|
+
case "unknown":
|
|
165
|
+
throw new errors.CredalError({
|
|
166
|
+
message: _response.error.errorMessage,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
111
171
|
/**
|
|
112
172
|
* @param {Credal.SendMessageRequest} request
|
|
113
173
|
* @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -128,7 +188,7 @@ class Copilots {
|
|
|
128
188
|
Authorization: yield this._getAuthorizationHeader(),
|
|
129
189
|
"X-Fern-Language": "JavaScript",
|
|
130
190
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
131
|
-
"X-Fern-SDK-Version": "0.0.
|
|
191
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
132
192
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
133
193
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
134
194
|
},
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as Credal from "../../../../index";
|
|
5
|
+
/**
|
|
6
|
+
* @example
|
|
7
|
+
* {
|
|
8
|
+
* userEmail: "ravin@credal.ai",
|
|
9
|
+
* messageId: "dd721cd8-4bf2-4b94-9869-258df3dab9dc",
|
|
10
|
+
* messageFeedback: {
|
|
11
|
+
* feedback: Credal.FeedbackEnum.Negative,
|
|
12
|
+
* suggestedAnswer: "Yes, Credal is SOC 2 compliant."
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
export interface ProvideMessageFeedbackRequest {
|
|
17
|
+
/**
|
|
18
|
+
* The user profile you want to use when providing feedback.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
userEmail: string;
|
|
22
|
+
/**
|
|
23
|
+
* The message ID for which feedback is being provided.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
messageId: string;
|
|
27
|
+
/**
|
|
28
|
+
* The feedback provided by the user.
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
messageFeedback: Credal.MessageFeedback;
|
|
32
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FeedbackEnum = void 0;
|
|
7
|
+
exports.FeedbackEnum = {
|
|
8
|
+
Positive: "POSITIVE",
|
|
9
|
+
Negative: "NEGATIVE",
|
|
10
|
+
};
|
|
@@ -2,7 +2,10 @@ export * from "./CreateConversationResponse";
|
|
|
2
2
|
export * from "./SendAgentMessageResponse";
|
|
3
3
|
export * from "./SendMessageResponse";
|
|
4
4
|
export * from "./MessageReply";
|
|
5
|
+
export * from "./ReferencedSource";
|
|
5
6
|
export * from "./ResponseChunk";
|
|
6
7
|
export * from "./InsertedAuditLog";
|
|
7
8
|
export * from "./MessageBlocked";
|
|
8
9
|
export * from "./PolicyTrigger";
|
|
10
|
+
export * from "./FeedbackEnum";
|
|
11
|
+
export * from "./MessageFeedback";
|
|
@@ -18,7 +18,10 @@ __exportStar(require("./CreateConversationResponse"), exports);
|
|
|
18
18
|
__exportStar(require("./SendAgentMessageResponse"), exports);
|
|
19
19
|
__exportStar(require("./SendMessageResponse"), exports);
|
|
20
20
|
__exportStar(require("./MessageReply"), exports);
|
|
21
|
+
__exportStar(require("./ReferencedSource"), exports);
|
|
21
22
|
__exportStar(require("./ResponseChunk"), exports);
|
|
22
23
|
__exportStar(require("./InsertedAuditLog"), exports);
|
|
23
24
|
__exportStar(require("./MessageBlocked"), exports);
|
|
24
25
|
__exportStar(require("./PolicyTrigger"), exports);
|
|
26
|
+
__exportStar(require("./FeedbackEnum"), exports);
|
|
27
|
+
__exportStar(require("./MessageFeedback"), exports);
|
|
@@ -71,7 +71,7 @@ class DocumentCatalog {
|
|
|
71
71
|
Authorization: yield this._getAuthorizationHeader(),
|
|
72
72
|
"X-Fern-Language": "JavaScript",
|
|
73
73
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
74
|
-
"X-Fern-SDK-Version": "0.0.
|
|
74
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
75
75
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
76
76
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
77
77
|
},
|
|
@@ -154,7 +154,7 @@ class DocumentCatalog {
|
|
|
154
154
|
Authorization: yield this._getAuthorizationHeader(),
|
|
155
155
|
"X-Fern-Language": "JavaScript",
|
|
156
156
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
157
|
-
"X-Fern-SDK-Version": "0.0.
|
|
157
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
158
158
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
159
159
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
160
160
|
},
|
|
@@ -78,7 +78,7 @@ class DocumentCollections {
|
|
|
78
78
|
Authorization: yield this._getAuthorizationHeader(),
|
|
79
79
|
"X-Fern-Language": "JavaScript",
|
|
80
80
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
81
|
-
"X-Fern-SDK-Version": "0.0.
|
|
81
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
82
82
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
83
83
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
84
84
|
},
|
|
@@ -74,7 +74,7 @@ class PermissionsService {
|
|
|
74
74
|
Authorization: yield this._getAuthorizationHeader(),
|
|
75
75
|
"X-Fern-Language": "JavaScript",
|
|
76
76
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
77
|
-
"X-Fern-SDK-Version": "0.0.
|
|
77
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
78
78
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
79
79
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
80
80
|
},
|
|
@@ -145,7 +145,7 @@ class PermissionsService {
|
|
|
145
145
|
Authorization: yield this._getAuthorizationHeader(),
|
|
146
146
|
"X-Fern-Language": "JavaScript",
|
|
147
147
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
148
|
-
"X-Fern-SDK-Version": "0.0.
|
|
148
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
149
149
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
150
150
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
151
151
|
},
|
|
@@ -207,7 +207,7 @@ class PermissionsService {
|
|
|
207
207
|
Authorization: yield this._getAuthorizationHeader(),
|
|
208
208
|
"X-Fern-Language": "JavaScript",
|
|
209
209
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
210
|
-
"X-Fern-SDK-Version": "0.0.
|
|
210
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
211
211
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
212
212
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
213
213
|
},
|
|
@@ -84,7 +84,7 @@ class Search {
|
|
|
84
84
|
Authorization: yield this._getAuthorizationHeader(),
|
|
85
85
|
"X-Fern-Language": "JavaScript",
|
|
86
86
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
87
|
-
"X-Fern-SDK-Version": "0.0.
|
|
87
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
88
88
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
89
89
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
90
90
|
},
|
|
@@ -35,7 +35,7 @@ export interface SearchDocumentCollectionRequest {
|
|
|
35
35
|
* The structured query filters to apply to the search query.
|
|
36
36
|
*
|
|
37
37
|
*/
|
|
38
|
-
structuredQueryFilters
|
|
38
|
+
structuredQueryFilters?: Credal.SingleFieldFilter[];
|
|
39
39
|
searchOptions?: Credal.DocumentCollectionSearchOptions;
|
|
40
40
|
/**
|
|
41
41
|
* Legacy metadata filter expression to apply to the search query. Use structuredQueryFilters instead.
|
|
@@ -79,7 +79,7 @@ class Users {
|
|
|
79
79
|
Authorization: yield this._getAuthorizationHeader(),
|
|
80
80
|
"X-Fern-Language": "JavaScript",
|
|
81
81
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
82
|
-
"X-Fern-SDK-Version": "0.0.
|
|
82
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
83
83
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
84
84
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
85
85
|
},
|
|
@@ -31,6 +31,21 @@ export declare class Copilots {
|
|
|
31
31
|
* })
|
|
32
32
|
*/
|
|
33
33
|
createConversation(request: Credal.CreateConversationRequest, requestOptions?: Copilots.RequestOptions): Promise<Credal.CreateConversationResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* @param {Credal.ProvideMessageFeedbackRequest} request
|
|
36
|
+
* @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* await credal.copilots.provideMessageFeedback({
|
|
40
|
+
* userEmail: "ravin@credal.ai",
|
|
41
|
+
* messageId: "dd721cd8-4bf2-4b94-9869-258df3dab9dc",
|
|
42
|
+
* messageFeedback: {
|
|
43
|
+
* feedback: Credal.FeedbackEnum.Negative,
|
|
44
|
+
* suggestedAnswer: "Yes, Credal is SOC 2 compliant."
|
|
45
|
+
* }
|
|
46
|
+
* })
|
|
47
|
+
*/
|
|
48
|
+
provideMessageFeedback(request: Credal.ProvideMessageFeedbackRequest, requestOptions?: Copilots.RequestOptions): Promise<void>;
|
|
34
49
|
/**
|
|
35
50
|
* @param {Credal.SendMessageRequest} request
|
|
36
51
|
* @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -69,7 +69,7 @@ class Copilots {
|
|
|
69
69
|
Authorization: yield this._getAuthorizationHeader(),
|
|
70
70
|
"X-Fern-Language": "JavaScript",
|
|
71
71
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
72
|
-
"X-Fern-SDK-Version": "0.0.
|
|
72
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
73
73
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
74
74
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
75
75
|
},
|
|
@@ -108,6 +108,66 @@ class Copilots {
|
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* @param {Credal.ProvideMessageFeedbackRequest} request
|
|
113
|
+
* @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* await credal.copilots.provideMessageFeedback({
|
|
117
|
+
* userEmail: "ravin@credal.ai",
|
|
118
|
+
* messageId: "dd721cd8-4bf2-4b94-9869-258df3dab9dc",
|
|
119
|
+
* messageFeedback: {
|
|
120
|
+
* feedback: Credal.FeedbackEnum.Negative,
|
|
121
|
+
* suggestedAnswer: "Yes, Credal is SOC 2 compliant."
|
|
122
|
+
* }
|
|
123
|
+
* })
|
|
124
|
+
*/
|
|
125
|
+
provideMessageFeedback(request, requestOptions) {
|
|
126
|
+
var _a, _b;
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
129
|
+
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CredalEnvironment.Production, "/v0/copilots/provideMessageFeedback"),
|
|
130
|
+
method: "POST",
|
|
131
|
+
headers: {
|
|
132
|
+
Authorization: yield this._getAuthorizationHeader(),
|
|
133
|
+
"X-Fern-Language": "JavaScript",
|
|
134
|
+
"X-Fern-SDK-Name": "@credal/sdk",
|
|
135
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
136
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
137
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
138
|
+
},
|
|
139
|
+
contentType: "application/json",
|
|
140
|
+
body: yield serializers.ProvideMessageFeedbackRequest.jsonOrThrow(request, {
|
|
141
|
+
unrecognizedObjectKeys: "strip",
|
|
142
|
+
}),
|
|
143
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
144
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
145
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
146
|
+
});
|
|
147
|
+
if (_response.ok) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (_response.error.reason === "status-code") {
|
|
151
|
+
throw new errors.CredalError({
|
|
152
|
+
statusCode: _response.error.statusCode,
|
|
153
|
+
body: _response.error.body,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
switch (_response.error.reason) {
|
|
157
|
+
case "non-json":
|
|
158
|
+
throw new errors.CredalError({
|
|
159
|
+
statusCode: _response.error.statusCode,
|
|
160
|
+
body: _response.error.rawBody,
|
|
161
|
+
});
|
|
162
|
+
case "timeout":
|
|
163
|
+
throw new errors.CredalTimeoutError();
|
|
164
|
+
case "unknown":
|
|
165
|
+
throw new errors.CredalError({
|
|
166
|
+
message: _response.error.errorMessage,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
111
171
|
/**
|
|
112
172
|
* @param {Credal.SendMessageRequest} request
|
|
113
173
|
* @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -128,7 +188,7 @@ class Copilots {
|
|
|
128
188
|
Authorization: yield this._getAuthorizationHeader(),
|
|
129
189
|
"X-Fern-Language": "JavaScript",
|
|
130
190
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
131
|
-
"X-Fern-SDK-Version": "0.0.
|
|
191
|
+
"X-Fern-SDK-Version": "0.0.5",
|
|
132
192
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
133
193
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
134
194
|
},
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as Credal from "../../../../index";
|
|
5
|
+
/**
|
|
6
|
+
* @example
|
|
7
|
+
* {
|
|
8
|
+
* userEmail: "ravin@credal.ai",
|
|
9
|
+
* messageId: "dd721cd8-4bf2-4b94-9869-258df3dab9dc",
|
|
10
|
+
* messageFeedback: {
|
|
11
|
+
* feedback: Credal.FeedbackEnum.Negative,
|
|
12
|
+
* suggestedAnswer: "Yes, Credal is SOC 2 compliant."
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
export interface ProvideMessageFeedbackRequest {
|
|
17
|
+
/**
|
|
18
|
+
* The user profile you want to use when providing feedback.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
userEmail: string;
|
|
22
|
+
/**
|
|
23
|
+
* The message ID for which feedback is being provided.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
messageId: string;
|
|
27
|
+
/**
|
|
28
|
+
* The feedback provided by the user.
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
messageFeedback: Credal.MessageFeedback;
|
|
32
|
+
}
|