vellum-ai 0.0.10 → 0.0.11
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/Client.d.ts +36 -0
- package/Client.js +102 -12
- package/api/client/requests/index.d.ts +0 -1
- package/api/errors/BadRequestError.d.ts +7 -0
- package/api/errors/BadRequestError.js +41 -0
- package/api/errors/InternalServerError.d.ts +7 -0
- package/api/errors/InternalServerError.js +41 -0
- package/api/errors/NotFoundError.d.ts +7 -0
- package/api/errors/NotFoundError.js +41 -0
- package/api/errors/index.d.ts +3 -0
- package/api/errors/index.js +19 -0
- package/api/index.d.ts +1 -0
- package/api/index.js +1 -0
- package/api/resources/documents/client/Client.d.ts +17 -0
- package/api/resources/documents/client/Client.js +31 -4
- package/api/resources/documents/client/requests/DocumentsListRequest.d.ts +12 -0
- package/api/resources/modelVersions/client/Client.d.ts +7 -0
- package/api/resources/modelVersions/client/Client.js +7 -0
- package/api/resources/sandboxes/client/Client.d.ts +11 -0
- package/api/resources/sandboxes/client/Client.js +11 -0
- package/api/resources/testSuites/client/Client.d.ts +11 -0
- package/api/resources/testSuites/client/Client.js +11 -0
- package/api/{client/requests → types}/GenerateBodyRequest.d.ts +1 -1
- package/api/types/GenerateStreamResponse.d.ts +7 -0
- package/api/types/GenerateStreamResult.d.ts +9 -0
- package/api/types/GenerateStreamResult.js +5 -0
- package/api/types/GenerateStreamResultData.d.ts +8 -0
- package/api/types/GenerateStreamResultData.js +5 -0
- package/api/types/index.d.ts +4 -0
- package/api/types/index.js +4 -0
- package/core/callback-queue/CallbackQueue.d.ts +6 -0
- package/core/callback-queue/CallbackQueue.js +20 -0
- package/core/callback-queue/index.d.ts +1 -0
- package/core/callback-queue/index.js +5 -0
- package/core/index.d.ts +2 -0
- package/core/index.js +2 -0
- package/core/streaming-fetcher/StreamingFetcher.d.ts +22 -0
- package/core/streaming-fetcher/StreamingFetcher.js +64 -0
- package/core/streaming-fetcher/index.d.ts +1 -0
- package/core/streaming-fetcher/index.js +5 -0
- package/dist/Client.d.ts +36 -0
- package/dist/Client.js +102 -12
- package/dist/api/client/requests/index.d.ts +0 -1
- package/dist/api/errors/BadRequestError.d.ts +7 -0
- package/dist/api/errors/BadRequestError.js +41 -0
- package/dist/api/errors/InternalServerError.d.ts +7 -0
- package/dist/api/errors/InternalServerError.js +41 -0
- package/dist/api/errors/NotFoundError.d.ts +7 -0
- package/dist/api/errors/NotFoundError.js +41 -0
- package/dist/api/errors/index.d.ts +3 -0
- package/dist/api/errors/index.js +19 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/resources/documents/client/Client.d.ts +17 -0
- package/dist/api/resources/documents/client/Client.js +31 -4
- package/dist/api/resources/documents/client/requests/DocumentsListRequest.d.ts +12 -0
- package/dist/api/resources/modelVersions/client/Client.d.ts +7 -0
- package/dist/api/resources/modelVersions/client/Client.js +7 -0
- package/dist/api/resources/sandboxes/client/Client.d.ts +11 -0
- package/dist/api/resources/sandboxes/client/Client.js +11 -0
- package/dist/api/resources/testSuites/client/Client.d.ts +11 -0
- package/dist/api/resources/testSuites/client/Client.js +11 -0
- package/dist/api/{client/requests → types}/GenerateBodyRequest.d.ts +1 -1
- package/dist/api/types/GenerateBodyRequest.js +5 -0
- package/dist/api/types/GenerateStreamResponse.d.ts +7 -0
- package/dist/api/types/GenerateStreamResponse.js +5 -0
- package/dist/api/types/GenerateStreamResult.d.ts +9 -0
- package/dist/api/types/GenerateStreamResult.js +5 -0
- package/dist/api/types/GenerateStreamResultData.d.ts +8 -0
- package/dist/api/types/GenerateStreamResultData.js +5 -0
- package/dist/api/types/index.d.ts +4 -0
- package/dist/api/types/index.js +4 -0
- package/dist/core/callback-queue/CallbackQueue.d.ts +6 -0
- package/dist/core/callback-queue/CallbackQueue.js +20 -0
- package/dist/core/callback-queue/index.d.ts +1 -0
- package/dist/core/callback-queue/index.js +5 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +2 -0
- package/dist/core/streaming-fetcher/StreamingFetcher.d.ts +22 -0
- package/dist/core/streaming-fetcher/StreamingFetcher.js +64 -0
- package/dist/core/streaming-fetcher/index.d.ts +1 -0
- package/dist/core/streaming-fetcher/index.js +5 -0
- package/dist/serialization/client/requests/index.d.ts +0 -1
- package/dist/serialization/client/requests/index.js +1 -3
- package/dist/serialization/{client/requests → types}/GenerateBodyRequest.d.ts +4 -4
- package/dist/serialization/{client/requests → types}/GenerateBodyRequest.js +3 -3
- package/dist/serialization/types/GenerateStreamResponse.d.ts +12 -0
- package/dist/serialization/types/GenerateStreamResponse.js +33 -0
- package/dist/serialization/types/GenerateStreamResult.d.ts +14 -0
- package/dist/serialization/types/GenerateStreamResult.js +35 -0
- package/dist/serialization/types/GenerateStreamResultData.d.ts +13 -0
- package/dist/serialization/types/GenerateStreamResultData.js +34 -0
- package/dist/serialization/types/index.d.ts +4 -0
- package/dist/serialization/types/index.js +4 -0
- package/package.json +1 -1
- package/serialization/client/requests/index.d.ts +0 -1
- package/serialization/client/requests/index.js +1 -3
- package/serialization/{client/requests → types}/GenerateBodyRequest.d.ts +4 -4
- package/serialization/{client/requests → types}/GenerateBodyRequest.js +3 -3
- package/serialization/types/GenerateStreamResponse.d.ts +12 -0
- package/serialization/types/GenerateStreamResponse.js +33 -0
- package/serialization/types/GenerateStreamResult.d.ts +14 -0
- package/serialization/types/GenerateStreamResult.js +35 -0
- package/serialization/types/GenerateStreamResultData.d.ts +13 -0
- package/serialization/types/GenerateStreamResultData.js +34 -0
- package/serialization/types/index.d.ts +4 -0
- package/serialization/types/index.js +4 -0
- /package/api/{client/requests → types}/GenerateBodyRequest.js +0 -0
- /package/{dist/api/client/requests/GenerateBodyRequest.js → api/types/GenerateStreamResponse.js} +0 -0
package/api/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./GenerateBodyRequest";
|
|
1
2
|
export * from "./BlockTypeEnum";
|
|
2
3
|
export * from "./ChatMessage";
|
|
3
4
|
export * from "./ChatMessageRequest";
|
|
@@ -15,6 +16,9 @@ export * from "./GenerateResponse";
|
|
|
15
16
|
export * from "./GenerateResult";
|
|
16
17
|
export * from "./GenerateResultData";
|
|
17
18
|
export * from "./GenerateResultError";
|
|
19
|
+
export * from "./GenerateStreamResponse";
|
|
20
|
+
export * from "./GenerateStreamResult";
|
|
21
|
+
export * from "./GenerateStreamResultData";
|
|
18
22
|
export * from "./IndexingStateEnum";
|
|
19
23
|
export * from "./LogprobsEnum";
|
|
20
24
|
export * from "./ModelTypeEnum";
|
package/api/types/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./GenerateBodyRequest"), exports);
|
|
17
18
|
__exportStar(require("./BlockTypeEnum"), exports);
|
|
18
19
|
__exportStar(require("./ChatMessage"), exports);
|
|
19
20
|
__exportStar(require("./ChatMessageRequest"), exports);
|
|
@@ -31,6 +32,9 @@ __exportStar(require("./GenerateResponse"), exports);
|
|
|
31
32
|
__exportStar(require("./GenerateResult"), exports);
|
|
32
33
|
__exportStar(require("./GenerateResultData"), exports);
|
|
33
34
|
__exportStar(require("./GenerateResultError"), exports);
|
|
35
|
+
__exportStar(require("./GenerateStreamResponse"), exports);
|
|
36
|
+
__exportStar(require("./GenerateStreamResult"), exports);
|
|
37
|
+
__exportStar(require("./GenerateStreamResultData"), exports);
|
|
34
38
|
__exportStar(require("./IndexingStateEnum"), exports);
|
|
35
39
|
__exportStar(require("./LogprobsEnum"), exports);
|
|
36
40
|
__exportStar(require("./ModelTypeEnum"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CallbackQueue = void 0;
|
|
4
|
+
class CallbackQueue {
|
|
5
|
+
queue = Promise.resolve();
|
|
6
|
+
wrap(callback) {
|
|
7
|
+
if (callback == null) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
return (...args) => {
|
|
11
|
+
this.queue = this.queue.then(() => {
|
|
12
|
+
return callback(...args);
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
toPromise() {
|
|
17
|
+
return this.queue;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.CallbackQueue = CallbackQueue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CallbackQueue } from "./CallbackQueue";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CallbackQueue = void 0;
|
|
4
|
+
var CallbackQueue_1 = require("./CallbackQueue");
|
|
5
|
+
Object.defineProperty(exports, "CallbackQueue", { enumerable: true, get: function () { return CallbackQueue_1.CallbackQueue; } });
|
package/core/index.d.ts
CHANGED
package/core/index.js
CHANGED
|
@@ -29,4 +29,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.serialization = void 0;
|
|
30
30
|
exports.serialization = __importStar(require("./schemas"));
|
|
31
31
|
__exportStar(require("./fetcher"), exports);
|
|
32
|
+
__exportStar(require("./streaming-fetcher"), exports);
|
|
33
|
+
__exportStar(require("./callback-queue"), exports);
|
|
32
34
|
__exportStar(require("./form-data-utils"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import URLSearchParams from "@ungap/url-search-params";
|
|
2
|
+
import { AxiosAdapter } from "axios";
|
|
3
|
+
export declare type StreamingFetchFunction = (args: StreamingFetcher.Args) => Promise<void>;
|
|
4
|
+
export declare namespace StreamingFetcher {
|
|
5
|
+
interface Args {
|
|
6
|
+
url: string;
|
|
7
|
+
method: string;
|
|
8
|
+
headers?: Record<string, string | undefined>;
|
|
9
|
+
queryParameters?: URLSearchParams;
|
|
10
|
+
body?: unknown;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
withCredentials?: boolean;
|
|
13
|
+
adapter?: AxiosAdapter;
|
|
14
|
+
onData: (data: unknown) => void;
|
|
15
|
+
onError?: (err: unknown) => void;
|
|
16
|
+
onFinish?: () => void;
|
|
17
|
+
abortController?: AbortController;
|
|
18
|
+
responseChunkPrefix?: string;
|
|
19
|
+
terminator?: string;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export declare const streamingFetcher: StreamingFetchFunction;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.streamingFetcher = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const streamingFetcher = async (args) => {
|
|
9
|
+
const headers = {};
|
|
10
|
+
if (args.body !== undefined) {
|
|
11
|
+
headers["Content-Type"] = "application/json";
|
|
12
|
+
}
|
|
13
|
+
if (args.headers != null) {
|
|
14
|
+
for (const [key, value] of Object.entries(args.headers)) {
|
|
15
|
+
if (value != null) {
|
|
16
|
+
headers[key] = value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
let response;
|
|
21
|
+
try {
|
|
22
|
+
response = await (0, axios_1.default)({
|
|
23
|
+
url: args.url,
|
|
24
|
+
params: args.queryParameters,
|
|
25
|
+
method: args.method,
|
|
26
|
+
headers,
|
|
27
|
+
data: args.body,
|
|
28
|
+
timeout: args.timeoutMs,
|
|
29
|
+
transitional: {
|
|
30
|
+
clarifyTimeoutError: true,
|
|
31
|
+
},
|
|
32
|
+
withCredentials: args.withCredentials,
|
|
33
|
+
signal: args.abortController?.signal,
|
|
34
|
+
responseType: "stream",
|
|
35
|
+
adapter: args.adapter,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
args.onError?.(error);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
response.data.on("data", (data) => {
|
|
43
|
+
for (const line of data.toString().split("\n")) {
|
|
44
|
+
let data = line;
|
|
45
|
+
if (args.responseChunkPrefix != null) {
|
|
46
|
+
if (!data.startsWith(args.responseChunkPrefix)) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
data = data.substring(args.responseChunkPrefix.length);
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const parsed = JSON.parse(data);
|
|
53
|
+
args.onData(parsed);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
args.onError?.(error);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (args.onFinish != null) {
|
|
61
|
+
response.data.on("end", args.onFinish);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.streamingFetcher = streamingFetcher;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { streamingFetcher, type StreamingFetcher, type StreamingFetchFunction } from "./StreamingFetcher";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.streamingFetcher = void 0;
|
|
4
|
+
var StreamingFetcher_1 = require("./StreamingFetcher");
|
|
5
|
+
Object.defineProperty(exports, "streamingFetcher", { enumerable: true, get: function () { return StreamingFetcher_1.streamingFetcher; } });
|
package/dist/Client.d.ts
CHANGED
|
@@ -17,8 +17,44 @@ export declare namespace VellumClient {
|
|
|
17
17
|
export declare class VellumClient {
|
|
18
18
|
protected readonly options: VellumClient.Options;
|
|
19
19
|
constructor(options: VellumClient.Options);
|
|
20
|
+
/**
|
|
21
|
+
* <strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
|
22
|
+
*
|
|
23
|
+
* Generate a completion using a previously defined deployment.
|
|
24
|
+
*
|
|
25
|
+
* **Note:** Uses a base url of `https://predict.vellum.ai`.
|
|
26
|
+
* @throws {Vellum.BadRequestError}
|
|
27
|
+
* @throws {Vellum.NotFoundError}
|
|
28
|
+
* @throws {Vellum.InternalServerError}
|
|
29
|
+
*/
|
|
20
30
|
generate(request: Vellum.GenerateBodyRequest): Promise<Vellum.GenerateResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* @throws {Vellum.BadRequestError}
|
|
33
|
+
* @throws {Vellum.NotFoundError}
|
|
34
|
+
* @throws {Vellum.InternalServerError}
|
|
35
|
+
*/
|
|
36
|
+
generateStream(request: Vellum.GenerateBodyRequest, cb: (data: Vellum.GenerateStreamResponse) => void, opts?: Pick<core.StreamingFetcher.Args, "onError" | "onFinish" | "abortController" | "timeoutMs">): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* <strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
|
39
|
+
*
|
|
40
|
+
* Perform a search against a document index.
|
|
41
|
+
*
|
|
42
|
+
* **Note:** Uses a base url of `https://predict.vellum.ai`.
|
|
43
|
+
* @throws {Vellum.BadRequestError}
|
|
44
|
+
* @throws {Vellum.NotFoundError}
|
|
45
|
+
* @throws {Vellum.InternalServerError}
|
|
46
|
+
*/
|
|
21
47
|
search(request: Vellum.SearchRequestBodyRequest): Promise<Vellum.SearchResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* <strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
|
50
|
+
*
|
|
51
|
+
* Used to submit feedback regarding the quality of previously generated completions.
|
|
52
|
+
*
|
|
53
|
+
* **Note:** Uses a base url of `https://predict.vellum.ai`.
|
|
54
|
+
* @throws {Vellum.BadRequestError}
|
|
55
|
+
* @throws {Vellum.NotFoundError}
|
|
56
|
+
* @throws {Vellum.InternalServerError}
|
|
57
|
+
*/
|
|
22
58
|
submitCompletionActuals(request: Vellum.SubmitCompletionActualsRequest): Promise<void>;
|
|
23
59
|
protected _documents: Documents | undefined;
|
|
24
60
|
get documents(): Documents;
|
package/dist/Client.js
CHANGED
|
@@ -32,6 +32,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
32
32
|
exports.VellumClient = void 0;
|
|
33
33
|
const environments = __importStar(require("./environments"));
|
|
34
34
|
const core = __importStar(require("./core"));
|
|
35
|
+
const Vellum = __importStar(require("./api"));
|
|
35
36
|
const url_join_1 = __importDefault(require("url-join"));
|
|
36
37
|
const serializers = __importStar(require("./serialization"));
|
|
37
38
|
const errors = __importStar(require("./errors"));
|
|
@@ -44,6 +45,16 @@ class VellumClient {
|
|
|
44
45
|
constructor(options) {
|
|
45
46
|
this.options = options;
|
|
46
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* <strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
|
50
|
+
*
|
|
51
|
+
* Generate a completion using a previously defined deployment.
|
|
52
|
+
*
|
|
53
|
+
* **Note:** Uses a base url of `https://predict.vellum.ai`.
|
|
54
|
+
* @throws {Vellum.BadRequestError}
|
|
55
|
+
* @throws {Vellum.NotFoundError}
|
|
56
|
+
* @throws {Vellum.InternalServerError}
|
|
57
|
+
*/
|
|
47
58
|
async generate(request) {
|
|
48
59
|
const _response = await core.fetcher({
|
|
49
60
|
url: (0, url_join_1.default)((this.options.environment ?? environments.VellumEnvironment.Production).predict, "v1/generate"),
|
|
@@ -62,10 +73,19 @@ class VellumClient {
|
|
|
62
73
|
});
|
|
63
74
|
}
|
|
64
75
|
if (_response.error.reason === "status-code") {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
switch (_response.error.statusCode) {
|
|
77
|
+
case 400:
|
|
78
|
+
throw new Vellum.BadRequestError(_response.error.body);
|
|
79
|
+
case 404:
|
|
80
|
+
throw new Vellum.NotFoundError(_response.error.body);
|
|
81
|
+
case 500:
|
|
82
|
+
throw new Vellum.InternalServerError(_response.error.body);
|
|
83
|
+
default:
|
|
84
|
+
throw new errors.VellumError({
|
|
85
|
+
statusCode: _response.error.statusCode,
|
|
86
|
+
body: _response.error.body,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
69
89
|
}
|
|
70
90
|
switch (_response.error.reason) {
|
|
71
91
|
case "non-json":
|
|
@@ -81,6 +101,48 @@ class VellumClient {
|
|
|
81
101
|
});
|
|
82
102
|
}
|
|
83
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* @throws {Vellum.BadRequestError}
|
|
106
|
+
* @throws {Vellum.NotFoundError}
|
|
107
|
+
* @throws {Vellum.InternalServerError}
|
|
108
|
+
*/
|
|
109
|
+
async generateStream(request, cb, opts) {
|
|
110
|
+
const _queue = new core.CallbackQueue();
|
|
111
|
+
await core.streamingFetcher({
|
|
112
|
+
url: (0, url_join_1.default)((this.options.environment ?? environments.VellumEnvironment.Production).default, "v1/generate-stream"),
|
|
113
|
+
method: "POST",
|
|
114
|
+
headers: {
|
|
115
|
+
X_API_KEY: await core.Supplier.get(this.options.apiKey),
|
|
116
|
+
},
|
|
117
|
+
body: await serializers.GenerateBodyRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
118
|
+
onData: _queue.wrap(async (data) => {
|
|
119
|
+
const parsed = await serializers.GenerateStreamResponse.parse(data, {
|
|
120
|
+
unrecognizedObjectKeys: "passthrough",
|
|
121
|
+
allowUnrecognizedUnionMembers: true,
|
|
122
|
+
allowUnrecognizedEnumValues: true,
|
|
123
|
+
});
|
|
124
|
+
if (parsed.ok) {
|
|
125
|
+
cb(parsed.value);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
opts?.onError?.(parsed.errors);
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
onError: opts?.onError != null ? _queue.wrap(opts.onError) : undefined,
|
|
132
|
+
onFinish: opts?.onFinish != null ? _queue.wrap(opts.onFinish) : undefined,
|
|
133
|
+
abortController: opts?.abortController,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* <strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
|
138
|
+
*
|
|
139
|
+
* Perform a search against a document index.
|
|
140
|
+
*
|
|
141
|
+
* **Note:** Uses a base url of `https://predict.vellum.ai`.
|
|
142
|
+
* @throws {Vellum.BadRequestError}
|
|
143
|
+
* @throws {Vellum.NotFoundError}
|
|
144
|
+
* @throws {Vellum.InternalServerError}
|
|
145
|
+
*/
|
|
84
146
|
async search(request) {
|
|
85
147
|
const _response = await core.fetcher({
|
|
86
148
|
url: (0, url_join_1.default)((this.options.environment ?? environments.VellumEnvironment.Production).predict, "v1/search"),
|
|
@@ -99,10 +161,19 @@ class VellumClient {
|
|
|
99
161
|
});
|
|
100
162
|
}
|
|
101
163
|
if (_response.error.reason === "status-code") {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
164
|
+
switch (_response.error.statusCode) {
|
|
165
|
+
case 400:
|
|
166
|
+
throw new Vellum.BadRequestError(_response.error.body);
|
|
167
|
+
case 404:
|
|
168
|
+
throw new Vellum.NotFoundError(_response.error.body);
|
|
169
|
+
case 500:
|
|
170
|
+
throw new Vellum.InternalServerError(_response.error.body);
|
|
171
|
+
default:
|
|
172
|
+
throw new errors.VellumError({
|
|
173
|
+
statusCode: _response.error.statusCode,
|
|
174
|
+
body: _response.error.body,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
106
177
|
}
|
|
107
178
|
switch (_response.error.reason) {
|
|
108
179
|
case "non-json":
|
|
@@ -118,6 +189,16 @@ class VellumClient {
|
|
|
118
189
|
});
|
|
119
190
|
}
|
|
120
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* <strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
|
194
|
+
*
|
|
195
|
+
* Used to submit feedback regarding the quality of previously generated completions.
|
|
196
|
+
*
|
|
197
|
+
* **Note:** Uses a base url of `https://predict.vellum.ai`.
|
|
198
|
+
* @throws {Vellum.BadRequestError}
|
|
199
|
+
* @throws {Vellum.NotFoundError}
|
|
200
|
+
* @throws {Vellum.InternalServerError}
|
|
201
|
+
*/
|
|
121
202
|
async submitCompletionActuals(request) {
|
|
122
203
|
const _response = await core.fetcher({
|
|
123
204
|
url: (0, url_join_1.default)((this.options.environment ?? environments.VellumEnvironment.Production).predict, "v1/submit-completion-actuals"),
|
|
@@ -134,10 +215,19 @@ class VellumClient {
|
|
|
134
215
|
return;
|
|
135
216
|
}
|
|
136
217
|
if (_response.error.reason === "status-code") {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
218
|
+
switch (_response.error.statusCode) {
|
|
219
|
+
case 400:
|
|
220
|
+
throw new Vellum.BadRequestError(_response.error.body);
|
|
221
|
+
case 404:
|
|
222
|
+
throw new Vellum.NotFoundError(_response.error.body);
|
|
223
|
+
case 500:
|
|
224
|
+
throw new Vellum.InternalServerError(_response.error.body);
|
|
225
|
+
default:
|
|
226
|
+
throw new errors.VellumError({
|
|
227
|
+
statusCode: _response.error.statusCode,
|
|
228
|
+
body: _response.error.body,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
141
231
|
}
|
|
142
232
|
switch (_response.error.reason) {
|
|
143
233
|
case "non-json":
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.BadRequestError = void 0;
|
|
30
|
+
const errors = __importStar(require("../../errors"));
|
|
31
|
+
class BadRequestError extends errors.VellumError {
|
|
32
|
+
constructor(body) {
|
|
33
|
+
super({
|
|
34
|
+
message: "BadRequestError",
|
|
35
|
+
statusCode: 400,
|
|
36
|
+
body: body,
|
|
37
|
+
});
|
|
38
|
+
Object.setPrototypeOf(this, BadRequestError.prototype);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.BadRequestError = BadRequestError;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.InternalServerError = void 0;
|
|
30
|
+
const errors = __importStar(require("../../errors"));
|
|
31
|
+
class InternalServerError extends errors.VellumError {
|
|
32
|
+
constructor(body) {
|
|
33
|
+
super({
|
|
34
|
+
message: "InternalServerError",
|
|
35
|
+
statusCode: 500,
|
|
36
|
+
body: body,
|
|
37
|
+
});
|
|
38
|
+
Object.setPrototypeOf(this, InternalServerError.prototype);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.InternalServerError = InternalServerError;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.NotFoundError = void 0;
|
|
30
|
+
const errors = __importStar(require("../../errors"));
|
|
31
|
+
class NotFoundError extends errors.VellumError {
|
|
32
|
+
constructor(body) {
|
|
33
|
+
super({
|
|
34
|
+
message: "NotFoundError",
|
|
35
|
+
statusCode: 404,
|
|
36
|
+
body: body,
|
|
37
|
+
});
|
|
38
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.NotFoundError = NotFoundError;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./BadRequestError"), exports);
|
|
18
|
+
__exportStar(require("./NotFoundError"), exports);
|
|
19
|
+
__exportStar(require("./InternalServerError"), exports);
|
package/dist/api/index.d.ts
CHANGED
package/dist/api/index.js
CHANGED
|
@@ -15,5 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./errors"), exports);
|
|
18
19
|
__exportStar(require("./resources"), exports);
|
|
19
20
|
__exportStar(require("./client"), exports);
|
|
@@ -15,6 +15,23 @@ export declare namespace Documents {
|
|
|
15
15
|
export declare class Documents {
|
|
16
16
|
protected readonly options: Documents.Options;
|
|
17
17
|
constructor(options: Documents.Options);
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* <strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
|
21
|
+
*
|
|
22
|
+
* Used to list documents. Optionally filter on supported fields.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
18
25
|
list(request?: Vellum.DocumentsListRequest): Promise<Vellum.PaginatedSlimDocumentList>;
|
|
26
|
+
/**
|
|
27
|
+
* <strong style="background-color:#4caf50; color:white; padding:4px; border-radius:4px">Stable</strong>
|
|
28
|
+
*
|
|
29
|
+
* Upload a document to be indexed and used for search.
|
|
30
|
+
*
|
|
31
|
+
* **Note:** Uses a base url of `https://documents.vellum.ai`.
|
|
32
|
+
* @throws {Vellum.BadRequestError}
|
|
33
|
+
* @throws {Vellum.NotFoundError}
|
|
34
|
+
* @throws {Vellum.InternalServerError}
|
|
35
|
+
*/
|
|
19
36
|
upload(contents: File | fs.ReadStream, request: Vellum.UploadDocumentBodyRequest): Promise<Vellum.UploadDocumentResponse>;
|
|
20
37
|
}
|