sarvamai 0.1.1 → 0.1.2

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 (107) hide show
  1. package/Client.d.ts +3 -0
  2. package/Client.js +5 -0
  3. package/README.md +1 -1
  4. package/api/errors/ForbiddenError.d.ts +1 -2
  5. package/api/errors/TooManyRequestsError.d.ts +1 -2
  6. package/api/resources/chat/client/Client.d.ts +53 -0
  7. package/api/resources/chat/client/Client.js +141 -0
  8. package/api/resources/chat/client/index.d.ts +1 -0
  9. package/api/resources/chat/client/index.js +17 -0
  10. package/api/resources/chat/client/requests/ChatCompletionsRequest.d.ts +63 -0
  11. package/api/resources/chat/client/requests/ChatCompletionsRequest.js +5 -0
  12. package/api/resources/chat/client/requests/index.d.ts +1 -0
  13. package/api/resources/chat/client/requests/index.js +2 -0
  14. package/api/resources/chat/index.d.ts +1 -0
  15. package/api/resources/chat/index.js +17 -0
  16. package/api/resources/index.d.ts +2 -0
  17. package/api/resources/index.js +3 -1
  18. package/api/resources/speechToText/client/Client.js +2 -2
  19. package/api/resources/text/client/Client.js +3 -3
  20. package/api/resources/textToSpeech/client/Client.js +1 -1
  21. package/api/types/ChatCompletionRequestAssistantMessage.d.ts +7 -0
  22. package/api/types/ChatCompletionRequestAssistantMessage.js +5 -0
  23. package/api/types/ChatCompletionRequestMessage.d.ts +16 -0
  24. package/api/types/ChatCompletionRequestMessage.js +5 -0
  25. package/api/types/ChatCompletionRequestSystemMessage.d.ts +7 -0
  26. package/api/types/ChatCompletionRequestSystemMessage.js +5 -0
  27. package/api/types/ChatCompletionRequestUserMessage.d.ts +7 -0
  28. package/api/types/ChatCompletionRequestUserMessage.js +5 -0
  29. package/api/types/ChatCompletionResponseMessage.d.ts +10 -0
  30. package/api/types/ChatCompletionResponseMessage.js +5 -0
  31. package/api/types/Choice.d.ts +16 -0
  32. package/api/types/Choice.js +5 -0
  33. package/api/types/CompletionUsage.d.ts +11 -0
  34. package/api/types/CompletionUsage.js +5 -0
  35. package/api/types/CreateChatCompletionResponse.d.ts +17 -0
  36. package/api/types/CreateChatCompletionResponse.js +5 -0
  37. package/api/types/ErrorCode.d.ts +4 -4
  38. package/api/types/ErrorCode.js +3 -3
  39. package/api/types/ErrorDetails.d.ts +2 -0
  40. package/api/types/FinishReason.d.ts +11 -0
  41. package/api/types/FinishReason.js +13 -0
  42. package/api/types/ReasoningEffort.d.ts +9 -0
  43. package/api/types/ReasoningEffort.js +11 -0
  44. package/api/types/Role.d.ts +4 -0
  45. package/api/types/Role.js +5 -0
  46. package/api/types/SarvamModelIds.d.ts +4 -0
  47. package/api/types/SarvamModelIds.js +5 -0
  48. package/api/types/StopConfiguration.d.ts +8 -0
  49. package/api/types/StopConfiguration.js +5 -0
  50. package/api/types/index.d.ts +13 -0
  51. package/api/types/index.js +13 -0
  52. package/dist/Client.d.ts +3 -0
  53. package/dist/Client.js +5 -0
  54. package/dist/api/errors/ForbiddenError.d.ts +1 -2
  55. package/dist/api/errors/TooManyRequestsError.d.ts +1 -2
  56. package/dist/api/resources/chat/client/Client.d.ts +53 -0
  57. package/dist/api/resources/chat/client/Client.js +141 -0
  58. package/dist/api/resources/chat/client/index.d.ts +1 -0
  59. package/dist/api/resources/chat/client/index.js +17 -0
  60. package/dist/api/resources/chat/client/requests/ChatCompletionsRequest.d.ts +63 -0
  61. package/dist/api/resources/chat/client/requests/ChatCompletionsRequest.js +5 -0
  62. package/dist/api/resources/chat/client/requests/index.d.ts +1 -0
  63. package/dist/api/resources/chat/client/requests/index.js +2 -0
  64. package/dist/api/resources/chat/index.d.ts +1 -0
  65. package/dist/api/resources/chat/index.js +17 -0
  66. package/dist/api/resources/index.d.ts +2 -0
  67. package/dist/api/resources/index.js +3 -1
  68. package/dist/api/resources/speechToText/client/Client.js +2 -2
  69. package/dist/api/resources/text/client/Client.js +3 -3
  70. package/dist/api/resources/textToSpeech/client/Client.js +1 -1
  71. package/dist/api/types/ChatCompletionRequestAssistantMessage.d.ts +7 -0
  72. package/dist/api/types/ChatCompletionRequestAssistantMessage.js +5 -0
  73. package/dist/api/types/ChatCompletionRequestMessage.d.ts +16 -0
  74. package/dist/api/types/ChatCompletionRequestMessage.js +5 -0
  75. package/dist/api/types/ChatCompletionRequestSystemMessage.d.ts +7 -0
  76. package/dist/api/types/ChatCompletionRequestSystemMessage.js +5 -0
  77. package/dist/api/types/ChatCompletionRequestUserMessage.d.ts +7 -0
  78. package/dist/api/types/ChatCompletionRequestUserMessage.js +5 -0
  79. package/dist/api/types/ChatCompletionResponseMessage.d.ts +10 -0
  80. package/dist/api/types/ChatCompletionResponseMessage.js +5 -0
  81. package/dist/api/types/Choice.d.ts +16 -0
  82. package/dist/api/types/Choice.js +5 -0
  83. package/dist/api/types/CompletionUsage.d.ts +11 -0
  84. package/dist/api/types/CompletionUsage.js +5 -0
  85. package/dist/api/types/CreateChatCompletionResponse.d.ts +17 -0
  86. package/dist/api/types/CreateChatCompletionResponse.js +5 -0
  87. package/dist/api/types/ErrorCode.d.ts +4 -4
  88. package/dist/api/types/ErrorCode.js +3 -3
  89. package/dist/api/types/ErrorDetails.d.ts +2 -0
  90. package/dist/api/types/FinishReason.d.ts +11 -0
  91. package/dist/api/types/FinishReason.js +13 -0
  92. package/dist/api/types/ReasoningEffort.d.ts +9 -0
  93. package/dist/api/types/ReasoningEffort.js +11 -0
  94. package/dist/api/types/Role.d.ts +4 -0
  95. package/dist/api/types/Role.js +5 -0
  96. package/dist/api/types/SarvamModelIds.d.ts +4 -0
  97. package/dist/api/types/SarvamModelIds.js +5 -0
  98. package/dist/api/types/StopConfiguration.d.ts +8 -0
  99. package/dist/api/types/StopConfiguration.js +5 -0
  100. package/dist/api/types/index.d.ts +13 -0
  101. package/dist/api/types/index.js +13 -0
  102. package/dist/version.d.ts +1 -1
  103. package/dist/version.js +1 -1
  104. package/package.json +1 -1
  105. package/reference.md +73 -0
  106. package/version.d.ts +1 -1
  107. package/version.js +1 -1
