sarvamai 0.0.3 → 0.0.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/Client.d.ts +1 -10
- package/Client.js +4 -14
- package/api/resources/index.d.ts +0 -4
- package/api/resources/index.js +1 -5
- package/api/resources/speechToText/client/Client.d.ts +4 -4
- package/api/resources/speechToText/client/Client.js +9 -6
- package/api/resources/text/client/Client.d.ts +4 -4
- package/api/resources/text/client/Client.js +10 -9
- package/api/resources/textToSpeech/client/Client.d.ts +5 -5
- package/api/resources/textToSpeech/client/Client.js +9 -4
- package/api/resources/textToSpeech/client/requests/TextToSpeechRequest.d.ts +33 -11
- package/api/types/ErrorCode.d.ts +3 -5
- package/api/types/ErrorCode.js +2 -4
- package/api/types/TextToSpeechLanguage.d.ts +4 -4
- package/api/types/TextToSpeechLanguage.js +3 -3
- package/api/types/TextToSpeechModel.d.ts +5 -1
- package/api/types/TextToSpeechModel.js +5 -0
- package/api/types/TextToSpeechSpeaker.d.ts +8 -1
- package/api/types/TextToSpeechSpeaker.js +7 -0
- package/api/types/index.d.ts +0 -13
- package/api/types/index.js +0 -13
- package/dist/Client.d.ts +1 -10
- package/dist/Client.js +4 -14
- package/dist/api/resources/index.d.ts +0 -4
- package/dist/api/resources/index.js +1 -5
- package/dist/api/resources/speechToText/client/Client.d.ts +4 -4
- package/dist/api/resources/speechToText/client/Client.js +9 -6
- package/dist/api/resources/text/client/Client.d.ts +4 -4
- package/dist/api/resources/text/client/Client.js +10 -9
- package/dist/api/resources/textToSpeech/client/Client.d.ts +5 -5
- package/dist/api/resources/textToSpeech/client/Client.js +9 -4
- package/dist/api/resources/textToSpeech/client/requests/TextToSpeechRequest.d.ts +33 -11
- package/dist/api/types/ErrorCode.d.ts +3 -5
- package/dist/api/types/ErrorCode.js +2 -4
- package/dist/api/types/TextToSpeechLanguage.d.ts +4 -4
- package/dist/api/types/TextToSpeechLanguage.js +3 -3
- package/dist/api/types/TextToSpeechModel.d.ts +5 -1
- package/dist/api/types/TextToSpeechModel.js +5 -0
- package/dist/api/types/TextToSpeechSpeaker.d.ts +8 -1
- package/dist/api/types/TextToSpeechSpeaker.js +7 -0
- package/dist/api/types/index.d.ts +0 -13
- package/dist/api/types/index.js +0 -13
- package/dist/environments.d.ts +1 -2
- package/dist/environments.js +0 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/environments.d.ts +1 -2
- package/environments.js +0 -1
- package/package.json +1 -1
- package/reference.md +1 -286
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/api/resources/analytics/client/Client.d.ts +0 -73
- package/api/resources/analytics/client/Client.js +0 -223
- package/api/resources/analytics/client/index.d.ts +0 -1
- package/api/resources/analytics/client/index.js +0 -17
- package/api/resources/analytics/client/requests/CallAnalyticsRequest.d.ts +0 -24
- package/api/resources/analytics/client/requests/CallAnalyticsRequest.js +0 -5
- package/api/resources/analytics/client/requests/index.d.ts +0 -1
- package/api/resources/analytics/client/requests/index.js +0 -2
- package/api/resources/analytics/index.d.ts +0 -1
- package/api/resources/analytics/index.js +0 -17
- package/api/resources/pdf/client/Client.d.ts +0 -63
- package/api/resources/pdf/client/Client.js +0 -215
- package/api/resources/pdf/client/index.d.ts +0 -1
- package/api/resources/pdf/client/index.js +0 -17
- package/api/resources/pdf/client/requests/ParsePdfRequest.d.ts +0 -21
- package/api/resources/pdf/client/requests/ParsePdfRequest.js +0 -5
- package/api/resources/pdf/client/requests/TranslatePdfRequest.d.ts +0 -32
- package/api/resources/pdf/client/requests/TranslatePdfRequest.js +0 -5
- package/api/resources/pdf/client/requests/index.d.ts +0 -2
- package/api/resources/pdf/client/requests/index.js +0 -2
- package/api/resources/pdf/index.d.ts +0 -1
- package/api/resources/pdf/index.js +0 -17
- package/api/types/CallAnalyticsJobParameters.d.ts +0 -21
- package/api/types/CallAnalyticsJobParameters.js +0 -5
- package/api/types/CallAnalyticsJobRequest.d.ts +0 -10
- package/api/types/CallAnalyticsJobRequest.js +0 -5
- package/api/types/CallAnalyticsResponse.d.ts +0 -19
- package/api/types/CallAnalyticsResponse.js +0 -5
- package/api/types/Language.d.ts +0 -17
- package/api/types/Language.js +0 -19
- package/api/types/ParsedPageResponse.d.ts +0 -7
- package/api/types/ParsedPageResponse.js +0 -5
- package/api/types/PromptCaching.d.ts +0 -8
- package/api/types/PromptCaching.js +0 -10
- package/api/types/QnaResponse.d.ts +0 -15
- package/api/types/QnaResponse.js +0 -5
- package/api/types/Question.d.ts +0 -23
- package/api/types/Question.js +0 -5
- package/api/types/QuestionType.d.ts +0 -11
- package/api/types/QuestionType.js +0 -13
- package/api/types/SarvamMode.d.ts +0 -8
- package/api/types/SarvamMode.js +0 -10
- package/api/types/TextAnalyticsRequest.d.ts +0 -9
- package/api/types/TextAnalyticsRequest.js +0 -5
- package/api/types/TextAnalyticsResponse.d.ts +0 -9
- package/api/types/TextAnalyticsResponse.js +0 -5
- package/api/types/TranslatedPage.d.ts +0 -7
- package/api/types/TranslatedPage.js +0 -5
- package/dist/api/resources/analytics/client/Client.d.ts +0 -73
- package/dist/api/resources/analytics/client/Client.js +0 -223
- package/dist/api/resources/analytics/client/index.d.ts +0 -1
- package/dist/api/resources/analytics/client/index.js +0 -17
- package/dist/api/resources/analytics/client/requests/CallAnalyticsRequest.d.ts +0 -24
- package/dist/api/resources/analytics/client/requests/CallAnalyticsRequest.js +0 -5
- package/dist/api/resources/analytics/client/requests/index.d.ts +0 -1
- package/dist/api/resources/analytics/client/requests/index.js +0 -2
- package/dist/api/resources/analytics/index.d.ts +0 -1
- package/dist/api/resources/analytics/index.js +0 -17
- package/dist/api/resources/pdf/client/Client.d.ts +0 -63
- package/dist/api/resources/pdf/client/Client.js +0 -215
- package/dist/api/resources/pdf/client/index.d.ts +0 -1
- package/dist/api/resources/pdf/client/index.js +0 -17
- package/dist/api/resources/pdf/client/requests/ParsePdfRequest.d.ts +0 -21
- package/dist/api/resources/pdf/client/requests/ParsePdfRequest.js +0 -5
- package/dist/api/resources/pdf/client/requests/TranslatePdfRequest.d.ts +0 -32
- package/dist/api/resources/pdf/client/requests/TranslatePdfRequest.js +0 -5
- package/dist/api/resources/pdf/client/requests/index.d.ts +0 -2
- package/dist/api/resources/pdf/client/requests/index.js +0 -2
- package/dist/api/resources/pdf/index.d.ts +0 -1
- package/dist/api/resources/pdf/index.js +0 -17
- package/dist/api/types/CallAnalyticsJobParameters.d.ts +0 -21
- package/dist/api/types/CallAnalyticsJobParameters.js +0 -5
- package/dist/api/types/CallAnalyticsJobRequest.d.ts +0 -10
- package/dist/api/types/CallAnalyticsJobRequest.js +0 -5
- package/dist/api/types/CallAnalyticsResponse.d.ts +0 -19
- package/dist/api/types/CallAnalyticsResponse.js +0 -5
- package/dist/api/types/Language.d.ts +0 -17
- package/dist/api/types/Language.js +0 -19
- package/dist/api/types/ParsedPageResponse.d.ts +0 -7
- package/dist/api/types/ParsedPageResponse.js +0 -5
- package/dist/api/types/PromptCaching.d.ts +0 -8
- package/dist/api/types/PromptCaching.js +0 -10
- package/dist/api/types/QnaResponse.d.ts +0 -15
- package/dist/api/types/QnaResponse.js +0 -5
- package/dist/api/types/Question.d.ts +0 -23
- package/dist/api/types/Question.js +0 -5
- package/dist/api/types/QuestionType.d.ts +0 -11
- package/dist/api/types/QuestionType.js +0 -13
- package/dist/api/types/SarvamMode.d.ts +0 -8
- package/dist/api/types/SarvamMode.js +0 -10
- package/dist/api/types/TextAnalyticsRequest.d.ts +0 -9
- package/dist/api/types/TextAnalyticsRequest.js +0 -5
- package/dist/api/types/TextAnalyticsResponse.d.ts +0 -9
- package/dist/api/types/TextAnalyticsResponse.js +0 -5
- package/dist/api/types/TranslatedPage.d.ts +0 -7
- package/dist/api/types/TranslatedPage.js +0 -5
|
@@ -1,17 +0,0 @@
|
|
|
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("./client"), exports);
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
import * as environments from "../../../../environments";
|
|
5
|
-
import * as core from "../../../../core";
|
|
6
|
-
import * as SarvamAI from "../../../index";
|
|
7
|
-
import * as fs from "fs";
|
|
8
|
-
import { Blob } from "buffer";
|
|
9
|
-
export declare namespace Pdf {
|
|
10
|
-
interface Options {
|
|
11
|
-
environment?: core.Supplier<environments.SarvamAIEnvironment | string>;
|
|
12
|
-
/** Specify a custom URL to connect the client to. */
|
|
13
|
-
baseUrl?: core.Supplier<string>;
|
|
14
|
-
/** Override the api-subscription-key header */
|
|
15
|
-
apiSubscriptionKey?: core.Supplier<string | undefined>;
|
|
16
|
-
}
|
|
17
|
-
interface RequestOptions {
|
|
18
|
-
/** The maximum time to wait for a response in seconds. */
|
|
19
|
-
timeoutInSeconds?: number;
|
|
20
|
-
/** The number of times to retry the request. Defaults to 2. */
|
|
21
|
-
maxRetries?: number;
|
|
22
|
-
/** A hook to abort the request. */
|
|
23
|
-
abortSignal?: AbortSignal;
|
|
24
|
-
/** Override the api-subscription-key header */
|
|
25
|
-
apiSubscriptionKey?: string | undefined;
|
|
26
|
-
/** Additional headers to include in the request. */
|
|
27
|
-
headers?: Record<string, string>;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export declare class Pdf {
|
|
31
|
-
protected readonly _options: Pdf.Options;
|
|
32
|
-
constructor(_options?: Pdf.Options);
|
|
33
|
-
/**
|
|
34
|
-
* Given a PDF, this API helps to get structured extraction of data in the document.The API returns a base64 encoded XML string containing the extracted data.
|
|
35
|
-
*
|
|
36
|
-
* @param {File | fs.ReadStream | Blob} pdf
|
|
37
|
-
* @param {SarvamAI.ParsePdfRequest} request
|
|
38
|
-
* @param {Pdf.RequestOptions} requestOptions - Request-specific configuration.
|
|
39
|
-
*
|
|
40
|
-
* @throws {@link SarvamAI.BadRequestError}
|
|
41
|
-
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
42
|
-
* @throws {@link SarvamAI.InternalServerError}
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* await client.pdf.parse(fs.createReadStream("/path/to/your/file"), {})
|
|
46
|
-
*/
|
|
47
|
-
parse(pdf: File | fs.ReadStream | Blob, request: SarvamAI.ParsePdfRequest, requestOptions?: Pdf.RequestOptions): Promise<SarvamAI.ParsedPageResponse>;
|
|
48
|
-
/**
|
|
49
|
-
* Given a PDF, this API helps to translate the content in the document
|
|
50
|
-
*
|
|
51
|
-
* @param {File | fs.ReadStream | Blob} pdf
|
|
52
|
-
* @param {SarvamAI.TranslatePdfRequest} request
|
|
53
|
-
* @param {Pdf.RequestOptions} requestOptions - Request-specific configuration.
|
|
54
|
-
*
|
|
55
|
-
* @throws {@link SarvamAI.BadRequestError}
|
|
56
|
-
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
57
|
-
* @throws {@link SarvamAI.InternalServerError}
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* await client.pdf.translate(fs.createReadStream("/path/to/your/file"), {})
|
|
61
|
-
*/
|
|
62
|
-
translate(pdf: File | fs.ReadStream | Blob, request: SarvamAI.TranslatePdfRequest, requestOptions?: Pdf.RequestOptions): Promise<SarvamAI.TranslatedPage>;
|
|
63
|
-
}
|
|
@@ -1,215 +0,0 @@
|
|
|
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 () {
|
|
22
|
-
var ownKeys = function(o) {
|
|
23
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
-
var ar = [];
|
|
25
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
return ownKeys(o);
|
|
29
|
-
};
|
|
30
|
-
return function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
})();
|
|
38
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
39
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
40
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
41
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
42
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
43
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
44
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
-
};
|
|
50
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.Pdf = void 0;
|
|
52
|
-
const environments = __importStar(require("../../../../environments"));
|
|
53
|
-
const core = __importStar(require("../../../../core"));
|
|
54
|
-
const SarvamAI = __importStar(require("../../../index"));
|
|
55
|
-
const url_join_1 = __importDefault(require("url-join"));
|
|
56
|
-
const errors = __importStar(require("../../../../errors/index"));
|
|
57
|
-
class Pdf {
|
|
58
|
-
constructor(_options = {}) {
|
|
59
|
-
this._options = _options;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Given a PDF, this API helps to get structured extraction of data in the document.The API returns a base64 encoded XML string containing the extracted data.
|
|
63
|
-
*
|
|
64
|
-
* @param {File | fs.ReadStream | Blob} pdf
|
|
65
|
-
* @param {SarvamAI.ParsePdfRequest} request
|
|
66
|
-
* @param {Pdf.RequestOptions} requestOptions - Request-specific configuration.
|
|
67
|
-
*
|
|
68
|
-
* @throws {@link SarvamAI.BadRequestError}
|
|
69
|
-
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
70
|
-
* @throws {@link SarvamAI.InternalServerError}
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* await client.pdf.parse(fs.createReadStream("/path/to/your/file"), {})
|
|
74
|
-
*/
|
|
75
|
-
parse(pdf, request, requestOptions) {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
var _a, _b;
|
|
78
|
-
const _request = yield core.newFormData();
|
|
79
|
-
yield _request.appendFile("pdf", pdf);
|
|
80
|
-
if (request.page_number != null) {
|
|
81
|
-
_request.append("page_number", request.page_number);
|
|
82
|
-
}
|
|
83
|
-
if (request.sarvam_mode != null) {
|
|
84
|
-
_request.append("sarvam_mode", request.sarvam_mode);
|
|
85
|
-
}
|
|
86
|
-
if (request.prompt_caching != null) {
|
|
87
|
-
_request.append("prompt_caching", request.prompt_caching);
|
|
88
|
-
}
|
|
89
|
-
const _maybeEncodedRequest = yield _request.getRequest();
|
|
90
|
-
const _response = yield core.fetcher({
|
|
91
|
-
url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.SarvamAIEnvironment.Production, "parse/parsepdf"),
|
|
92
|
-
method: "POST",
|
|
93
|
-
headers: Object.assign(Object.assign({ "api-subscription-key": (yield core.Supplier.get(this._options.apiSubscriptionKey)) != null
|
|
94
|
-
? yield core.Supplier.get(this._options.apiSubscriptionKey)
|
|
95
|
-
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.0.3", "User-Agent": "sarvamai/0.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
96
|
-
requestType: "file",
|
|
97
|
-
duplex: _maybeEncodedRequest.duplex,
|
|
98
|
-
body: _maybeEncodedRequest.body,
|
|
99
|
-
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
100
|
-
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
101
|
-
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
102
|
-
});
|
|
103
|
-
if (_response.ok) {
|
|
104
|
-
return _response.body;
|
|
105
|
-
}
|
|
106
|
-
if (_response.error.reason === "status-code") {
|
|
107
|
-
switch (_response.error.statusCode) {
|
|
108
|
-
case 400:
|
|
109
|
-
throw new SarvamAI.BadRequestError(_response.error.body);
|
|
110
|
-
case 422:
|
|
111
|
-
throw new SarvamAI.UnprocessableEntityError(_response.error.body);
|
|
112
|
-
case 500:
|
|
113
|
-
throw new SarvamAI.InternalServerError(_response.error.body);
|
|
114
|
-
default:
|
|
115
|
-
throw new errors.SarvamAIError({
|
|
116
|
-
statusCode: _response.error.statusCode,
|
|
117
|
-
body: _response.error.body,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
switch (_response.error.reason) {
|
|
122
|
-
case "non-json":
|
|
123
|
-
throw new errors.SarvamAIError({
|
|
124
|
-
statusCode: _response.error.statusCode,
|
|
125
|
-
body: _response.error.rawBody,
|
|
126
|
-
});
|
|
127
|
-
case "timeout":
|
|
128
|
-
throw new errors.SarvamAITimeoutError("Timeout exceeded when calling POST /parse/parsepdf.");
|
|
129
|
-
case "unknown":
|
|
130
|
-
throw new errors.SarvamAIError({
|
|
131
|
-
message: _response.error.errorMessage,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Given a PDF, this API helps to translate the content in the document
|
|
138
|
-
*
|
|
139
|
-
* @param {File | fs.ReadStream | Blob} pdf
|
|
140
|
-
* @param {SarvamAI.TranslatePdfRequest} request
|
|
141
|
-
* @param {Pdf.RequestOptions} requestOptions - Request-specific configuration.
|
|
142
|
-
*
|
|
143
|
-
* @throws {@link SarvamAI.BadRequestError}
|
|
144
|
-
* @throws {@link SarvamAI.UnprocessableEntityError}
|
|
145
|
-
* @throws {@link SarvamAI.InternalServerError}
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* await client.pdf.translate(fs.createReadStream("/path/to/your/file"), {})
|
|
149
|
-
*/
|
|
150
|
-
translate(pdf, request, requestOptions) {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
var _a, _b;
|
|
153
|
-
const _request = yield core.newFormData();
|
|
154
|
-
yield _request.appendFile("pdf", pdf);
|
|
155
|
-
if (request.page_number != null) {
|
|
156
|
-
_request.append("page_number", request.page_number);
|
|
157
|
-
}
|
|
158
|
-
if (request.hard_translate_dict != null) {
|
|
159
|
-
_request.append("hard_translate_dict", request.hard_translate_dict);
|
|
160
|
-
}
|
|
161
|
-
if (request.input_lang != null) {
|
|
162
|
-
_request.append("input_lang", request.input_lang);
|
|
163
|
-
}
|
|
164
|
-
if (request.output_lang != null) {
|
|
165
|
-
_request.append("output_lang", request.output_lang);
|
|
166
|
-
}
|
|
167
|
-
const _maybeEncodedRequest = yield _request.getRequest();
|
|
168
|
-
const _response = yield core.fetcher({
|
|
169
|
-
url: (0, url_join_1.default)((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.SarvamAIEnvironment.Production, "parse/translatepdf"),
|
|
170
|
-
method: "POST",
|
|
171
|
-
headers: Object.assign(Object.assign({ "api-subscription-key": (yield core.Supplier.get(this._options.apiSubscriptionKey)) != null
|
|
172
|
-
? yield core.Supplier.get(this._options.apiSubscriptionKey)
|
|
173
|
-
: undefined, "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.0.3", "User-Agent": "sarvamai/0.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
174
|
-
requestType: "file",
|
|
175
|
-
duplex: _maybeEncodedRequest.duplex,
|
|
176
|
-
body: _maybeEncodedRequest.body,
|
|
177
|
-
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
178
|
-
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
179
|
-
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
180
|
-
});
|
|
181
|
-
if (_response.ok) {
|
|
182
|
-
return _response.body;
|
|
183
|
-
}
|
|
184
|
-
if (_response.error.reason === "status-code") {
|
|
185
|
-
switch (_response.error.statusCode) {
|
|
186
|
-
case 400:
|
|
187
|
-
throw new SarvamAI.BadRequestError(_response.error.body);
|
|
188
|
-
case 422:
|
|
189
|
-
throw new SarvamAI.UnprocessableEntityError(_response.error.body);
|
|
190
|
-
case 500:
|
|
191
|
-
throw new SarvamAI.InternalServerError(_response.error.body);
|
|
192
|
-
default:
|
|
193
|
-
throw new errors.SarvamAIError({
|
|
194
|
-
statusCode: _response.error.statusCode,
|
|
195
|
-
body: _response.error.body,
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
switch (_response.error.reason) {
|
|
200
|
-
case "non-json":
|
|
201
|
-
throw new errors.SarvamAIError({
|
|
202
|
-
statusCode: _response.error.statusCode,
|
|
203
|
-
body: _response.error.rawBody,
|
|
204
|
-
});
|
|
205
|
-
case "timeout":
|
|
206
|
-
throw new errors.SarvamAITimeoutError("Timeout exceeded when calling POST /parse/translatepdf.");
|
|
207
|
-
case "unknown":
|
|
208
|
-
throw new errors.SarvamAIError({
|
|
209
|
-
message: _response.error.errorMessage,
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
exports.Pdf = Pdf;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./requests";
|
|
@@ -1,17 +0,0 @@
|
|
|
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("./requests"), exports);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
import * as SarvamAI from "../../../../index";
|
|
5
|
-
/**
|
|
6
|
-
* @example
|
|
7
|
-
* {}
|
|
8
|
-
*/
|
|
9
|
-
export interface ParsePdfRequest {
|
|
10
|
-
/** The page number you want to extract data from. This is a one-based index (meaning, the first page is 1). */
|
|
11
|
-
page_number?: string;
|
|
12
|
-
/**
|
|
13
|
-
* The mode of parsing to use:
|
|
14
|
-
*
|
|
15
|
-
* - small: Use this mode for economical and fast parsing
|
|
16
|
-
* - large: Use this mode for highest precision parsing
|
|
17
|
-
*/
|
|
18
|
-
sarvam_mode?: SarvamAI.SarvamMode;
|
|
19
|
-
/** Whether to cache the prompt for the parse request. This is useful when running multiple requests to the parsing endpoint. */
|
|
20
|
-
prompt_caching?: SarvamAI.PromptCaching;
|
|
21
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
import * as SarvamAI from "../../../../index";
|
|
5
|
-
/**
|
|
6
|
-
* @example
|
|
7
|
-
* {}
|
|
8
|
-
*/
|
|
9
|
-
export interface TranslatePdfRequest {
|
|
10
|
-
/** The page number you want to translate. Use a one-based index (e.g., 1 for the first page). You can send an empty value if you want to translate the entire document. */
|
|
11
|
-
page_number?: string;
|
|
12
|
-
/** A dictionary of words for which you want to hardcode the translation. A list of words that you want to translate in a specific way. When these words appear in the document, the system will use your custom translation instead of automatic translation.If you add a dictionary with {"Hello": "नमस्कार"}, every time the word "नमस्कार" appears in the document, it will be translated as "नमस्कार" instead of the usual translation. */
|
|
13
|
-
hard_translate_dict?: string;
|
|
14
|
-
/** The language code of the input PDF. If you don’t specify, the system will try to detect it automatically.Note:-TranslatePDF currently supports only English language PDFs for translation. */
|
|
15
|
-
input_lang?: string;
|
|
16
|
-
/**
|
|
17
|
-
* The language code of the output text. This specifies the target language for translation.
|
|
18
|
-
* Available options:
|
|
19
|
-
* hi = "hi-IN"
|
|
20
|
-
* bn = "bn-IN"
|
|
21
|
-
* gu = "gu-IN"
|
|
22
|
-
* kn = "kn-IN"
|
|
23
|
-
* ml = "ml-IN"
|
|
24
|
-
* mr = "mr-IN"
|
|
25
|
-
* od = "od-IN"
|
|
26
|
-
* pa = "pa-IN"
|
|
27
|
-
* ta = "ta-IN"
|
|
28
|
-
* te = "te-IN"
|
|
29
|
-
* Example: "hi-IN" for Hindi
|
|
30
|
-
*/
|
|
31
|
-
output_lang?: SarvamAI.Language;
|
|
32
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./client";
|
|
@@ -1,17 +0,0 @@
|
|
|
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("./client"), exports);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
import * as SarvamAI from "../index";
|
|
5
|
-
export interface CallAnalyticsJobParameters {
|
|
6
|
-
/**
|
|
7
|
-
* List of questions to be answered based on the call content. Each question should be a valid JSON object with the following structure:
|
|
8
|
-
* ```[{id: "q001", text: "What was the main issue discussed in the call?", description: "Identify the primary concern or topic of the conversation", type: "enum", properties: {"options": ["NEW_CONNECTION", "INTERNET_ISSUES", "REFUND"]}}].```The `type` field must be one of: `boolean`, `enum`, `short answer`, `long answer`, or `number`. For `enum` type questions, include an 'options' list in the properties.
|
|
9
|
-
*/
|
|
10
|
-
questions: SarvamAI.Question[];
|
|
11
|
-
/** Model to be used for converting speech to text in target language */
|
|
12
|
-
model?: SarvamAI.SpeechToTextTranslateModel;
|
|
13
|
-
/**
|
|
14
|
-
* Enables speaker diarization, which identifies and separates different speakers in the audio.
|
|
15
|
-
* When set to true, the API will provide speaker-specific segments in the response.
|
|
16
|
-
* Note: This parameter is currently in Beta mode.
|
|
17
|
-
*/
|
|
18
|
-
with_diarization?: boolean;
|
|
19
|
-
/** Number of speakers to be detected in the audio. */
|
|
20
|
-
num_speakers?: number;
|
|
21
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
import * as SarvamAI from "../index";
|
|
5
|
-
export interface CallAnalyticsJobRequest {
|
|
6
|
-
/** Job UUID */
|
|
7
|
-
job_id: string;
|
|
8
|
-
/** Job Parameters for the bulk call analytics job */
|
|
9
|
-
job_parameters: SarvamAI.CallAnalyticsJobParameters;
|
|
10
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
import * as SarvamAI from "../index";
|
|
5
|
-
export interface CallAnalyticsResponse {
|
|
6
|
-
request_id?: string;
|
|
7
|
-
/** Unique identifier for the analyzed audio file. */
|
|
8
|
-
file_name?: string;
|
|
9
|
-
/** Full transcript of the call generated by Sarvam's inhouse speech-to-text model. */
|
|
10
|
-
transcript: string;
|
|
11
|
-
/** List of answers to predefined questions, derived from the call analysis. It can be null if no valid answers were generated. */
|
|
12
|
-
answers?: SarvamAI.QnaResponse[];
|
|
13
|
-
/** Duration of the analyzed call in seconds. */
|
|
14
|
-
duration_in_seconds?: number;
|
|
15
|
-
/** This will return the BCP-47 code of language spoken in the input. If multiple languages are detected, this will return language code of most predominant spoken language. If no language is detected, this will be null */
|
|
16
|
-
language_code?: SarvamAI.SpeechToTextTranslateLanguage;
|
|
17
|
-
/** Diarized transcript of the provided speech */
|
|
18
|
-
diarized_transcript?: SarvamAI.DiarizedTranscript;
|
|
19
|
-
}
|
package/api/types/Language.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
export type Language = "hi-IN" | "bn-IN" | "kn-IN" | "ml-IN" | "mr-IN" | "od-IN" | "pa-IN" | "ta-IN" | "te-IN" | "en-IN" | "gu-IN";
|
|
5
|
-
export declare const Language: {
|
|
6
|
-
readonly HiIn: "hi-IN";
|
|
7
|
-
readonly BnIn: "bn-IN";
|
|
8
|
-
readonly KnIn: "kn-IN";
|
|
9
|
-
readonly MlIn: "ml-IN";
|
|
10
|
-
readonly MrIn: "mr-IN";
|
|
11
|
-
readonly OdIn: "od-IN";
|
|
12
|
-
readonly PaIn: "pa-IN";
|
|
13
|
-
readonly TaIn: "ta-IN";
|
|
14
|
-
readonly TeIn: "te-IN";
|
|
15
|
-
readonly EnIn: "en-IN";
|
|
16
|
-
readonly GuIn: "gu-IN";
|
|
17
|
-
};
|
package/api/types/Language.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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.Language = void 0;
|
|
7
|
-
exports.Language = {
|
|
8
|
-
HiIn: "hi-IN",
|
|
9
|
-
BnIn: "bn-IN",
|
|
10
|
-
KnIn: "kn-IN",
|
|
11
|
-
MlIn: "ml-IN",
|
|
12
|
-
MrIn: "mr-IN",
|
|
13
|
-
OdIn: "od-IN",
|
|
14
|
-
PaIn: "pa-IN",
|
|
15
|
-
TaIn: "ta-IN",
|
|
16
|
-
TeIn: "te-IN",
|
|
17
|
-
EnIn: "en-IN",
|
|
18
|
-
GuIn: "gu-IN",
|
|
19
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
export interface ParsedPageResponse {
|
|
5
|
-
/** The base64 encoded HTML string corresponding to the parsed page. The output will be an empty string if parsing fails for some reason. */
|
|
6
|
-
output?: string;
|
|
7
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
export interface QnaResponse {
|
|
5
|
-
/** Unique identifier for the question-answer pair, corresponding to the question ID in the request. */
|
|
6
|
-
id: string;
|
|
7
|
-
/** The original question text that was asked and analyzed. */
|
|
8
|
-
question: string;
|
|
9
|
-
/** Explanation or reasoning provided by the analysis model to justify the answer. */
|
|
10
|
-
reasoning: string;
|
|
11
|
-
/** The answer to the question, derived from the call analysis. The format may vary based on the question type (e.g., boolean, enum, text). */
|
|
12
|
-
response: string;
|
|
13
|
-
/** Relevant excerpt from the call transcript that supports the answer. This provides direct evidence for the response. */
|
|
14
|
-
utterance: string;
|
|
15
|
-
}
|
package/api/types/QnaResponse.js
DELETED
package/api/types/Question.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
import * as SarvamAI from "../index";
|
|
5
|
-
export interface Question {
|
|
6
|
-
/** Unique identifier for the question. This should be a short, distinct string or number. */
|
|
7
|
-
id: string;
|
|
8
|
-
/** The actual text of the question to be answered based on the call content. */
|
|
9
|
-
text: string;
|
|
10
|
-
/** Optional description or context for the question. Use this to provide additional information to the LLM for better reasoning. */
|
|
11
|
-
description?: string;
|
|
12
|
-
/**
|
|
13
|
-
* The type of question, which determines how it should be answered and processed. Valid types are:
|
|
14
|
-
* - boolean: A yes/no question
|
|
15
|
-
* - enum: A question with predefined answer options
|
|
16
|
-
* - short answer: A question requiring a brief text response
|
|
17
|
-
* - long answer: A question requiring a detailed text response
|
|
18
|
-
* - number: A question expecting a numeric answer
|
|
19
|
-
*/
|
|
20
|
-
type: SarvamAI.QuestionType;
|
|
21
|
-
/** Additional properties specific to the question type. For 'enum' types, this should include an 'options' list. */
|
|
22
|
-
properties?: Record<string, unknown>;
|
|
23
|
-
}
|
package/api/types/Question.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
export type QuestionType = "boolean" | "enum" | "short answer" | "long answer" | "number";
|
|
5
|
-
export declare const QuestionType: {
|
|
6
|
-
readonly Boolean: "boolean";
|
|
7
|
-
readonly Enum: "enum";
|
|
8
|
-
readonly ShortAnswer: "short answer";
|
|
9
|
-
readonly LongAnswer: "long answer";
|
|
10
|
-
readonly Number: "number";
|
|
11
|
-
};
|