@orq-ai/node 1.7.0

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 (38) hide show
  1. package/README.md +236 -0
  2. package/package.json +29 -0
  3. package/src/index.d.ts +3 -0
  4. package/src/index.js +7 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/api/deployments.d.ts +42 -0
  7. package/src/lib/api/deployments.js +145 -0
  8. package/src/lib/api/deployments.js.map +1 -0
  9. package/src/lib/api/index.d.ts +1 -0
  10. package/src/lib/api/index.js +5 -0
  11. package/src/lib/api/index.js.map +1 -0
  12. package/src/lib/client.d.ts +11 -0
  13. package/src/lib/client.js +32 -0
  14. package/src/lib/client.js.map +1 -0
  15. package/src/lib/exceptions/index.d.ts +9 -0
  16. package/src/lib/exceptions/index.js +34 -0
  17. package/src/lib/exceptions/index.js.map +1 -0
  18. package/src/lib/http/index.d.ts +8 -0
  19. package/src/lib/http/index.js +20 -0
  20. package/src/lib/http/index.js.map +1 -0
  21. package/src/lib/models/deployments.d.ts +143 -0
  22. package/src/lib/models/deployments.js +40 -0
  23. package/src/lib/models/deployments.js.map +1 -0
  24. package/src/lib/models/index.d.ts +3 -0
  25. package/src/lib/models/index.js +7 -0
  26. package/src/lib/models/index.js.map +1 -0
  27. package/src/lib/models/options.d.ts +12 -0
  28. package/src/lib/models/options.js +3 -0
  29. package/src/lib/models/options.js.map +1 -0
  30. package/src/lib/models/user-info.d.ts +3 -0
  31. package/src/lib/models/user-info.js +3 -0
  32. package/src/lib/models/user-info.js.map +1 -0
  33. package/src/lib/utils/index.d.ts +7 -0
  34. package/src/lib/utils/index.js +49 -0
  35. package/src/lib/utils/index.js.map +1 -0
  36. package/src/lib/version.d.ts +1 -0
  37. package/src/lib/version.js +5 -0
  38. package/src/lib/version.js.map +1 -0