package/Client.d.ts CHANGED
@@ -6,6 +6,7 @@ import * as core from "./core";
6
6
  import { Text } from "./api/resources/text/client/Client";
7
7
  import { SpeechToText } from "./api/resources/speechToText/client/Client";
8
8
  import { TextToSpeech } from "./api/resources/textToSpeech/client/Client";
9
+ import { Chat } from "./api/resources/chat/client/Client";
9
10
  export declare namespace SarvamAIClient {
10
11
  interface Options {
11
12
  environment?: core.Supplier<environments.SarvamAIEnvironment | string>;
@@ -29,8 +30,10 @@ export declare class SarvamAIClient {
29
30
  protected _text: Text | undefined;
30
31
  protected _speechToText: SpeechToText | undefined;
31
32
  protected _textToSpeech: TextToSpeech | undefined;
33
+ protected _chat: Chat | undefined;
32
34
  constructor(_options?: SarvamAIClient.Options);
33
35
  get text(): Text;
34
36
  get speechToText(): SpeechToText;
35
37
  get textToSpeech(): TextToSpeech;
38
+ get chat(): Chat;
36
39
  }
package/Client.js CHANGED
@@ -7,6 +7,7 @@ exports.SarvamAIClient = void 0;
7
7
  const Client_1 = require("./api/resources/text/client/Client");
8
8
  const Client_2 = require("./api/resources/speechToText/client/Client");
9
9
  const Client_3 = require("./api/resources/textToSpeech/client/Client");
10
+ const Client_4 = require("./api/resources/chat/client/Client");
10
11
  class SarvamAIClient {
11
12
  constructor(_options = {}) {
12
13
  this._options = _options;
@@ -23,5 +24,9 @@ class SarvamAIClient {
23
24
  var _a;
24
25
  return ((_a = this._textToSpeech) !== null && _a !== void 0 ? _a : (this._textToSpeech = new Client_3.TextToSpeech(this._options)));
25
26
  }
27
+ get chat() {
28
+ var _a;
29
+ return ((_a = this._chat) !== null && _a !== void 0 ? _a : (this._chat = new Client_4.Chat(this._options)));
30
+ }
26
31
  }
27
32
  exports.SarvamAIClient = SarvamAIClient;
package/README.md CHANGED
@@ -17,7 +17,7 @@ npm i -s sarvamai
17
17
 
18
18
  ## Reference
19
19
 
20
- A full reference for this library is available [here](./reference.md).
20
+ A full reference for this library is available [here](https://github.com/sarvamai/sarvam-javascript-sdk/blob/HEAD/./reference.md).
21
21
 
22
22
  ## Usage
23
23
 
@@ -2,7 +2,6 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as errors from "../../errors/index";
5
- import * as SarvamAI from "../index";
6
5
  export declare class ForbiddenError extends errors.SarvamAIError {
7
- constructor(body: SarvamAI.ErrorMessage);
6
+ constructor(body?: unknown);
8
7
  }
@@ -2,7 +2,6 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as errors from "../../errors/index";
5
- import * as SarvamAI from "../index";
6
5
  export declare class TooManyRequestsError extends errors.SarvamAIError {
7
- constructor(body: SarvamAI.ErrorMessage);
6
+ constructor(body?: unknown);
8
7
  }
@@ -0,0 +1,53 @@
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
+ export declare namespace Chat {
8
+ interface Options {
9
+ environment?: core.Supplier<environments.SarvamAIEnvironment | string>;
10
+ /** Specify a custom URL to connect the client to. */
11
+ baseUrl?: core.Supplier<string>;
12
+ apiSubscriptionKey?: core.Supplier<string>;
13
+ }
14
+ interface RequestOptions {
15
+ /** The maximum time to wait for a response in seconds. */
16
+ timeoutInSeconds?: number;
17
+ /** The number of times to retry the request. Defaults to 2. */
18
+ maxRetries?: number;
19
+ /** A hook to abort the request. */
20
+ abortSignal?: AbortSignal;
21
+ /** Additional headers to include in the request. */
22
+ headers?: Record<string, string>;
23
+ }
24
+ }
25
+ export declare class Chat {
26
+ protected readonly _options: Chat.Options;
27
+ constructor(_options?: Chat.Options);
28
+ /**
29
+ * Calls Sarvam LLM API to get the chat completion. Supported model(s): `sarvam-m`.
30
+ *
31
+ * @param {SarvamAI.ChatCompletionsRequest} request
32
+ * @param {Chat.RequestOptions} requestOptions - Request-specific configuration.
33
+ *
34
+ * @throws {@link SarvamAI.BadRequestError}
35
+ * @throws {@link SarvamAI.ForbiddenError}
36
+ * @throws {@link SarvamAI.UnprocessableEntityError}
37
+ * @throws {@link SarvamAI.TooManyRequestsError}
38
+ * @throws {@link SarvamAI.InternalServerError}
39
+ *
40
+ * @example
41
+ * await client.chat.completions({
42
+ * messages: [{
43
+ * role: "assistant",
44
+ * content: "content"
45
+ * }],
46
+ * model: "sarvam-m"
47
+ * })
48
+ */
49
+ completions(request: SarvamAI.ChatCompletionsRequest, requestOptions?: Chat.RequestOptions): Promise<SarvamAI.CreateChatCompletionResponse>;
50
+ protected _getCustomAuthorizationHeaders(): Promise<{
51
+ "api-subscription-key": string | undefined;
52
+ }>;
53
+ }
@@ -0,0 +1,141 @@
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.Chat = 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 Chat {
58
+ constructor(_options = {}) {
59
+ this._options = _options;
60
+ }
61
+ /**
62
+ * Calls Sarvam LLM API to get the chat completion. Supported model(s): `sarvam-m`.
63
+ *
64
+ * @param {SarvamAI.ChatCompletionsRequest} request
65
+ * @param {Chat.RequestOptions} requestOptions - Request-specific configuration.
66
+ *
67
+ * @throws {@link SarvamAI.BadRequestError}
68
+ * @throws {@link SarvamAI.ForbiddenError}
69
+ * @throws {@link SarvamAI.UnprocessableEntityError}
70
+ * @throws {@link SarvamAI.TooManyRequestsError}
71
+ * @throws {@link SarvamAI.InternalServerError}
72
+ *
73
+ * @example
74
+ * await client.chat.completions({
75
+ * messages: [{
76
+ * role: "assistant",
77
+ * content: "content"
78
+ * }],
79
+ * model: "sarvam-m"
80
+ * })
81
+ */
82
+ completions(request, requestOptions) {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ var _a, _b;
85
+ const _response = yield core.fetcher({
86
+ 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, "v1/chat/completions"),
87
+ method: "POST",
88
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.1.2", "User-Agent": "sarvamai/0.1.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
89
+ contentType: "application/json",
90
+ requestType: "json",
91
+ body: Object.assign(Object.assign({}, request), { model: "sarvam-m" }),
92
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
93
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
94
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
95
+ });
96
+ if (_response.ok) {
97
+ return _response.body;
98
+ }
99
+ if (_response.error.reason === "status-code") {
100
+ switch (_response.error.statusCode) {
101
+ case 400:
102
+ throw new SarvamAI.BadRequestError(_response.error.body);
103
+ case 403:
104
+ throw new SarvamAI.ForbiddenError(_response.error.body);
105
+ case 422:
106
+ throw new SarvamAI.UnprocessableEntityError(_response.error.body);
107
+ case 429:
108
+ throw new SarvamAI.TooManyRequestsError(_response.error.body);
109
+ case 500:
110
+ throw new SarvamAI.InternalServerError(_response.error.body);
111
+ default:
112
+ throw new errors.SarvamAIError({
113
+ statusCode: _response.error.statusCode,
114
+ body: _response.error.body,
115
+ });
116
+ }
117
+ }
118
+ switch (_response.error.reason) {
119
+ case "non-json":
120
+ throw new errors.SarvamAIError({
121
+ statusCode: _response.error.statusCode,
122
+ body: _response.error.rawBody,
123
+ });
124
+ case "timeout":
125
+ throw new errors.SarvamAITimeoutError("Timeout exceeded when calling POST /v1/chat/completions.");
126
+ case "unknown":
127
+ throw new errors.SarvamAIError({
128
+ message: _response.error.errorMessage,
129
+ });
130
+ }
131
+ });
132
+ }
133
+ _getCustomAuthorizationHeaders() {
134
+ return __awaiter(this, void 0, void 0, function* () {
135
+ var _a;
136
+ const apiSubscriptionKeyValue = (_a = (yield core.Supplier.get(this._options.apiSubscriptionKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env["SARVAM_API_KEY"];
137
+ return { "api-subscription-key": apiSubscriptionKeyValue };
138
+ });
139
+ }
140
+ }
141
+ exports.Chat = Chat;
@@ -0,0 +1 @@
1
+ export * from "./requests";
@@ -0,0 +1,17 @@
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);
@@ -0,0 +1,63 @@
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
+ * messages: [{
9
+ * role: "assistant",
10
+ * content: "content"
11
+ * }],
12
+ * model: "sarvam-m"
13
+ * }
14
+ */
15
+ export interface ChatCompletionsRequest {
16
+ /** A list of messages comprising the conversation so far. */
17
+ messages: SarvamAI.ChatCompletionRequestMessage[];
18
+ /**
19
+ * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
20
+ * We generally recommend altering this or `top_p` but not both.
21
+ */
22
+ temperature?: number;
23
+ /**
24
+ * An alternative to sampling with temperature, called nucleus sampling,
25
+ * where the model considers the results of the tokens with top_p probability
26
+ * mass. So 0.1 means only the tokens comprising the top 10% probability mass
27
+ * are considered.
28
+ *
29
+ * We generally recommend altering this or `temperature` but not both.
30
+ */
31
+ top_p?: number;
32
+ reasoning_effort?: SarvamAI.ReasoningEffort;
33
+ /** The maximum number of tokens that can be generated in the chat completion. */
34
+ max_tokens?: number;
35
+ /**
36
+ * If set to true, the model response data will be streamed to the client
37
+ * as it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
38
+ */
39
+ stream?: boolean;
40
+ stop?: SarvamAI.StopConfiguration;
41
+ /** How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. */
42
+ n?: number;
43
+ /**
44
+ * This feature is in Beta.
45
+ * If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.
46
+ * Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.
47
+ */
48
+ seed?: number;
49
+ /**
50
+ * Number between -2.0 and 2.0. Positive values penalize new tokens based on
51
+ * their existing frequency in the text so far, decreasing the model's
52
+ * likelihood to repeat the same line verbatim.
53
+ */
54
+ frequency_penalty?: number;
55
+ /**
56
+ * Number between -2.0 and 2.0. Positive values penalize new tokens based on
57
+ * whether they appear in the text so far, increasing the model's likelihood
58
+ * to talk about new topics.
59
+ */
60
+ presence_penalty?: number;
61
+ /** If this parameter is enabled, then the model uses a RAG based approach to retrieve relevant chunks from Wikipedia and uses them to answer the question. This is particularly useful for queries seeking factual information. */
62
+ wiki_grounding?: boolean;
63
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { type ChatCompletionsRequest } from "./ChatCompletionsRequest";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./client";
@@ -0,0 +1,17 @@
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,6 +1,8 @@
1
1
  export * as text from "./text";
2
2
  export * as speechToText from "./speechToText";
3
3
  export * as textToSpeech from "./textToSpeech";
4
+ export * as chat from "./chat";
4
5
  export * from "./text/client/requests";
5
6
  export * from "./speechToText/client/requests";
6
7
  export * from "./textToSpeech/client/requests";
8
+ export * from "./chat/client/requests";
@@ -36,10 +36,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.textToSpeech = exports.speechToText = exports.text = void 0;
39
+ exports.chat = exports.textToSpeech = exports.speechToText = exports.text = void 0;
40
40
  exports.text = __importStar(require("./text"));
41
41
  exports.speechToText = __importStar(require("./speechToText"));
42
42
  exports.textToSpeech = __importStar(require("./textToSpeech"));
43
+ exports.chat = __importStar(require("./chat"));
43
44
  __exportStar(require("./text/client/requests"), exports);
44
45
  __exportStar(require("./speechToText/client/requests"), exports);
45
46
  __exportStar(require("./textToSpeech/client/requests"), exports);
47
+ __exportStar(require("./chat/client/requests"), exports);
@@ -102,7 +102,7 @@ class SpeechToText {
102
102
  const _response = yield core.fetcher({
103
103
  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, "speech-to-text"),
104
104
  method: "POST",
105
- headers: Object.assign(Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.1.1", "User-Agent": "sarvamai/0.1.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
105
+ headers: Object.assign(Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.1.2", "User-Agent": "sarvamai/0.1.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
106
106
  requestType: "file",
107
107
  duplex: _maybeEncodedRequest.duplex,
108
108
  body: _maybeEncodedRequest.body,
@@ -193,7 +193,7 @@ class SpeechToText {
193
193
  const _response = yield core.fetcher({
194
194
  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, "speech-to-text-translate"),
195
195
  method: "POST",
196
- headers: Object.assign(Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.1.1", "User-Agent": "sarvamai/0.1.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
196
+ headers: Object.assign(Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.1.2", "User-Agent": "sarvamai/0.1.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
197
197
  requestType: "file",
198
198
  duplex: _maybeEncodedRequest.duplex,
199
199
  body: _maybeEncodedRequest.body,
@@ -99,7 +99,7 @@ class Text {
99
99
  const _response = yield core.fetcher({
100
100
  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, "translate"),
101
101
  method: "POST",
102
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.1.1", "User-Agent": "sarvamai/0.1.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
102
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.1.2", "User-Agent": "sarvamai/0.1.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
103
103
  contentType: "application/json",
104
104
  requestType: "json",
105
105
  body: request,
@@ -167,7 +167,7 @@ class Text {
167
167
  const _response = yield core.fetcher({
168
168
  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-lid"),
169
169
  method: "POST",
170
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.1.1", "User-Agent": "sarvamai/0.1.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
170
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.1.2", "User-Agent": "sarvamai/0.1.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
171
171
  contentType: "application/json",
172
172
  requestType: "json",
173
173
  body: request,
@@ -259,7 +259,7 @@ class Text {
259
259
  const _response = yield core.fetcher({
260
260
  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, "transliterate"),
261
261
  method: "POST",
262
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.1.1", "User-Agent": "sarvamai/0.1.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
262
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.1.2", "User-Agent": "sarvamai/0.1.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
263
263
  contentType: "application/json",
264
264
  requestType: "json",
265
265
  body: request,
@@ -83,7 +83,7 @@ class TextToSpeech {
83
83
  const _response = yield core.fetcher({
84
84
  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-to-speech"),
85
85
  method: "POST",
86
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.1.1", "User-Agent": "sarvamai/0.1.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
86
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "sarvamai", "X-Fern-SDK-Version": "0.1.2", "User-Agent": "sarvamai/0.1.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
87
87
  contentType: "application/json",
88
88
  requestType: "json",
89
89
  body: request,
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface ChatCompletionRequestAssistantMessage {
5
+ /** The contents of the assistant message */
6
+ content: string;
7
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as SarvamAI from "../index";
5
+ export type ChatCompletionRequestMessage = SarvamAI.ChatCompletionRequestMessage.Assistant | SarvamAI.ChatCompletionRequestMessage.System | SarvamAI.ChatCompletionRequestMessage.User;
6
+ export declare namespace ChatCompletionRequestMessage {
7
+ interface Assistant extends SarvamAI.ChatCompletionRequestAssistantMessage {
8
+ role: "assistant";
9
+ }
10
+ interface System extends SarvamAI.ChatCompletionRequestSystemMessage {
11
+ role: "system";
12
+ }
13
+ interface User extends SarvamAI.ChatCompletionRequestUserMessage {
14
+ role: "user";
15
+ }
16
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface ChatCompletionRequestSystemMessage {
5
+ /** The contents of the system message. */
6
+ content: string;
7
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface ChatCompletionRequestUserMessage {
5
+ /** The contents of the user message. */
6
+ content: string;
7
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as SarvamAI from "../index";
5
+ export interface ChatCompletionResponseMessage {
6
+ /** The contents of the message. */
7
+ content: string;
8
+ /** The role of the author of this message. */
9
+ role: SarvamAI.Role;
10
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as SarvamAI from "../index";
5
+ export interface Choice {
6
+ /**
7
+ * The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
8
+ * `length` if the maximum number of tokens specified in the request was reached,
9
+ * `content_filter` if content was omitted due to a flag from our content filters,
10
+ * `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
11
+ */
12
+ finish_reason: SarvamAI.FinishReason;
13
+ /** The index of the choice in the list of choices. */
14
+ index: number;
15
+ message: SarvamAI.ChatCompletionResponseMessage;
16
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface CompletionUsage {
5
+ /** Number of tokens in the generated completion. */
6
+ completion_tokens: number;
7
+ /** Number of tokens in the prompt. */
8
+ prompt_tokens: number;
9
+ /** Total number of tokens used in the request (prompt + completion). */
10
+ total_tokens: number;
11
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as SarvamAI from "../index";
5
+ export interface CreateChatCompletionResponse {
6
+ /** A unique identifier for the chat completion. */
7
+ id: string;
8
+ /** A list of chat completion choices. Can be more than one if `n` is greater than 1. */
9
+ choices: SarvamAI.Choice[];
10
+ /** The Unix timestamp (in seconds) of when the chat completion was created. */
11
+ created: number;
12
+ /** The model used for the chat completion. */
13
+ model: string;
14
+ /** The object type, which is always `chat.completion`. */
15
+ object: "chat.completion";
16
+ usage?: SarvamAI.CompletionUsage;
17
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });