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.
Files changed (148) hide show
  1. package/Client.d.ts +1 -10
  2. package/Client.js +4 -14
  3. package/api/resources/index.d.ts +0 -4
  4. package/api/resources/index.js +1 -5
  5. package/api/resources/speechToText/client/Client.d.ts +4 -4
  6. package/api/resources/speechToText/client/Client.js +9 -6
  7. package/api/resources/text/client/Client.d.ts +4 -4
  8. package/api/resources/text/client/Client.js +10 -9
  9. package/api/resources/textToSpeech/client/Client.d.ts +5 -5
  10. package/api/resources/textToSpeech/client/Client.js +9 -4
  11. package/api/resources/textToSpeech/client/requests/TextToSpeechRequest.d.ts +33 -11
  12. package/api/types/ErrorCode.d.ts +3 -5
  13. package/api/types/ErrorCode.js +2 -4
  14. package/api/types/TextToSpeechLanguage.d.ts +4 -4
  15. package/api/types/TextToSpeechLanguage.js +3 -3
  16. package/api/types/TextToSpeechModel.d.ts +5 -1
  17. package/api/types/TextToSpeechModel.js +5 -0
  18. package/api/types/TextToSpeechSpeaker.d.ts +8 -1
  19. package/api/types/TextToSpeechSpeaker.js +7 -0
  20. package/api/types/index.d.ts +0 -13
  21. package/api/types/index.js +0 -13
  22. package/dist/Client.d.ts +1 -10
  23. package/dist/Client.js +4 -14
  24. package/dist/api/resources/index.d.ts +0 -4
  25. package/dist/api/resources/index.js +1 -5
  26. package/dist/api/resources/speechToText/client/Client.d.ts +4 -4
  27. package/dist/api/resources/speechToText/client/Client.js +9 -6
  28. package/dist/api/resources/text/client/Client.d.ts +4 -4
  29. package/dist/api/resources/text/client/Client.js +10 -9
  30. package/dist/api/resources/textToSpeech/client/Client.d.ts +5 -5
  31. package/dist/api/resources/textToSpeech/client/Client.js +9 -4
  32. package/dist/api/resources/textToSpeech/client/requests/TextToSpeechRequest.d.ts +33 -11
  33. package/dist/api/types/ErrorCode.d.ts +3 -5
  34. package/dist/api/types/ErrorCode.js +2 -4
  35. package/dist/api/types/TextToSpeechLanguage.d.ts +4 -4
  36. package/dist/api/types/TextToSpeechLanguage.js +3 -3
  37. package/dist/api/types/TextToSpeechModel.d.ts +5 -1
  38. package/dist/api/types/TextToSpeechModel.js +5 -0
  39. package/dist/api/types/TextToSpeechSpeaker.d.ts +8 -1
  40. package/dist/api/types/TextToSpeechSpeaker.js +7 -0
  41. package/dist/api/types/index.d.ts +0 -13
  42. package/dist/api/types/index.js +0 -13
  43. package/dist/environments.d.ts +1 -2
  44. package/dist/environments.js +0 -1
  45. package/dist/version.d.ts +1 -1
  46. package/dist/version.js +1 -1
  47. package/environments.d.ts +1 -2
  48. package/environments.js +0 -1
  49. package/package.json +1 -1
  50. package/reference.md +1 -286
  51. package/version.d.ts +1 -1
  52. package/version.js +1 -1
  53. package/api/resources/analytics/client/Client.d.ts +0 -73
  54. package/api/resources/analytics/client/Client.js +0 -223
  55. package/api/resources/analytics/client/index.d.ts +0 -1
  56. package/api/resources/analytics/client/index.js +0 -17
  57. package/api/resources/analytics/client/requests/CallAnalyticsRequest.d.ts +0 -24
  58. package/api/resources/analytics/client/requests/CallAnalyticsRequest.js +0 -5
  59. package/api/resources/analytics/client/requests/index.d.ts +0 -1
  60. package/api/resources/analytics/client/requests/index.js +0 -2
  61. package/api/resources/analytics/index.d.ts +0 -1
  62. package/api/resources/analytics/index.js +0 -17
  63. package/api/resources/pdf/client/Client.d.ts +0 -63
  64. package/api/resources/pdf/client/Client.js +0 -215
  65. package/api/resources/pdf/client/index.d.ts +0 -1
  66. package/api/resources/pdf/client/index.js +0 -17
  67. package/api/resources/pdf/client/requests/ParsePdfRequest.d.ts +0 -21
  68. package/api/resources/pdf/client/requests/ParsePdfRequest.js +0 -5
  69. package/api/resources/pdf/client/requests/TranslatePdfRequest.d.ts +0 -32
  70. package/api/resources/pdf/client/requests/TranslatePdfRequest.js +0 -5
  71. package/api/resources/pdf/client/requests/index.d.ts +0 -2
  72. package/api/resources/pdf/client/requests/index.js +0 -2
  73. package/api/resources/pdf/index.d.ts +0 -1
  74. package/api/resources/pdf/index.js +0 -17
  75. package/api/types/CallAnalyticsJobParameters.d.ts +0 -21
  76. package/api/types/CallAnalyticsJobParameters.js +0 -5
  77. package/api/types/CallAnalyticsJobRequest.d.ts +0 -10
  78. package/api/types/CallAnalyticsJobRequest.js +0 -5
  79. package/api/types/CallAnalyticsResponse.d.ts +0 -19
  80. package/api/types/CallAnalyticsResponse.js +0 -5
  81. package/api/types/Language.d.ts +0 -17
  82. package/api/types/Language.js +0 -19
  83. package/api/types/ParsedPageResponse.d.ts +0 -7
  84. package/api/types/ParsedPageResponse.js +0 -5
  85. package/api/types/PromptCaching.d.ts +0 -8
  86. package/api/types/PromptCaching.js +0 -10
  87. package/api/types/QnaResponse.d.ts +0 -15
  88. package/api/types/QnaResponse.js +0 -5
  89. package/api/types/Question.d.ts +0 -23
  90. package/api/types/Question.js +0 -5
  91. package/api/types/QuestionType.d.ts +0 -11
  92. package/api/types/QuestionType.js +0 -13
  93. package/api/types/SarvamMode.d.ts +0 -8
  94. package/api/types/SarvamMode.js +0 -10
  95. package/api/types/TextAnalyticsRequest.d.ts +0 -9
  96. package/api/types/TextAnalyticsRequest.js +0 -5
  97. package/api/types/TextAnalyticsResponse.d.ts +0 -9
  98. package/api/types/TextAnalyticsResponse.js +0 -5
  99. package/api/types/TranslatedPage.d.ts +0 -7
  100. package/api/types/TranslatedPage.js +0 -5
  101. package/dist/api/resources/analytics/client/Client.d.ts +0 -73
  102. package/dist/api/resources/analytics/client/Client.js +0 -223
  103. package/dist/api/resources/analytics/client/index.d.ts +0 -1
  104. package/dist/api/resources/analytics/client/index.js +0 -17
  105. package/dist/api/resources/analytics/client/requests/CallAnalyticsRequest.d.ts +0 -24
  106. package/dist/api/resources/analytics/client/requests/CallAnalyticsRequest.js +0 -5
  107. package/dist/api/resources/analytics/client/requests/index.d.ts +0 -1
  108. package/dist/api/resources/analytics/client/requests/index.js +0 -2
  109. package/dist/api/resources/analytics/index.d.ts +0 -1
  110. package/dist/api/resources/analytics/index.js +0 -17
  111. package/dist/api/resources/pdf/client/Client.d.ts +0 -63
  112. package/dist/api/resources/pdf/client/Client.js +0 -215
  113. package/dist/api/resources/pdf/client/index.d.ts +0 -1
  114. package/dist/api/resources/pdf/client/index.js +0 -17
  115. package/dist/api/resources/pdf/client/requests/ParsePdfRequest.d.ts +0 -21
  116. package/dist/api/resources/pdf/client/requests/ParsePdfRequest.js +0 -5
  117. package/dist/api/resources/pdf/client/requests/TranslatePdfRequest.d.ts +0 -32
  118. package/dist/api/resources/pdf/client/requests/TranslatePdfRequest.js +0 -5
  119. package/dist/api/resources/pdf/client/requests/index.d.ts +0 -2
  120. package/dist/api/resources/pdf/client/requests/index.js +0 -2
  121. package/dist/api/resources/pdf/index.d.ts +0 -1
  122. package/dist/api/resources/pdf/index.js +0 -17
  123. package/dist/api/types/CallAnalyticsJobParameters.d.ts +0 -21
  124. package/dist/api/types/CallAnalyticsJobParameters.js +0 -5
  125. package/dist/api/types/CallAnalyticsJobRequest.d.ts +0 -10
  126. package/dist/api/types/CallAnalyticsJobRequest.js +0 -5
  127. package/dist/api/types/CallAnalyticsResponse.d.ts +0 -19
  128. package/dist/api/types/CallAnalyticsResponse.js +0 -5
  129. package/dist/api/types/Language.d.ts +0 -17
  130. package/dist/api/types/Language.js +0 -19
  131. package/dist/api/types/ParsedPageResponse.d.ts +0 -7
  132. package/dist/api/types/ParsedPageResponse.js +0 -5
  133. package/dist/api/types/PromptCaching.d.ts +0 -8
  134. package/dist/api/types/PromptCaching.js +0 -10
  135. package/dist/api/types/QnaResponse.d.ts +0 -15
  136. package/dist/api/types/QnaResponse.js +0 -5
  137. package/dist/api/types/Question.d.ts +0 -23
  138. package/dist/api/types/Question.js +0 -5
  139. package/dist/api/types/QuestionType.d.ts +0 -11
  140. package/dist/api/types/QuestionType.js +0 -13
  141. package/dist/api/types/SarvamMode.d.ts +0 -8
  142. package/dist/api/types/SarvamMode.js +0 -10
  143. package/dist/api/types/TextAnalyticsRequest.d.ts +0 -9
  144. package/dist/api/types/TextAnalyticsRequest.js +0 -5
  145. package/dist/api/types/TextAnalyticsResponse.d.ts +0 -9
  146. package/dist/api/types/TextAnalyticsResponse.js +0 -5
  147. package/dist/api/types/TranslatedPage.d.ts +0 -7
  148. package/dist/api/types/TranslatedPage.js +0 -5