package/README.md ADDED
@@ -0,0 +1,236 @@
1
+ <p align="left">
2
+ <a href="https://orq.ai" target="_blank">
3
+ <img src="https://asset.brandfetch.io/idtBhDRr2x/idcrPsCm4K.png" alt="Orq">
4
+ </a>
5
+ </p>
6
+
7
+ Build AI Applications from Playground to Production
8
+
9
+ # orq.ai Node SDK
10
+
11
+ The orq.ai Node library enables easy orq.ai REST API integration in NodeJS 16+ apps.
12
+
13
+ # Documentation
14
+
15
+ The REST API documentation can be found on [docs.orq.ai](https://docs.orq.ai/reference/authentication).
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install @orq-ai/node
21
+ ```
22
+
23
+ ```bash
24
+ yarn add @orq-ai/node
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ _You can get your workspace API key from the settings section in your orq.ai workspace. `https://my.orq.ai/<workspace>/settings/developers`_
30
+
31
+ Initialize the orq.ai client with your API key:
32
+
33
+ ```ts
34
+ import { createClient } from '@orq-ai/node';
35
+
36
+ const client = createClient({
37
+ apiKey: 'orquesta-api-key',
38
+ environment: 'production',
39
+ });
40
+
41
+ generation = await client.deployments.invoke(
42
+ key: 'customer_service',
43
+ context: { environments: 'production', country: 'NLD' },
44
+ inputs: { firstname: 'John', city: 'New York' },
45
+ metadata: { customer_id: 'Qwtqwty90281' },
46
+ );
47
+ ```
48
+
49
+ ## Deployments
50
+
51
+ The Deployments API delivers text outputs, images or tool calls based on the configuration established within orq.ai for your deployments. Additionally, this API supports streaming. To ensure ease of use and minimize errors, using the code snippets from the orq.ai Admin panel is highly recommended.
52
+
53
+ ### Invoke a deployment
54
+
55
+ #### `invoke()`
56
+
57
+ ```ts
58
+ const generation = await client.deployments.invoke({
59
+ key: 'customer_service',
60
+ context: { environments: 'production', country: 'NLD' },
61
+ inputs: { firstname: 'John', city: 'New York' },
62
+ metadata: { customer_id: 'Qwtqwty90281' },
63
+ });
64
+
65
+ console.log(generation?.choices[0].message.content);
66
+ ```
67
+
68
+ #### `invoke_with_stream()`
69
+
70
+ ```ts
71
+ const deployment = await client.deployments.invoke({
72
+ key: 'customer_service',
73
+ context: { environments: 'production', country: 'NLD' },
74
+ inputs: { firstname: 'John', city: 'New York' },
75
+ metadata: { customer_id: 'Qwtqwty90281' },
76
+ });
77
+
78
+ for await (const chunk of stream) {
79
+ console.log(chunk.choices[0]?.message.content);
80
+ }
81
+ ```
82
+
83
+ #### Adding messages as part of your request
84
+
85
+ If you are using the `invoke` method, you can include `messages` in your request to the model. The `messages` property
86
+ allows you to combine `chat_history` with the prompt configuration in Orq, or to directly send `messages` to the
87
+ model if you are managing the prompt in your code.
88
+
89
+ ```ts
90
+ generation = await client.deployments.invoke(
91
+ key: 'customer_service',
92
+ context:{
93
+ language: [],
94
+ environments: [],
95
+ },
96
+ metadata: {
97
+ 'custom-field-name': 'custom-metadata-value',
98
+ },
99
+ inputs:{ firstname: 'John', city: 'New York' },
100
+ messages: [
101
+ {
102
+ role: 'user',
103
+ content:
104
+ 'A customer is asking about the latest software update features. Generate a detailed and informative response highlighting the key new features and improvements in the latest update.',
105
+ },
106
+ ]
107
+ );
108
+ ```
109
+
110
+ #### Logging metrics to the deployment configuration
111
+
112
+ After invoking, streaming or getting the configuration of a deployment, you can use the `add_metrics` method to add information to the deployment.
113
+
114
+ ```ts
115
+ generation.addMetrics({
116
+ chain_id: 'c4a75b53-62fa-401b-8e97-493f3d299316',
117
+ conversation_id: 'ee7b0c8c-eeb2-43cf-83e9-a4a49f8f13ea',
118
+ user_id: 'e3a202a6-461b-447c-abe2-018ba4d04cd0',
119
+ feedback: { score: 100 },
120
+ metadata: {
121
+ custom: 'custom_metadata',
122
+ chain_id: 'ad1231xsdaABw',
123
+ },
124
+ });
125
+ ```
126
+
127
+ ### Get deployment configuration
128
+
129
+ #### `get_config()`
130
+
131
+ ```ts
132
+ const deploymentPromptConfig = await client.deployments.getConfig({
133
+ key: 'customer_service',
134
+ context: { environments: 'production', country: 'NLD' },
135
+ inputs: { firstname: 'John', city: 'New York' },
136
+ metadata: { customer_id: 'Qwtqwty90281' },
137
+ });
138
+
139
+ console.log(deploymentPromptConfig);
140
+ ```
141
+
142
+ #### Logging metrics to the deployment configuration
143
+
144
+ After invoking, streaming or getting the configuration of a deployment, you can use the `add_metrics` method to add information to the deployment.
145
+
146
+ ```ts
147
+ deploymentPromptConfig.addMetrics({
148
+ chain_id: 'c4a75b53-62fa-401b-8e97-493f3d299316',
149
+ conversation_id: 'ee7b0c8c-eeb2-43cf-83e9-a4a49f8f13ea',
150
+ user_id: 'e3a202a6-461b-447c-abe2-018ba4d04cd0',
151
+ feedback: { score: 100 },
152
+ metadata: {
153
+ custom: 'custom_metadata',
154
+ chain_id: 'ad1231xsdaABw',
155
+ },
156
+ usage: {
157
+ prompt_tokens: 100,
158
+ completion_tokens: 900,
159
+ total_tokens: 1000,
160
+ },
161
+ performance: {
162
+ latency: 9000,
163
+ time_to_first_token: 250,
164
+ },
165
+ });
166
+ ```
167
+
168
+ ### Logging LLM responses
169
+
170
+ Whether you use the `get_config` or `invoke`, you can log the model generations to the deployment. Here are some
171
+ examples of how to do it.
172
+
173
+ #### Logging the completion choices the model generated for the input prompt
174
+
175
+ ```ts
176
+ generation.addMetrics(
177
+ choices:[
178
+ {
179
+ index: 0,
180
+ finish_reason: 'assistant',
181
+ message: {
182
+ role: 'assistant',
183
+ content:
184
+ "Dear customer: Thank you for your interest in our latest software update! We're excited to share with you the new features and improvements we've rolled out. Here's what you can look forward to in this update",
185
+ },
186
+ },
187
+ ]
188
+ );
189
+ ```
190
+
191
+ #### Logging the completion choices the model generated for the input prompt
192
+
193
+ You can save the images generated by the model in Orq. If the image format is `base64` we always store it as
194
+ a `png`.
195
+
196
+ ```ts
197
+ generation.addMetrics(
198
+ choices: [
199
+ {
200
+ index: 0,
201
+ finish_reason: 'stop',
202
+ message: {
203
+ role: 'assistant',
204
+ url: '<image_url>',
205
+ },
206
+ },
207
+ ]
208
+ );
209
+ ```
210
+
211
+ #### Logging the output of the tool calls
212
+
213
+ ```ts
214
+ generation.addMetrics(
215
+ choices: [
216
+ {
217
+ index: 0,
218
+ message: {
219
+ role: 'assistant',
220
+ content: None,
221
+ tool_calls: [
222
+ {
223
+ type: 'function',
224
+ id: 'call_pDBPMMacPXOtoWhTWibW1D94',
225
+ function: {
226
+ name: 'get_weather',
227
+ arguments: '{"location":"San Francisco, CA"}',
228
+ },
229
+ },
230
+ ],
231
+ },
232
+ finish_reason: 'tool_calls',
233
+ },
234
+ ]
235
+ );
236
+ ```
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@orq-ai/node",
3
+ "version": "1.7.0",
4
+ "description": "orq.ai Typescript SDK",
5
+ "author": "orq.ai",
6
+ "homepage": "https://orq.ai",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/orq-ai/orq-node.git"
11
+ },
12
+ "dependencies": {
13
+ "tslib": "^2.3.0",
14
+ "axios": "^1.5.1"
15
+ },
16
+ "keywords": [
17
+ "prompts",
18
+ "typescript",
19
+ "orq.ai",
20
+ "orq",
21
+ "ai",
22
+ "mlops",
23
+ "llmops",
24
+ "generativeai"
25
+ ],
26
+ "type": "commonjs",
27
+ "main": "./src/index.js",
28
+ "typings": "./src/index.d.ts"
29
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './lib/api';
2
+ export * from './lib/client';
3
+ export * from './lib/models';
package/src/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./lib/api"), exports);
5
+ tslib_1.__exportStar(require("./lib/client"), exports);
6
+ tslib_1.__exportStar(require("./lib/models"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../orq-ai-sdk/src/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,uDAA6B;AAC7B,uDAA6B"}
@@ -0,0 +1,42 @@
1
+ import { DeplomentToolCall, DeploymentChoice, DeploymentCommon, DeploymentConfiguration, DeploymentEvent, DeploymentMessage, DeploymentModelType, DeploymentParameter, DeploymentProvider, DeploymentResponse } from "../models";
2
+ export type InvokeDeploymentParams = DeploymentCommon & {
3
+ key: string;
4
+ context?: Record<string, unknown>;
5
+ metadata?: Record<string, unknown>;
6
+ inputs?: Record<string, string>;
7
+ messages?: DeploymentMessage[];
8
+ extra_params?: Record<string, unknown>;
9
+ };
10
+ export declare abstract class BaseDeployment {
11
+ id: string;
12
+ constructor(id: string);
13
+ addMetrics(metrics: DeploymentEvent): Promise<{
14
+ success: boolean;
15
+ } | undefined>;
16
+ }
17
+ export declare class DeploymentPromptConfig extends BaseDeployment implements DeploymentConfiguration {
18
+ private config;
19
+ messages: DeploymentMessage[];
20
+ model: string;
21
+ provider: DeploymentProvider;
22
+ parameters: Record<DeploymentParameter, DeploymentParameter>;
23
+ type: DeploymentModelType;
24
+ tools?: DeplomentToolCall[] | undefined;
25
+ constructor(config: DeploymentPromptConfig);
26
+ }
27
+ export declare class DeploymentGeneration extends BaseDeployment implements DeploymentResponse {
28
+ choices: DeploymentChoice[];
29
+ created: string;
30
+ model: string;
31
+ object: DeploymentModelType;
32
+ finalized: string;
33
+ is_final: boolean;
34
+ provider: DeploymentProvider;
35
+ system_fingerprint: string | undefined;
36
+ constructor(data: DeploymentResponse);
37
+ }
38
+ export declare class Deployment {
39
+ getConfig(params: InvokeDeploymentParams): Promise<DeploymentPromptConfig | undefined>;
40
+ invoke(params: InvokeDeploymentParams): Promise<DeploymentGeneration | undefined>;
41
+ invokeWithStream(params: InvokeDeploymentParams): AsyncGenerator<DeploymentGeneration>;
42
+ }
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Deployment = exports.DeploymentGeneration = exports.DeploymentPromptConfig = exports.BaseDeployment = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const exceptions_1 = require("../exceptions");
6
+ const http_1 = require("../http");
7
+ const utils_1 = require("../utils");
8
+ const DEPLOYMENTS_GET_CONFIG = "deployments/get_config";
9
+ const DEPLOYMENTS_INVOKE = "deployments/invoke";
10
+ const buildAddMetricsUrl = (id) => `deployments/${id}/metrics`;
11
+ function buildDeploymentRequestBody(params) {
12
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ key: params.key }, (params.context && { context: params.context })), (params.metadata && { metadata: params.metadata })), (params.inputs && { inputs: params.inputs })), (params.messages && { messages: params.messages })), (params.extra_params && { extra_params: params.extra_params }));
13
+ }
14
+ class BaseDeployment {
15
+ constructor(id) {
16
+ this.id = id;
17
+ if (!id) {
18
+ throw new Error("Something went wrong while fetching the deployment. Please try again.");
19
+ }
20
+ }
21
+ addMetrics(metrics) {
22
+ var _a;
23
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
24
+ const url = buildAddMetricsUrl(this.id);
25
+ if (!metrics.user_id && ((_a = utils_1.Store.userInfo) === null || _a === void 0 ? void 0 : _a.id)) {
26
+ metrics.user_id = utils_1.Store.userInfo.id;
27
+ }
28
+ try {
29
+ const response = yield (0, http_1.createHttpRequest)({
30
+ method: "POST",
31
+ apiKey: utils_1.Store.apiKey,
32
+ url,
33
+ data: metrics,
34
+ });
35
+ return response.data;
36
+ }
37
+ catch (err) {
38
+ (0, exceptions_1.handleRequestError)(err);
39
+ return;
40
+ }
41
+ });
42
+ }
43
+ }
44
+ exports.BaseDeployment = BaseDeployment;
45
+ class DeploymentPromptConfig extends BaseDeployment {
46
+ constructor(config) {
47
+ super(config.id);
48
+ this.config = config;
49
+ this.messages = this.config.messages;
50
+ this.model = this.config.model;
51
+ this.provider = this.config.provider;
52
+ this.parameters = this.config.parameters;
53
+ this.type = this.config.type;
54
+ this.tools = this.config.tools;
55
+ }
56
+ }
57
+ exports.DeploymentPromptConfig = DeploymentPromptConfig;
58
+ class DeploymentGeneration extends BaseDeployment {
59
+ constructor(data) {
60
+ super(data.id);
61
+ this.created = data.created;
62
+ this.provider = data.provider;
63
+ this.model = data.model;
64
+ this.object = data.object;
65
+ this.finalized = data.finalized;
66
+ this.is_final = data.is_final;
67
+ this.choices = data.choices;
68
+ this.system_fingerprint = data.system_fingerprint;
69
+ }
70
+ }
71
+ exports.DeploymentGeneration = DeploymentGeneration;
72
+ class Deployment {
73
+ getConfig(params) {
74
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
75
+ try {
76
+ const response = yield (0, http_1.createHttpRequest)({
77
+ method: "POST",
78
+ apiKey: utils_1.Store.apiKey,
79
+ url: DEPLOYMENTS_GET_CONFIG,
80
+ data: buildDeploymentRequestBody(params),
81
+ });
82
+ return new DeploymentPromptConfig(response.data);
83
+ }
84
+ catch (err) {
85
+ (0, exceptions_1.handleRequestError)(err);
86
+ return;
87
+ }
88
+ });
89
+ }
90
+ invoke(params) {
91
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
92
+ try {
93
+ const response = yield (0, http_1.createHttpRequest)({
94
+ method: "POST",
95
+ apiKey: utils_1.Store.apiKey,
96
+ url: DEPLOYMENTS_INVOKE,
97
+ data: buildDeploymentRequestBody(params),
98
+ });
99
+ return new DeploymentGeneration(response.data);
100
+ }
101
+ catch (err) {
102
+ (0, exceptions_1.handleRequestError)(err);
103
+ return;
104
+ }
105
+ });
106
+ }
107
+ invokeWithStream(params) {
108
+ return tslib_1.__asyncGenerator(this, arguments, function* invokeWithStream_1() {
109
+ var _a, e_1, _b, _c;
110
+ try {
111
+ const response = yield tslib_1.__await((0, http_1.createHttpRequest)({
112
+ method: "POST",
113
+ apiKey: utils_1.Store.apiKey,
114
+ url: DEPLOYMENTS_INVOKE,
115
+ data: Object.assign(Object.assign({}, buildDeploymentRequestBody(params)), { stream: true }),
116
+ }));
117
+ const stream = response.data;
118
+ try {
119
+ for (var _d = true, stream_1 = tslib_1.__asyncValues(stream), stream_1_1; stream_1_1 = yield tslib_1.__await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true) {
120
+ _c = stream_1_1.value;
121
+ _d = false;
122
+ const chunk = _c;
123
+ const jsonValue = (0, utils_1.extractSSEData)(chunk.toString("utf8"));
124
+ const parsedObjects = (0, utils_1.safeJSONParse)(jsonValue);
125
+ for (const parsedObject of parsedObjects) {
126
+ yield yield tslib_1.__await(new DeploymentGeneration(parsedObject));
127
+ }
128
+ }
129
+ }
130
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
131
+ finally {
132
+ try {
133
+ if (!_d && !_a && (_b = stream_1.return)) yield tslib_1.__await(_b.call(stream_1));
134
+ }
135
+ finally { if (e_1) throw e_1.error; }
136
+ }
137
+ }
138
+ catch (err) {
139
+ (0, exceptions_1.handleRequestError)(err);
140
+ }
141
+ });
142
+ }
143
+ }
144
+ exports.Deployment = Deployment;
145
+ //# sourceMappingURL=deployments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployments.js","sourceRoot":"","sources":["../../../../../orq-ai-sdk/src/lib/api/deployments.ts"],"names":[],"mappings":";;;;AACA,8CAAmD;AACnD,kCAA4C;AAa5C,oCAAgE;AAEhE,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AACxD,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEhD,MAAM,kBAAkB,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,eAAe,EAAE,UAAU,CAAC;AAWvE,SAAS,0BAA0B,CAAC,MAA8B;IACjE,+EACC,GAAG,EAAE,MAAM,CAAC,GAAG,IACZ,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,GAC/C,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,GAClD,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAC5C,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,GAClD,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,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
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./deployments"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../orq-ai-sdk/src/lib/api/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B"}
@@ -0,0 +1,11 @@
1
+ import { Deployment } from "./api";
2
+ import type { OrqAIClientOptions, UserInfo } from "./models";
3
+ export declare function createClient(options: OrqAIClientOptions): Client;
4
+ export declare class Client {
5
+ #private;
6
+ protected apiKey: string;
7
+ protected environment?: string | undefined;
8
+ constructor(apiKey: string, environment?: string | undefined);
9
+ setUser(info: UserInfo): void;
10
+ get deployments(): Deployment;
11
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var _Client_deployments;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Client = exports.createClient = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const api_1 = require("./api");
7
+ const utils_1 = require("./utils");
8
+ function createClient(options) {
9
+ return new Client(options.apiKey, options.environment);
10
+ }
11
+ exports.createClient = createClient;
12
+ class Client {
13
+ constructor(apiKey, environment) {
14
+ this.apiKey = apiKey;
15
+ this.environment = environment;
16
+ _Client_deployments.set(this, null);
17
+ utils_1.Store.apiKey = apiKey;
18
+ utils_1.Store.environment = environment;
19
+ }
20
+ setUser(info) {
21
+ utils_1.Store.userInfo = info;
22
+ }
23
+ get deployments() {
24
+ if (!tslib_1.__classPrivateFieldGet(this, _Client_deployments, "f")) {
25
+ tslib_1.__classPrivateFieldSet(this, _Client_deployments, new api_1.Deployment(), "f");
26
+ }
27
+ return tslib_1.__classPrivateFieldGet(this, _Client_deployments, "f");
28
+ }
29
+ }
30
+ exports.Client = Client;
31
+ _Client_deployments = new WeakMap();
32
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../orq-ai-sdk/src/lib/client.ts"],"names":[],"mappings":";;;;;AAAA,+BAAmC;AAEnC,mCAAgC;AAEhC,SAAgB,YAAY,CAAC,OAA2B;IACvD,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;AACxD,CAAC;AAFD,oCAEC;AAED,MAAa,MAAM;IAGlB,YACW,MAAc,EACd,WAAoB;QADpB,WAAM,GAAN,MAAM,CAAQ;QACd,gBAAW,GAAX,WAAW,CAAS;QAJ/B,8BAAkC,IAAI,EAAC;QAMtC,aAAK,CAAC,MAAM,GAAG,MAAM,CAAC;QACtB,aAAK,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEM,OAAO,CAAC,IAAc;QAC5B,aAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,IAAI,WAAW;QACd,IAAI,CAAC,+BAAA,IAAI,2BAAa,EAAE;YACvB,+BAAA,IAAI,uBAAgB,IAAI,gBAAU,EAAE,MAAA,CAAC;SACrC;QAED,OAAO,+BAAA,IAAI,2BAAa,CAAC;IAC1B,CAAC;CACD;AAtBD,wBAsBC"}
@@ -0,0 +1,9 @@
1
+ export declare function isOrqAIError(payload: any): payload is OrqAIError;
2
+ export declare function handleRequestError(err: unknown): void;
3
+ declare class OrqAIError extends Error {
4
+ error: string;
5
+ code: number;
6
+ source?: string | undefined;
7
+ constructor(error: string, code: number, source?: string | undefined);
8
+ }
9
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleRequestError = exports.isOrqAIError = void 0;
4
+ const axios_1 = require("axios");
5
+ function isOrqAIError(payload) {
6
+ if (payload === null || payload === undefined) {
7
+ return false;
8
+ }
9
+ return ["code", "error", "source"].every((key) => key in payload);
10
+ }
11
+ exports.isOrqAIError = isOrqAIError;
12
+ function handleRequestError(err) {
13
+ var _a, _b;
14
+ if (axios_1.default.isAxiosError(err)) {
15
+ if (err.response && isOrqAIError(err.response.data)) {
16
+ const { code, error, source } = err.response.data;
17
+ throw new OrqAIError(error, code, source);
18
+ }
19
+ throw new OrqAIError("Unexpected error occurred", (_b = (_a = err.response) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 500);
20
+ }
21
+ throw new OrqAIError("Unexpected error occurred", 500);
22
+ }
23
+ exports.handleRequestError = handleRequestError;
24
+ class OrqAIError extends Error {
25
+ constructor(error, code, source) {
26
+ super(error);
27
+ this.error = error;
28
+ this.code = code;
29
+ this.source = source;
30
+ this.name = "OrqAIError";
31
+ this.message = `[${source !== null && source !== void 0 ? source : "OrqAI"}][${code}]: ${error}`;
32
+ }
33
+ }
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../orq-ai-sdk/src/lib/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,iCAA0B;AAE1B,SAAgB,YAAY,CAAC,OAAY;IACxC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE;QAC9C,OAAO,KAAK,CAAC;KACb;IAED,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC;AACnE,CAAC;AAND,oCAMC;AAED,SAAgB,kBAAkB,CAAC,GAAY;;IAC9C,IAAI,eAAK,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE;QAC5B,IAAI,GAAG,CAAC,QAAQ,IAAI,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACpD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;YAClD,MAAM,IAAI,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;SAC1C;QACD,MAAM,IAAI,UAAU,CACnB,2BAA2B,EAC3B,MAAA,MAAA,GAAG,CAAC,QAAQ,0CAAE,MAAM,mCAAI,GAAG,CAC3B,CAAC;KACF;IAED,MAAM,IAAI,UAAU,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;AACxD,CAAC;AAbD,gDAaC;AAED,MAAM,UAAW,SAAQ,KAAK;IAC7B,YACQ,KAAa,EACb,IAAY,EACZ,MAAe;QAEtB,KAAK,CAAC,KAAK,CAAC,CAAC;QAJN,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAS;QAGtB,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,OAAO,KAAK,IAAI,MAAM,KAAK,EAAE,CAAC;IAC5D,CAAC;CACD"}
@@ -0,0 +1,8 @@
1
+ export declare function createHttpRequest<T extends {
2
+ [key: string]: any;
3
+ }>({ method, url, apiKey, data, }: {
4
+ method: string;
5
+ url: string;
6
+ apiKey: string;
7
+ data?: T;
8
+ }): Promise<import("axios").AxiosResponse<any, any>>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createHttpRequest = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const axios_1 = require("axios");
6
+ const axiosInstance = axios_1.default.create({
7
+ baseURL: "https://api.orq.ai/v2",
8
+ });
9
+ // Create a function that allow to create an http request with axios
10
+ function createHttpRequest({ method, url, apiKey, data, }) {
11
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ return axiosInstance(Object.assign(Object.assign({ method,
13
+ url, headers: {
14
+ "Content-Type": "application/json",
15
+ Authorization: `Bearer ${apiKey}`,
16
+ } }, (data && { data })), ((data === null || data === void 0 ? void 0 : data["stream"]) && { responseType: "stream" })));
17
+ });
18
+ }
19
+ exports.createHttpRequest = createHttpRequest;
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../orq-ai-sdk/src/lib/http/index.ts"],"names":[],"mappings":";;;;AAAA,iCAA0B;AAE1B,MAAM,aAAa,GAAG,eAAK,CAAC,MAAM,CAAC;IAClC,OAAO,EAAE,uBAAuB;CAChC,CAAC,CAAC;AAEH,oEAAoE;AACpE,SAAsB,iBAAiB,CAAmC,EACzE,MAAM,EACN,GAAG,EACH,MAAM,EACN,IAAI,GAMJ;;QACA,OAAO,aAAa,+BACnB,MAAM;YACN,GAAG,EACH,OAAO,EAAE;gBACR,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,UAAU,MAAM,EAAE;aACjC,IACE,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC,GAClB,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,QAAQ,CAAC,KAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,EAClD,CAAC;IACJ,CAAC;CAAA;AArBD,8CAqBC"}
@@ -0,0 +1,143 @@
1
+ export declare enum DeploymentProvider {
2
+ Cohere = "cohere",
3
+ OpenAI = "openai",
4
+ Anthropic = "anthropic",
5
+ Google = "google",
6
+ Azure = "azure",
7
+ Aws = "aws",
8
+ Anyscale = "anyscale"
9
+ }
10
+ export declare enum DeploymentModelType {
11
+ Completion = "completion",
12
+ Chat = "chat",
13
+ Image = "image"
14
+ }
15
+ export declare enum DeploymentParameter {
16
+ TopK = "topK",
17
+ TopP = "topP",
18
+ Temperature = "temperature",
19
+ FrequencyPenalty = "frequencyPenalty",
20
+ PresencePenalty = "presencePenalty",
21
+ MaxTokens = "maxTokens",
22
+ NumImages = "numImages",
23
+ Format = "format",
24
+ Dimensions = "dimensions",
25
+ Quality = "quality",
26
+ Style = "style"
27
+ }
28
+ export declare enum DeploymentMessageRole {
29
+ System = "system",
30
+ User = "user",
31
+ Assistant = "assistant"
32
+ }
33
+ export type DeploymentMessage = {
34
+ role: DeploymentMessageRole;
35
+ content: string;
36
+ };
37
+ export type DeploymentToolFunctionParameters = {
38
+ type: "object";
39
+ properties: Record<string, {
40
+ type: string;
41
+ description: string;
42
+ }>;
43
+ required: string[];
44
+ };
45
+ export type DeploymentToolFunction = {
46
+ name: string;
47
+ description?: string;
48
+ parameters: DeploymentToolFunctionParameters;
49
+ };
50
+ export type DeploymentToolCallFunction = {
51
+ name: string;
52
+ arguments: string;
53
+ };
54
+ export type DeplomentToolCall = {
55
+ type: "function";
56
+ function: DeploymentToolCallFunction;
57
+ };
58
+ export type DeploymentConfiguration = {
59
+ id: string;
60
+ provider: DeploymentProvider;
61
+ model: string;
62
+ type: DeploymentModelType;
63
+ messages: DeploymentMessage[];
64
+ parameters: Record<string, DeploymentParameter>;
65
+ tools?: DeplomentToolCall[];
66
+ };
67
+ export type DeploymentChoiceContent = {
68
+ role: DeploymentMessageRole.Assistant;
69
+ content: string;
70
+ };
71
+ export type DeploymentChoiceImage = {
72
+ role: DeploymentMessageRole.Assistant;
73
+ url: string;
74
+ };
75
+ export type DeploymentChoiceToolCalls = {
76
+ role: DeploymentMessageRole.Assistant;
77
+ tool_calls: DeplomentToolCall[];
78
+ };
79
+ export type DeploymentChoiceMessage = DeploymentChoiceContent | DeploymentChoiceImage | DeploymentChoiceToolCalls;
80
+ export type DeploymentChoice = {
81
+ index: number;
82
+ message: DeploymentChoiceContent & DeploymentChoiceImage & DeploymentChoiceToolCalls;
83
+ finish_reason: string;
84
+ };
85
+ /**
86
+ * Represents the response object for a deployment.
87
+ */
88
+ export type DeploymentResponse = Omit<DeploymentConfiguration, "tools" | "parameters" | "messages" | "type"> & {
89
+ /**
90
+ * The timestamp when the deployment was created.
91
+ */
92
+ created: string;
93
+ /**
94
+ * The object type of the deployment.
95
+ */
96
+ object: DeploymentModelType;
97
+ /**
98
+ * The model associated with the deployment.
99
+ */
100
+ model: string;
101
+ /**
102
+ * The provider of the deployment.
103
+ */
104
+ provider: DeploymentProvider;
105
+ /**
106
+ * Indicates whether the deployment response is the final response. Useful for streaming.
107
+ */
108
+ is_final: boolean;
109
+ /**
110
+ * The timestamp when the deployment was finalized.
111
+ */
112
+ finalized: string;
113
+ /**
114
+ * The choices returned by the deployment model
115
+ */
116
+ choices: DeploymentChoice[];
117
+ /**
118
+ * The system fingerprint returned by the provider
119
+ */
120
+ system_fingerprint?: string;
121
+ };
122
+ export type DeploymentCommon = {
123
+ chain_id?: string;
124
+ conversation_id?: string;
125
+ user_id?: string;
126
+ };
127
+ export type DeploymentEvent = DeploymentCommon & {
128
+ metadata?: Record<string, unknown>;
129
+ feedback?: {
130
+ score: number;
131
+ };
132
+ usage?: {
133
+ prompt_tokens: number;
134
+ completion_tokens: number;
135
+ total_tokens?: number;
136
+ };
137
+ performance?: {
138
+ latency?: number;
139
+ time_to_first_token?: number;
140
+ };
141
+ choices?: DeploymentChoice[];
142
+ messages?: DeploymentMessage[];
143
+ };
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeploymentMessageRole = exports.DeploymentParameter = exports.DeploymentModelType = exports.DeploymentProvider = void 0;
4
+ var DeploymentProvider;
5
+ (function (DeploymentProvider) {
6
+ DeploymentProvider["Cohere"] = "cohere";
7
+ DeploymentProvider["OpenAI"] = "openai";
8
+ DeploymentProvider["Anthropic"] = "anthropic";
9
+ DeploymentProvider["Google"] = "google";
10
+ DeploymentProvider["Azure"] = "azure";
11
+ DeploymentProvider["Aws"] = "aws";
12
+ DeploymentProvider["Anyscale"] = "anyscale";
13
+ })(DeploymentProvider || (exports.DeploymentProvider = DeploymentProvider = {}));
14
+ var DeploymentModelType;
15
+ (function (DeploymentModelType) {
16
+ DeploymentModelType["Completion"] = "completion";
17
+ DeploymentModelType["Chat"] = "chat";
18
+ DeploymentModelType["Image"] = "image";
19
+ })(DeploymentModelType || (exports.DeploymentModelType = DeploymentModelType = {}));
20
+ var DeploymentParameter;
21
+ (function (DeploymentParameter) {
22
+ DeploymentParameter["TopK"] = "topK";
23
+ DeploymentParameter["TopP"] = "topP";
24
+ DeploymentParameter["Temperature"] = "temperature";
25
+ DeploymentParameter["FrequencyPenalty"] = "frequencyPenalty";
26
+ DeploymentParameter["PresencePenalty"] = "presencePenalty";
27
+ DeploymentParameter["MaxTokens"] = "maxTokens";
28
+ DeploymentParameter["NumImages"] = "numImages";
29
+ DeploymentParameter["Format"] = "format";
30
+ DeploymentParameter["Dimensions"] = "dimensions";
31
+ DeploymentParameter["Quality"] = "quality";
32
+ DeploymentParameter["Style"] = "style";
33
+ })(DeploymentParameter || (exports.DeploymentParameter = DeploymentParameter = {}));
34
+ var DeploymentMessageRole;
35
+ (function (DeploymentMessageRole) {
36
+ DeploymentMessageRole["System"] = "system";
37
+ DeploymentMessageRole["User"] = "user";
38
+ DeploymentMessageRole["Assistant"] = "assistant";
39
+ })(DeploymentMessageRole || (exports.DeploymentMessageRole = DeploymentMessageRole = {}));
40
+ //# sourceMappingURL=deployments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployments.js","sourceRoot":"","sources":["../../../../../orq-ai-sdk/src/lib/models/deployments.ts"],"names":[],"mappings":";;;AAAA,IAAY,kBAQX;AARD,WAAY,kBAAkB;IAC7B,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,6CAAuB,CAAA;IACvB,uCAAiB,CAAA;IACjB,qCAAe,CAAA;IACf,iCAAW,CAAA;IACX,2CAAqB,CAAA;AACtB,CAAC,EARW,kBAAkB,kCAAlB,kBAAkB,QAQ7B;AAED,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC9B,gDAAyB,CAAA;IACzB,oCAAa,CAAA;IACb,sCAAe,CAAA;AAChB,CAAC,EAJW,mBAAmB,mCAAnB,mBAAmB,QAI9B;AAED,IAAY,mBAYX;AAZD,WAAY,mBAAmB;IAC9B,oCAAa,CAAA;IACb,oCAAa,CAAA;IACb,kDAA2B,CAAA;IAC3B,4DAAqC,CAAA;IACrC,0DAAmC,CAAA;IACnC,8CAAuB,CAAA;IACvB,8CAAuB,CAAA;IACvB,wCAAiB,CAAA;IACjB,gDAAyB,CAAA;IACzB,0CAAmB,CAAA;IACnB,sCAAe,CAAA;AAChB,CAAC,EAZW,mBAAmB,mCAAnB,mBAAmB,QAY9B;AAED,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAChC,0CAAiB,CAAA;IACjB,sCAAa,CAAA;IACb,gDAAuB,CAAA;AACxB,CAAC,EAJW,qBAAqB,qCAArB,qBAAqB,QAIhC"}
@@ -0,0 +1,3 @@
1
+ export * from './deployments';
2
+ export * from './options';
3
+ export * from './user-info';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./deployments"), exports);
5
+ tslib_1.__exportStar(require("./options"), exports);
6
+ tslib_1.__exportStar(require("./user-info"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../orq-ai-sdk/src/lib/models/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,oDAA0B;AAC1B,sDAA4B"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Options for configuring the orq.ai client.
3
+ *
4
+ * @type
5
+ * @property {string} apiKey - The API key for authenticating requests. This is a required field.
6
+ * @property {string} [environment] - The environment the client is interacting with, e.g., 'production' or 'development'.
7
+ * This field is optional.
8
+ */
9
+ export type OrqAIClientOptions = {
10
+ apiKey: string;
11
+ environment?: string;
12
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../../orq-ai-sdk/src/lib/models/options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export interface UserInfo {
2
+ id: string;
3
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=user-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-info.js","sourceRoot":"","sources":["../../../../../orq-ai-sdk/src/lib/models/user-info.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { OrqAIClientOptions, UserInfo } from "../models";
2
+ export declare function extractSSEData(input: string): string;
3
+ export declare function safeJSONParse(input: string): any[];
4
+ export declare function parseJson(input: string): any[];
5
+ export declare const Store: OrqAIClientOptions & {
6
+ userInfo?: UserInfo;
7
+ };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Store = exports.parseJson = exports.safeJSONParse = exports.extractSSEData = void 0;
4
+ function extractSSEData(input) {
5
+ const entries = input.split("\n\n");
6
+ return entries.map((entry) => entry.replace(/^data: /, "").trim()).join("");
7
+ }
8
+ exports.extractSSEData = extractSSEData;
9
+ function safeJSONParse(input) {
10
+ const cleanedInput = input.replace(/\[DONE\]/g, "");
11
+ if (!cleanedInput || cleanedInput === "[DONE]") {
12
+ return [];
13
+ }
14
+ return parseJson(cleanedInput);
15
+ }
16
+ exports.safeJSONParse = safeJSONParse;
17
+ function parseJson(input) {
18
+ const results = [];
19
+ let braceCount = 0;
20
+ let currentObject = "";
21
+ let inString = false;
22
+ for (const char of input) {
23
+ if (char === '"' && currentObject[currentObject.length - 1] !== "\\") {
24
+ inString = !inString;
25
+ }
26
+ if (char === "{" && !inString) {
27
+ braceCount++;
28
+ }
29
+ if (char === "}" && !inString) {
30
+ braceCount--;
31
+ }
32
+ currentObject += char;
33
+ if (braceCount === 0 && currentObject !== "") {
34
+ try {
35
+ const parsed = JSON.parse(currentObject);
36
+ results.push(parsed);
37
+ }
38
+ catch (e) {
39
+ // eslint-disable-next-line no-console
40
+ continue;
41
+ }
42
+ currentObject = "";
43
+ }
44
+ }
45
+ return results;
46
+ }
47
+ exports.parseJson = parseJson;
48
+ exports.Store = {};
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../orq-ai-sdk/src/lib/utils/index.ts"],"names":[],"mappings":";;;AAEA,SAAgB,cAAc,CAAC,KAAa;IAC3C,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC;AAHD,wCAGC;AAED,SAAgB,aAAa,CAAC,KAAa;IAC1C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAEpD,IAAI,CAAC,YAAY,IAAI,YAAY,KAAK,QAAQ,EAAE;QAC/C,OAAO,EAAE,CAAC;KACV;IAED,OAAO,SAAS,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AARD,sCAQC;AAED,SAAgB,SAAS,CAAC,KAAa;IACtC,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,aAAa,GAAG,EAAE,CAAC;IACvB,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACzB,IAAI,IAAI,KAAK,GAAG,IAAI,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE;YACrE,QAAQ,GAAG,CAAC,QAAQ,CAAC;SACrB;QAED,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE;YAC9B,UAAU,EAAE,CAAC;SACb;QACD,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE;YAC9B,UAAU,EAAE,CAAC;SACb;QAED,aAAa,IAAI,IAAI,CAAC;QAEtB,IAAI,UAAU,KAAK,CAAC,IAAI,aAAa,KAAK,EAAE,EAAE;YAC7C,IAAI;gBACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;gBACzC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACrB;YAAC,OAAO,CAAC,EAAE;gBACX,sCAAsC;gBACtC,SAAS;aACT;YACD,aAAa,GAAG,EAAE,CAAC;SACnB;KACD;IAED,OAAO,OAAO,CAAC;AAChB,CAAC;AAjCD,8BAiCC;AACY,QAAA,KAAK,GACjB,EAAwB,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const version = "2.1.0";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.version = void 0;
4
+ exports.version = "2.1.0";
5
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../orq-ai-sdk/src/lib/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC"}