@credal/sdk 0.1.11 → 0.1.13
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/dist/cjs/BaseClient.d.ts +10 -1
- package/dist/cjs/BaseClient.js +55 -0
- package/dist/cjs/Client.d.ts +18 -17
- package/dist/cjs/Client.js +8 -49
- package/dist/cjs/api/resources/copilots/client/Client.d.ts +22 -22
- package/dist/cjs/api/resources/copilots/client/Client.js +32 -34
- package/dist/cjs/api/resources/documentCatalog/client/Client.d.ts +13 -13
- package/dist/cjs/api/resources/documentCatalog/client/Client.js +18 -25
- package/dist/cjs/api/resources/documentCollections/client/Client.d.ts +19 -19
- package/dist/cjs/api/resources/documentCollections/client/Client.js +27 -31
- package/dist/cjs/api/resources/search/client/Client.d.ts +7 -7
- package/dist/cjs/api/resources/search/client/Client.js +9 -19
- package/dist/cjs/api/resources/users/client/Client.d.ts +7 -7
- package/dist/cjs/api/resources/users/client/Client.js +9 -19
- package/dist/cjs/auth/BearerAuthProvider.d.ts +14 -0
- package/dist/cjs/auth/BearerAuthProvider.js +72 -0
- package/dist/cjs/auth/index.d.ts +1 -0
- package/dist/cjs/auth/index.js +5 -0
- package/dist/cjs/core/auth/AuthProvider.d.ts +4 -1
- package/dist/cjs/core/auth/BearerToken.d.ts +3 -1
- package/dist/cjs/core/auth/BearerToken.js +7 -6
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +10 -1
- package/dist/esm/BaseClient.mjs +20 -1
- package/dist/esm/Client.d.mts +18 -17
- package/dist/esm/Client.mjs +13 -21
- package/dist/esm/api/resources/copilots/client/Client.d.mts +22 -22
- package/dist/esm/api/resources/copilots/client/Client.mjs +31 -33
- package/dist/esm/api/resources/documentCatalog/client/Client.d.mts +13 -13
- package/dist/esm/api/resources/documentCatalog/client/Client.mjs +16 -23
- package/dist/esm/api/resources/documentCollections/client/Client.d.mts +19 -19
- package/dist/esm/api/resources/documentCollections/client/Client.mjs +26 -30
- package/dist/esm/api/resources/search/client/Client.d.mts +7 -7
- package/dist/esm/api/resources/search/client/Client.mjs +8 -18
- package/dist/esm/api/resources/users/client/Client.d.mts +7 -7
- package/dist/esm/api/resources/users/client/Client.mjs +8 -18
- package/dist/esm/auth/BearerAuthProvider.d.mts +14 -0
- package/dist/esm/auth/BearerAuthProvider.mjs +35 -0
- package/dist/esm/auth/index.d.mts +1 -0
- package/dist/esm/auth/index.mjs +1 -0
- package/dist/esm/core/auth/AuthProvider.d.mts +4 -1
- package/dist/esm/core/auth/BearerToken.d.mts +3 -1
- package/dist/esm/core/auth/BearerToken.mjs +7 -6
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/reference.md +21 -21
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.BearerAuthProvider = void 0;
|
|
47
|
+
const core = __importStar(require("../core/index.js"));
|
|
48
|
+
const errors = __importStar(require("../errors/index.js"));
|
|
49
|
+
class BearerAuthProvider {
|
|
50
|
+
constructor(options) {
|
|
51
|
+
this.token = options.apiKey;
|
|
52
|
+
}
|
|
53
|
+
static canCreate(options) {
|
|
54
|
+
var _a;
|
|
55
|
+
return options.apiKey != null || ((_a = process.env) === null || _a === void 0 ? void 0 : _a.CREDAL_API_KEY) != null;
|
|
56
|
+
}
|
|
57
|
+
getAuthRequest(_arg) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
const apiKey = (_a = (yield core.Supplier.get(this.token))) !== null && _a !== void 0 ? _a : (_b = process.env) === null || _b === void 0 ? void 0 : _b.CREDAL_API_KEY;
|
|
61
|
+
if (apiKey == null) {
|
|
62
|
+
throw new errors.CredalError({
|
|
63
|
+
message: "Please specify a apiKey by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.BearerAuthProvider = BearerAuthProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BearerAuthProvider } from "./BearerAuthProvider.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BearerAuthProvider = void 0;
|
|
4
|
+
var BearerAuthProvider_js_1 = require("./BearerAuthProvider.js");
|
|
5
|
+
Object.defineProperty(exports, "BearerAuthProvider", { enumerable: true, get: function () { return BearerAuthProvider_js_1.BearerAuthProvider; } });
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import type { EndpointMetadata } from "../fetcher/EndpointMetadata.js";
|
|
1
2
|
import type { AuthRequest } from "./AuthRequest.js";
|
|
2
3
|
export interface AuthProvider {
|
|
3
|
-
getAuthRequest(
|
|
4
|
+
getAuthRequest(arg?: {
|
|
5
|
+
endpointMetadata?: EndpointMetadata;
|
|
6
|
+
}): Promise<AuthRequest>;
|
|
4
7
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export type BearerToken = string;
|
|
2
|
+
declare function toAuthorizationHeader(token: string | undefined): string | undefined;
|
|
2
3
|
export declare const BearerToken: {
|
|
3
|
-
toAuthorizationHeader:
|
|
4
|
+
toAuthorizationHeader: typeof toAuthorizationHeader;
|
|
4
5
|
fromAuthorizationHeader: (header: string) => BearerToken;
|
|
5
6
|
};
|
|
7
|
+
export {};
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BearerToken = void 0;
|
|
4
4
|
const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i;
|
|
5
|
+
function toAuthorizationHeader(token) {
|
|
6
|
+
if (token == null) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return `Bearer ${token}`;
|
|
10
|
+
}
|
|
5
11
|
exports.BearerToken = {
|
|
6
|
-
toAuthorizationHeader:
|
|
7
|
-
if (token == null) {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
return `Bearer ${token}`;
|
|
11
|
-
},
|
|
12
|
+
toAuthorizationHeader: toAuthorizationHeader,
|
|
12
13
|
fromAuthorizationHeader: (header) => {
|
|
13
14
|
return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim();
|
|
14
15
|
},
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.1.
|
|
1
|
+
export declare const SDK_VERSION = "0.1.13";
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as core from "./core/index.mjs";
|
|
2
2
|
import type * as environments from "./environments.mjs";
|
|
3
3
|
export interface BaseClientOptions {
|
|
4
4
|
environment?: core.Supplier<environments.CredalEnvironment | string>;
|
|
@@ -29,3 +29,12 @@ export interface BaseRequestOptions {
|
|
|
29
29
|
/** Additional headers to include in the request. */
|
|
30
30
|
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
31
31
|
}
|
|
32
|
+
export type NormalizedClientOptions<T extends BaseClientOptions> = T & {
|
|
33
|
+
logging: core.logging.Logger;
|
|
34
|
+
authProvider?: core.AuthProvider;
|
|
35
|
+
};
|
|
36
|
+
export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions> = NormalizedClientOptions<T> & {
|
|
37
|
+
authProvider: core.AuthProvider;
|
|
38
|
+
};
|
|
39
|
+
export declare function normalizeClientOptions<T extends BaseClientOptions>(options: T): NormalizedClientOptions<T>;
|
|
40
|
+
export declare function normalizeClientOptionsWithAuth<T extends BaseClientOptions>(options: T): NormalizedClientOptionsWithAuth<T>;
|
package/dist/esm/BaseClient.mjs
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
1
|
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
-
|
|
2
|
+
import { BearerAuthProvider } from "./auth/BearerAuthProvider.mjs";
|
|
3
|
+
import { mergeHeaders } from "./core/headers.mjs";
|
|
4
|
+
import * as core from "./core/index.mjs";
|
|
5
|
+
export function normalizeClientOptions(options) {
|
|
6
|
+
const headers = mergeHeaders({
|
|
7
|
+
"X-Fern-Language": "JavaScript",
|
|
8
|
+
"X-Fern-SDK-Name": "@credal/sdk",
|
|
9
|
+
"X-Fern-SDK-Version": "0.1.13",
|
|
10
|
+
"User-Agent": "@credal/sdk/0.1.13",
|
|
11
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
12
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
13
|
+
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
14
|
+
return Object.assign(Object.assign({}, options), { logging: core.logging.createLogger(options === null || options === void 0 ? void 0 : options.logging), headers });
|
|
15
|
+
}
|
|
16
|
+
export function normalizeClientOptionsWithAuth(options) {
|
|
17
|
+
var _a;
|
|
18
|
+
const normalized = normalizeClientOptions(options);
|
|
19
|
+
(_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = new BearerAuthProvider(options));
|
|
20
|
+
return normalized;
|
|
21
|
+
}
|
package/dist/esm/Client.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { CopilotsClient } from "./api/resources/copilots/client/Client.mjs";
|
|
2
|
+
import { DocumentCatalogClient } from "./api/resources/documentCatalog/client/Client.mjs";
|
|
3
|
+
import { DocumentCollectionsClient } from "./api/resources/documentCollections/client/Client.mjs";
|
|
4
|
+
import { SearchClient } from "./api/resources/search/client/Client.mjs";
|
|
5
|
+
import { UsersClient } from "./api/resources/users/client/Client.mjs";
|
|
6
6
|
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.mjs";
|
|
7
|
+
import { type NormalizedClientOptionsWithAuth } from "./BaseClient.mjs";
|
|
7
8
|
export declare namespace CredalClient {
|
|
8
9
|
interface Options extends BaseClientOptions {
|
|
9
10
|
}
|
|
@@ -11,16 +12,16 @@ export declare namespace CredalClient {
|
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
export declare class CredalClient {
|
|
14
|
-
protected readonly _options: CredalClient.Options
|
|
15
|
-
protected _copilots:
|
|
16
|
-
protected _documentCatalog:
|
|
17
|
-
protected _documentCollections:
|
|
18
|
-
protected _search:
|
|
19
|
-
protected _users:
|
|
20
|
-
constructor(
|
|
21
|
-
get copilots():
|
|
22
|
-
get documentCatalog():
|
|
23
|
-
get documentCollections():
|
|
24
|
-
get search():
|
|
25
|
-
get users():
|
|
15
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<CredalClient.Options>;
|
|
16
|
+
protected _copilots: CopilotsClient | undefined;
|
|
17
|
+
protected _documentCatalog: DocumentCatalogClient | undefined;
|
|
18
|
+
protected _documentCollections: DocumentCollectionsClient | undefined;
|
|
19
|
+
protected _search: SearchClient | undefined;
|
|
20
|
+
protected _users: UsersClient | undefined;
|
|
21
|
+
constructor(options?: CredalClient.Options);
|
|
22
|
+
get copilots(): CopilotsClient;
|
|
23
|
+
get documentCatalog(): DocumentCatalogClient;
|
|
24
|
+
get documentCollections(): DocumentCollectionsClient;
|
|
25
|
+
get search(): SearchClient;
|
|
26
|
+
get users(): UsersClient;
|
|
26
27
|
}
|
package/dist/esm/Client.mjs
CHANGED
|
@@ -1,40 +1,32 @@
|
|
|
1
1
|
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import * as core from "./core/index.mjs";
|
|
2
|
+
import { CopilotsClient } from "./api/resources/copilots/client/Client.mjs";
|
|
3
|
+
import { DocumentCatalogClient } from "./api/resources/documentCatalog/client/Client.mjs";
|
|
4
|
+
import { DocumentCollectionsClient } from "./api/resources/documentCollections/client/Client.mjs";
|
|
5
|
+
import { SearchClient } from "./api/resources/search/client/Client.mjs";
|
|
6
|
+
import { UsersClient } from "./api/resources/users/client/Client.mjs";
|
|
7
|
+
import { normalizeClientOptionsWithAuth } from "./BaseClient.mjs";
|
|
9
8
|
export class CredalClient {
|
|
10
|
-
constructor(
|
|
11
|
-
this._options =
|
|
12
|
-
"X-Fern-Language": "JavaScript",
|
|
13
|
-
"X-Fern-SDK-Name": "@credal/sdk",
|
|
14
|
-
"X-Fern-SDK-Version": "0.1.11",
|
|
15
|
-
"User-Agent": "@credal/sdk/0.1.11",
|
|
16
|
-
"X-Fern-Runtime": core.RUNTIME.type,
|
|
17
|
-
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
18
|
-
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
9
|
+
constructor(options = {}) {
|
|
10
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
19
11
|
}
|
|
20
12
|
get copilots() {
|
|
21
13
|
var _a;
|
|
22
|
-
return ((_a = this._copilots) !== null && _a !== void 0 ? _a : (this._copilots = new
|
|
14
|
+
return ((_a = this._copilots) !== null && _a !== void 0 ? _a : (this._copilots = new CopilotsClient(this._options)));
|
|
23
15
|
}
|
|
24
16
|
get documentCatalog() {
|
|
25
17
|
var _a;
|
|
26
|
-
return ((_a = this._documentCatalog) !== null && _a !== void 0 ? _a : (this._documentCatalog = new
|
|
18
|
+
return ((_a = this._documentCatalog) !== null && _a !== void 0 ? _a : (this._documentCatalog = new DocumentCatalogClient(this._options)));
|
|
27
19
|
}
|
|
28
20
|
get documentCollections() {
|
|
29
21
|
var _a;
|
|
30
|
-
return ((_a = this._documentCollections) !== null && _a !== void 0 ? _a : (this._documentCollections = new
|
|
22
|
+
return ((_a = this._documentCollections) !== null && _a !== void 0 ? _a : (this._documentCollections = new DocumentCollectionsClient(this._options)));
|
|
31
23
|
}
|
|
32
24
|
get search() {
|
|
33
25
|
var _a;
|
|
34
|
-
return ((_a = this._search) !== null && _a !== void 0 ? _a : (this._search = new
|
|
26
|
+
return ((_a = this._search) !== null && _a !== void 0 ? _a : (this._search = new SearchClient(this._options)));
|
|
35
27
|
}
|
|
36
28
|
get users() {
|
|
37
29
|
var _a;
|
|
38
|
-
return ((_a = this._users) !== null && _a !== void 0 ? _a : (this._users = new
|
|
30
|
+
return ((_a = this._users) !== null && _a !== void 0 ? _a : (this._users = new UsersClient(this._options)));
|
|
39
31
|
}
|
|
40
32
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
2
3
|
import * as core from "../../../../core/index.mjs";
|
|
3
4
|
import type * as Credal from "../../../index.mjs";
|
|
4
|
-
export declare namespace
|
|
5
|
+
export declare namespace CopilotsClient {
|
|
5
6
|
interface Options extends BaseClientOptions {
|
|
6
7
|
}
|
|
7
8
|
interface RequestOptions extends BaseRequestOptions {
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
|
-
export declare class
|
|
11
|
-
protected readonly _options:
|
|
12
|
-
constructor(
|
|
11
|
+
export declare class CopilotsClient {
|
|
12
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<CopilotsClient.Options>;
|
|
13
|
+
constructor(options?: CopilotsClient.Options);
|
|
13
14
|
/**
|
|
14
15
|
* Create a new agent. The API key used will be added to the agent for future Requests
|
|
15
16
|
*
|
|
16
17
|
* @param {Credal.CreateCopilotRequest} request
|
|
17
|
-
* @param {
|
|
18
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
18
19
|
*
|
|
19
20
|
* @example
|
|
20
21
|
* await client.copilots.createCopilot({
|
|
@@ -26,13 +27,13 @@ export declare class Copilots {
|
|
|
26
27
|
* }]
|
|
27
28
|
* })
|
|
28
29
|
*/
|
|
29
|
-
createCopilot(request: Credal.CreateCopilotRequest, requestOptions?:
|
|
30
|
+
createCopilot(request: Credal.CreateCopilotRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<Credal.CreateCopilotResponse>;
|
|
30
31
|
private __createCopilot;
|
|
31
32
|
/**
|
|
32
33
|
* OPTIONAL. Create a new conversation with the Agent. The conversation ID can be used in the `sendMessage` endpoint. The `sendMessage` endpoint automatically creates new conversations upon first request, but calling this endpoint can simplify certain use cases where it is helpful for the application to have the conversation ID before the first message is sent.
|
|
33
34
|
*
|
|
34
35
|
* @param {Credal.CreateConversationRequest} request
|
|
35
|
-
* @param {
|
|
36
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
36
37
|
*
|
|
37
38
|
* @example
|
|
38
39
|
* await client.copilots.createConversation({
|
|
@@ -40,11 +41,11 @@ export declare class Copilots {
|
|
|
40
41
|
* userEmail: "ravin@credal.ai"
|
|
41
42
|
* })
|
|
42
43
|
*/
|
|
43
|
-
createConversation(request: Credal.CreateConversationRequest, requestOptions?:
|
|
44
|
+
createConversation(request: Credal.CreateConversationRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<Credal.CreateConversationResponse>;
|
|
44
45
|
private __createConversation;
|
|
45
46
|
/**
|
|
46
47
|
* @param {Credal.ProvideMessageFeedbackRequest} request
|
|
47
|
-
* @param {
|
|
48
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
48
49
|
*
|
|
49
50
|
* @example
|
|
50
51
|
* await client.copilots.provideMessageFeedback({
|
|
@@ -58,11 +59,11 @@ export declare class Copilots {
|
|
|
58
59
|
* }
|
|
59
60
|
* })
|
|
60
61
|
*/
|
|
61
|
-
provideMessageFeedback(request: Credal.ProvideMessageFeedbackRequest, requestOptions?:
|
|
62
|
+
provideMessageFeedback(request: Credal.ProvideMessageFeedbackRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<void>;
|
|
62
63
|
private __provideMessageFeedback;
|
|
63
64
|
/**
|
|
64
65
|
* @param {Credal.SendMessageRequest} request
|
|
65
|
-
* @param {
|
|
66
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
66
67
|
*
|
|
67
68
|
* @example
|
|
68
69
|
* await client.copilots.sendMessage({
|
|
@@ -78,18 +79,18 @@ export declare class Copilots {
|
|
|
78
79
|
* }]
|
|
79
80
|
* })
|
|
80
81
|
*/
|
|
81
|
-
sendMessage(request: Credal.SendMessageRequest, requestOptions?:
|
|
82
|
+
sendMessage(request: Credal.SendMessageRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<Credal.SendAgentMessageResponse>;
|
|
82
83
|
private __sendMessage;
|
|
83
84
|
/**
|
|
84
85
|
* This endpoint allows you to send a message to a specific agent and get the response back as a streamed set of Server-Sent Events.
|
|
85
86
|
*/
|
|
86
|
-
streamMessage(request: Credal.StreamMessageRequest, requestOptions?:
|
|
87
|
+
streamMessage(request: Credal.StreamMessageRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<core.Stream<Credal.StreamingChunk>>;
|
|
87
88
|
private __streamMessage;
|
|
88
89
|
/**
|
|
89
90
|
* Link a collection with a agent. The API Key used must be added to both the collection and the agent beforehand.
|
|
90
91
|
*
|
|
91
92
|
* @param {Credal.AddCollectionToCopilotRequest} request
|
|
92
|
-
* @param {
|
|
93
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
93
94
|
*
|
|
94
95
|
* @example
|
|
95
96
|
* await client.copilots.addCollectionToCopilot({
|
|
@@ -97,13 +98,13 @@ export declare class Copilots {
|
|
|
97
98
|
* collectionId: "def1055f-83c5-43d6-b558-f7a38e7b299e"
|
|
98
99
|
* })
|
|
99
100
|
*/
|
|
100
|
-
addCollectionToCopilot(request: Credal.AddCollectionToCopilotRequest, requestOptions?:
|
|
101
|
+
addCollectionToCopilot(request: Credal.AddCollectionToCopilotRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<void>;
|
|
101
102
|
private __addCollectionToCopilot;
|
|
102
103
|
/**
|
|
103
104
|
* Unlink a collection with a agent. The API Key used must be added to both the collection and the agent beforehand.
|
|
104
105
|
*
|
|
105
106
|
* @param {Credal.RemoveCollectionFromCopilotRequest} request
|
|
106
|
-
* @param {
|
|
107
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
107
108
|
*
|
|
108
109
|
* @example
|
|
109
110
|
* await client.copilots.removeCollectionFromCopilot({
|
|
@@ -111,13 +112,13 @@ export declare class Copilots {
|
|
|
111
112
|
* collectionId: "def1055f-83c5-43d6-b558-f7a38e7b299e"
|
|
112
113
|
* })
|
|
113
114
|
*/
|
|
114
|
-
removeCollectionFromCopilot(request: Credal.RemoveCollectionFromCopilotRequest, requestOptions?:
|
|
115
|
+
removeCollectionFromCopilot(request: Credal.RemoveCollectionFromCopilotRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<void>;
|
|
115
116
|
private __removeCollectionFromCopilot;
|
|
116
117
|
/**
|
|
117
118
|
* Update the configuration for a agent
|
|
118
119
|
*
|
|
119
120
|
* @param {Credal.UpdateConfigurationRequest} request
|
|
120
|
-
* @param {
|
|
121
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
121
122
|
*
|
|
122
123
|
* @example
|
|
123
124
|
* await client.copilots.updateConfiguration({
|
|
@@ -133,18 +134,17 @@ export declare class Copilots {
|
|
|
133
134
|
* }
|
|
134
135
|
* })
|
|
135
136
|
*/
|
|
136
|
-
updateConfiguration(request: Credal.UpdateConfigurationRequest, requestOptions?:
|
|
137
|
+
updateConfiguration(request: Credal.UpdateConfigurationRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<void>;
|
|
137
138
|
private __updateConfiguration;
|
|
138
139
|
/**
|
|
139
140
|
* @param {Credal.DeleteCopilotRequest} request
|
|
140
|
-
* @param {
|
|
141
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
141
142
|
*
|
|
142
143
|
* @example
|
|
143
144
|
* await client.copilots.deleteCopilot({
|
|
144
145
|
* id: "ac20e6ba-0bae-11ef-b25a-efca73df4c3a"
|
|
145
146
|
* })
|
|
146
147
|
*/
|
|
147
|
-
deleteCopilot(request: Credal.DeleteCopilotRequest, requestOptions?:
|
|
148
|
+
deleteCopilot(request: Credal.DeleteCopilotRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<Credal.DeleteCopilotResponse>;
|
|
148
149
|
private __deleteCopilot;
|
|
149
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
150
150
|
}
|
|
@@ -8,19 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
import {
|
|
11
|
+
import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
12
|
+
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
12
13
|
import * as core from "../../../../core/index.mjs";
|
|
13
14
|
import * as environments from "../../../../environments.mjs";
|
|
14
15
|
import * as errors from "../../../../errors/index.mjs";
|
|
15
|
-
export class
|
|
16
|
-
constructor(
|
|
17
|
-
this._options =
|
|
16
|
+
export class CopilotsClient {
|
|
17
|
+
constructor(options = {}) {
|
|
18
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* Create a new agent. The API key used will be added to the agent for future Requests
|
|
21
22
|
*
|
|
22
23
|
* @param {Credal.CreateCopilotRequest} request
|
|
23
|
-
* @param {
|
|
24
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
24
25
|
*
|
|
25
26
|
* @example
|
|
26
27
|
* await client.copilots.createCopilot({
|
|
@@ -38,7 +39,8 @@ export class Copilots {
|
|
|
38
39
|
__createCopilot(request, requestOptions) {
|
|
39
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
41
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
41
|
-
const
|
|
42
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
43
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
42
44
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
43
45
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/createCopilot"),
|
|
44
46
|
method: "POST",
|
|
@@ -84,7 +86,7 @@ export class Copilots {
|
|
|
84
86
|
* OPTIONAL. Create a new conversation with the Agent. The conversation ID can be used in the `sendMessage` endpoint. The `sendMessage` endpoint automatically creates new conversations upon first request, but calling this endpoint can simplify certain use cases where it is helpful for the application to have the conversation ID before the first message is sent.
|
|
85
87
|
*
|
|
86
88
|
* @param {Credal.CreateConversationRequest} request
|
|
87
|
-
* @param {
|
|
89
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
88
90
|
*
|
|
89
91
|
* @example
|
|
90
92
|
* await client.copilots.createConversation({
|
|
@@ -98,7 +100,8 @@ export class Copilots {
|
|
|
98
100
|
__createConversation(request, requestOptions) {
|
|
99
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
102
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
101
|
-
const
|
|
103
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
104
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
102
105
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
103
106
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/createConversation"),
|
|
104
107
|
method: "POST",
|
|
@@ -142,7 +145,7 @@ export class Copilots {
|
|
|
142
145
|
}
|
|
143
146
|
/**
|
|
144
147
|
* @param {Credal.ProvideMessageFeedbackRequest} request
|
|
145
|
-
* @param {
|
|
148
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
146
149
|
*
|
|
147
150
|
* @example
|
|
148
151
|
* await client.copilots.provideMessageFeedback({
|
|
@@ -162,7 +165,8 @@ export class Copilots {
|
|
|
162
165
|
__provideMessageFeedback(request, requestOptions) {
|
|
163
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
167
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
165
|
-
const
|
|
168
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
169
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
166
170
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
167
171
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/provideMessageFeedback"),
|
|
168
172
|
method: "POST",
|
|
@@ -206,7 +210,7 @@ export class Copilots {
|
|
|
206
210
|
}
|
|
207
211
|
/**
|
|
208
212
|
* @param {Credal.SendMessageRequest} request
|
|
209
|
-
* @param {
|
|
213
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
210
214
|
*
|
|
211
215
|
* @example
|
|
212
216
|
* await client.copilots.sendMessage({
|
|
@@ -228,7 +232,8 @@ export class Copilots {
|
|
|
228
232
|
__sendMessage(request, requestOptions) {
|
|
229
233
|
return __awaiter(this, void 0, void 0, function* () {
|
|
230
234
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
231
|
-
const
|
|
235
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
236
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
232
237
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
233
238
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/sendMessage"),
|
|
234
239
|
method: "POST",
|
|
@@ -279,7 +284,8 @@ export class Copilots {
|
|
|
279
284
|
__streamMessage(request, requestOptions) {
|
|
280
285
|
return __awaiter(this, void 0, void 0, function* () {
|
|
281
286
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
282
|
-
const
|
|
287
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
288
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
283
289
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
284
290
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/streamMessage"),
|
|
285
291
|
method: "POST",
|
|
@@ -337,7 +343,7 @@ export class Copilots {
|
|
|
337
343
|
* Link a collection with a agent. The API Key used must be added to both the collection and the agent beforehand.
|
|
338
344
|
*
|
|
339
345
|
* @param {Credal.AddCollectionToCopilotRequest} request
|
|
340
|
-
* @param {
|
|
346
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
341
347
|
*
|
|
342
348
|
* @example
|
|
343
349
|
* await client.copilots.addCollectionToCopilot({
|
|
@@ -351,7 +357,8 @@ export class Copilots {
|
|
|
351
357
|
__addCollectionToCopilot(request, requestOptions) {
|
|
352
358
|
return __awaiter(this, void 0, void 0, function* () {
|
|
353
359
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
354
|
-
const
|
|
360
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
361
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
355
362
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
356
363
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/addCollectionToCopilot"),
|
|
357
364
|
method: "POST",
|
|
@@ -397,7 +404,7 @@ export class Copilots {
|
|
|
397
404
|
* Unlink a collection with a agent. The API Key used must be added to both the collection and the agent beforehand.
|
|
398
405
|
*
|
|
399
406
|
* @param {Credal.RemoveCollectionFromCopilotRequest} request
|
|
400
|
-
* @param {
|
|
407
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
401
408
|
*
|
|
402
409
|
* @example
|
|
403
410
|
* await client.copilots.removeCollectionFromCopilot({
|
|
@@ -411,7 +418,8 @@ export class Copilots {
|
|
|
411
418
|
__removeCollectionFromCopilot(request, requestOptions) {
|
|
412
419
|
return __awaiter(this, void 0, void 0, function* () {
|
|
413
420
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
414
|
-
const
|
|
421
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
422
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
415
423
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
416
424
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/removeCollectionFromCopilot"),
|
|
417
425
|
method: "POST",
|
|
@@ -457,7 +465,7 @@ export class Copilots {
|
|
|
457
465
|
* Update the configuration for a agent
|
|
458
466
|
*
|
|
459
467
|
* @param {Credal.UpdateConfigurationRequest} request
|
|
460
|
-
* @param {
|
|
468
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
461
469
|
*
|
|
462
470
|
* @example
|
|
463
471
|
* await client.copilots.updateConfiguration({
|
|
@@ -479,7 +487,8 @@ export class Copilots {
|
|
|
479
487
|
__updateConfiguration(request, requestOptions) {
|
|
480
488
|
return __awaiter(this, void 0, void 0, function* () {
|
|
481
489
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
482
|
-
const
|
|
490
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
491
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
483
492
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
484
493
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/updateConfiguration"),
|
|
485
494
|
method: "POST",
|
|
@@ -523,7 +532,7 @@ export class Copilots {
|
|
|
523
532
|
}
|
|
524
533
|
/**
|
|
525
534
|
* @param {Credal.DeleteCopilotRequest} request
|
|
526
|
-
* @param {
|
|
535
|
+
* @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
527
536
|
*
|
|
528
537
|
* @example
|
|
529
538
|
* await client.copilots.deleteCopilot({
|
|
@@ -536,7 +545,8 @@ export class Copilots {
|
|
|
536
545
|
__deleteCopilot(request, requestOptions) {
|
|
537
546
|
return __awaiter(this, void 0, void 0, function* () {
|
|
538
547
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
539
|
-
const
|
|
548
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
549
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
540
550
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
541
551
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/deleteCopilot"),
|
|
542
552
|
method: "DELETE",
|
|
@@ -578,16 +588,4 @@ export class Copilots {
|
|
|
578
588
|
}
|
|
579
589
|
});
|
|
580
590
|
}
|
|
581
|
-
_getAuthorizationHeader() {
|
|
582
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
583
|
-
var _a;
|
|
584
|
-
const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env.CREDAL_API_KEY;
|
|
585
|
-
if (bearer == null) {
|
|
586
|
-
throw new errors.CredalError({
|
|
587
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
588
|
-
});
|
|
589
|
-
}
|
|
590
|
-
return `Bearer ${bearer}`;
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
591
|
}
|