@@ -1,13 +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.QuestionType = void 0;
7
- exports.QuestionType = {
8
- Boolean: "boolean",
9
- Enum: "enum",
10
- ShortAnswer: "short answer",
11
- LongAnswer: "long answer",
12
- Number: "number",
13
- };
@@ -1,8 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- export type SarvamMode = "small" | "large";
5
- export declare const SarvamMode: {
6
- readonly Small: "small";
7
- readonly Large: "large";
8
- };
@@ -1,10 +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.SarvamMode = void 0;
7
- exports.SarvamMode = {
8
- Small: "small",
9
- Large: "large",
10
- };
@@ -1,9 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- export interface TextAnalyticsRequest {
5
- /** The text content to be analyzed. This should be a non-empty string containing the full text for analysis. */
6
- text: string;
7
- /** List of questions to be answered based on the call content. Each question should be a valid JSON object with the following structure: ```{id: string, text: string, description: string (optional), type: string, properties: object}.```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. */
8
- questions: string;
9
- }
@@ -1,5 +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 });
@@ -1,9 +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 TextAnalyticsResponse {
6
- request_id?: string;
7
- /** List of answers derived from the text analysis. Each answer corresponds to a question from the original request. This field will be null if no valid answers could be generated. */
8
- answers?: SarvamAI.QnaResponse[];
9
- }
@@ -1,5 +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 });
@@ -1,7 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- export interface TranslatedPage {
5
- /** The translated PDF document in base64 encoding. */
6
- translated_pdf?: string;
7
- }
@@ -1,5 +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 });
@@ -1,73 +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 Analytics {
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 Analytics {
31
- protected readonly _options: Analytics.Options;
32
- constructor(_options?: Analytics.Options);
33
- /**
34
- * Given an audio file of a call between two parties and a list of questions, this API analyzes the content and returns the transcript, along with responses to the questions. Each response is supported by reasoning and exact phrases extracted from the transcript.
35
- *
36
- * @param {File | fs.ReadStream | Blob} file
37
- * @param {SarvamAI.CallAnalyticsRequest} request
38
- * @param {Analytics.RequestOptions} requestOptions - Request-specific configuration.
39
- *
40
- * @throws {@link SarvamAI.BadRequestError}
41
- * @throws {@link SarvamAI.ForbiddenError}
42
- * @throws {@link SarvamAI.UnprocessableEntityError}
43
- * @throws {@link SarvamAI.TooManyRequestsError}
44
- * @throws {@link SarvamAI.InternalServerError}
45
- * @throws {@link SarvamAI.ServiceUnavailableError}
46
- *
47
- * @example
48
- * await client.analytics.call(fs.createReadStream("/path/to/your/file"), {
49
- * questions: "questions"
50
- * })
51
- */
52
- call(file: File | fs.ReadStream | Blob, request: SarvamAI.CallAnalyticsRequest, requestOptions?: Analytics.RequestOptions): Promise<SarvamAI.CallAnalyticsResponse>;
53
- /**
54
- * This endpoint performs comprehensive text analysis on provided content and answers specific questions about the text. Each response is supported by reasoning and the exact phrase extracted from the content.
55
- *
56
- * @param {SarvamAI.TextAnalyticsRequest} request
57
- * @param {Analytics.RequestOptions} requestOptions - Request-specific configuration.
58
- *
59
- * @throws {@link SarvamAI.BadRequestError}
60
- * @throws {@link SarvamAI.ForbiddenError}
61
- * @throws {@link SarvamAI.UnprocessableEntityError}
62
- * @throws {@link SarvamAI.TooManyRequestsError}
63
- * @throws {@link SarvamAI.InternalServerError}
64
- * @throws {@link SarvamAI.ServiceUnavailableError}
65
- *
66
- * @example
67
- * await client.analytics.text({
68
- * text: "Climate change is a critical global challenge that demands immediate attention. Rising temperatures, extreme weather events, and sea level rise are just a few of the consequences we're already experiencing. Scientists emphasize the urgency of limiting global warming to 1.5\u00B0C above pre-industrial levels to avoid the most severe consequences. This requires significant reductions in greenhouse gas emissions across all sectors of society.",
69
- * questions: "questions"
70
- * })
71
- */
72
- text(request: SarvamAI.TextAnalyticsRequest, requestOptions?: Analytics.RequestOptions): Promise<SarvamAI.TextAnalyticsResponse>;
73
- }
@@ -1,223 +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.Analytics = 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 Analytics {
58
- constructor(_options = {}) {
59
- this._options = _options;
60
- }
61
- /**
62
- * Given an audio file of a call between two parties and a list of questions, this API analyzes the content and returns the transcript, along with responses to the questions. Each response is supported by reasoning and exact phrases extracted from the transcript.
63
- *
64
- * @param {File | fs.ReadStream | Blob} file
65
- * @param {SarvamAI.CallAnalyticsRequest} request
66
- * @param {Analytics.RequestOptions} requestOptions - Request-specific configuration.
67
- *
68
- * @throws {@link SarvamAI.BadRequestError}
69
- * @throws {@link SarvamAI.ForbiddenError}
70
- * @throws {@link SarvamAI.UnprocessableEntityError}
71
- * @throws {@link SarvamAI.TooManyRequestsError}
72
- * @throws {@link SarvamAI.InternalServerError}
73
- * @throws {@link SarvamAI.ServiceUnavailableError}
74
- *
75
- * @example
76
- * await client.analytics.call(fs.createReadStream("/path/to/your/file"), {
77
- * questions: "questions"
78
- * })
79
- */
80
- call(file, request, requestOptions) {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- var _a, _b;
83
- const _request = yield core.newFormData();
84
- yield _request.appendFile("file", file);
85
- _request.append("questions", request.questions);
86
- if (request.hotwords != null) {
87
- _request.append("hotwords", request.hotwords);
88
- }
89
- if (request.model != null) {
90
- _request.append("model", request.model);
91
- }
92
- if (request.with_diarization != null) {
93
- _request.append("with_diarization", request.with_diarization.toString());
94
- }
95
- const _maybeEncodedRequest = yield _request.getRequest();
96
- const _response = yield core.fetcher({
97
- 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, "call-analytics"),
98
- method: "POST",
99
- headers: Object.assign(Object.assign({ "api-subscription-key": (yield core.Supplier.get(this._options.apiSubscriptionKey)) != null
100
- ? yield core.Supplier.get(this._options.apiSubscriptionKey)
101
- : 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),
102
- requestType: "file",
103
- duplex: _maybeEncodedRequest.duplex,
104
- body: _maybeEncodedRequest.body,
105
- timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
106
- maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
107
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
108
- });
109
- if (_response.ok) {
110
- return _response.body;
111
- }
112
- if (_response.error.reason === "status-code") {
113
- switch (_response.error.statusCode) {
114
- case 400:
115
- throw new SarvamAI.BadRequestError(_response.error.body);
116
- case 403:
117
- throw new SarvamAI.ForbiddenError(_response.error.body);
118
- case 422:
119
- throw new SarvamAI.UnprocessableEntityError(_response.error.body);
120
- case 429:
121
- throw new SarvamAI.TooManyRequestsError(_response.error.body);
122
- case 500:
123
- throw new SarvamAI.InternalServerError(_response.error.body);
124
- case 503:
125
- throw new SarvamAI.ServiceUnavailableError(_response.error.body);
126
- default:
127
- throw new errors.SarvamAIError({
128
- statusCode: _response.error.statusCode,
129
- body: _response.error.body,
130
- });
131
- }
132
- }
133
- switch (_response.error.reason) {
134
- case "non-json":
135
- throw new errors.SarvamAIError({
136
- statusCode: _response.error.statusCode,
137
- body: _response.error.rawBody,
138
- });
139
- case "timeout":
140
- throw new errors.SarvamAITimeoutError("Timeout exceeded when calling POST /call-analytics.");
141
- case "unknown":
142
- throw new errors.SarvamAIError({
143
- message: _response.error.errorMessage,
144
- });
145
- }
146
- });
147
- }
148
- /**
149
- * This endpoint performs comprehensive text analysis on provided content and answers specific questions about the text. Each response is supported by reasoning and the exact phrase extracted from the content.
150
- *
151
- * @param {SarvamAI.TextAnalyticsRequest} request
152
- * @param {Analytics.RequestOptions} requestOptions - Request-specific configuration.
153
- *
154
- * @throws {@link SarvamAI.BadRequestError}
155
- * @throws {@link SarvamAI.ForbiddenError}
156
- * @throws {@link SarvamAI.UnprocessableEntityError}
157
- * @throws {@link SarvamAI.TooManyRequestsError}
158
- * @throws {@link SarvamAI.InternalServerError}
159
- * @throws {@link SarvamAI.ServiceUnavailableError}
160
- *
161
- * @example
162
- * await client.analytics.text({
163
- * text: "Climate change is a critical global challenge that demands immediate attention. Rising temperatures, extreme weather events, and sea level rise are just a few of the consequences we're already experiencing. Scientists emphasize the urgency of limiting global warming to 1.5\u00B0C above pre-industrial levels to avoid the most severe consequences. This requires significant reductions in greenhouse gas emissions across all sectors of society.",
164
- * questions: "questions"
165
- * })
166
- */
167
- text(request, requestOptions) {
168
- return __awaiter(this, void 0, void 0, function* () {
169
- var _a, _b;
170
- const _response = yield core.fetcher({
171
- 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, "text-analytics"),
172
- method: "POST",
173
- headers: Object.assign({ "api-subscription-key": (yield core.Supplier.get(this._options.apiSubscriptionKey)) != null
174
- ? yield core.Supplier.get(this._options.apiSubscriptionKey)
175
- : 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 }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
176
- contentType: "application/x-www-form-urlencoded",
177
- requestType: "json",
178
- body: request,
179
- timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
180
- maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
181
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
182
- });
183
- if (_response.ok) {
184
- return _response.body;
185
- }
186
- if (_response.error.reason === "status-code") {
187
- switch (_response.error.statusCode) {
188
- case 400:
189
- throw new SarvamAI.BadRequestError(_response.error.body);
190
- case 403:
191
- throw new SarvamAI.ForbiddenError(_response.error.body);
192
- case 422:
193
- throw new SarvamAI.UnprocessableEntityError(_response.error.body);
194
- case 429:
195
- throw new SarvamAI.TooManyRequestsError(_response.error.body);
196
- case 500:
197
- throw new SarvamAI.InternalServerError(_response.error.body);
198
- case 503:
199
- throw new SarvamAI.ServiceUnavailableError(_response.error.body);
200
- default:
201
- throw new errors.SarvamAIError({
202
- statusCode: _response.error.statusCode,
203
- body: _response.error.body,
204
- });
205
- }
206
- }
207
- switch (_response.error.reason) {
208
- case "non-json":
209
- throw new errors.SarvamAIError({
210
- statusCode: _response.error.statusCode,
211
- body: _response.error.rawBody,
212
- });
213
- case "timeout":
214
- throw new errors.SarvamAITimeoutError("Timeout exceeded when calling POST /text-analytics.");
215
- case "unknown":
216
- throw new errors.SarvamAIError({
217
- message: _response.error.errorMessage,
218
- });
219
- }
220
- });
221
- }
222
- }
223
- exports.Analytics = Analytics;
@@ -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,24 +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
- * questions: "questions"
9
- * }
10
- */
11
- export interface CallAnalyticsRequest {
12
- /**
13
- * List of questions to be answered based on the call content. Each question should be a valid `JSON` object with the following structure: ```{id: string, text: string, description: string (optional), type: string, properties: object}```.
14
- * The `type` field must be one of: `boolean`, `enum`, `short answer`, `long answer`, or `number`.
15
- * For `enum` type questions, include an 'options' list in the properties.
16
- */
17
- questions: string;
18
- /** Optional comma-separated string of keywords specific to your domain. These keywords will be preserved as-is in the transcript. */
19
- hotwords?: string;
20
- /** Model to be used for converting speech to text in target language */
21
- model?: SarvamAI.SpeechToTextTranslateModel;
22
- /** Include diarization in the output */
23
- with_diarization?: boolean;
24
- }
@@ -1,5 +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 });
@@ -1 +0,0 @@
1
- export { type CallAnalyticsRequest } from "./CallAnalyticsRequest";
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,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
- }