@halix/action-sdk 1.0.32 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/ai.js +32 -163
- package/lib/cjs/index.js +1 -4
- package/lib/cjs/types/ai.d.ts +11 -19
- package/lib/cjs/types/ai.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +1 -1
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/esm/ai.js +33 -155
- package/lib/esm/ai.js.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/index.mjs +0 -2
- package/lib/esm/types/ai.d.ts +11 -19
- package/lib/esm/types/index.d.ts +1 -1
- package/package.json +1 -1
package/lib/cjs/ai.js
CHANGED
|
@@ -20,7 +20,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
20
20
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.LLMProvider = void 0;
|
|
24
23
|
exports.sendAIMessage = sendAIMessage;
|
|
25
24
|
exports.sendAIMessageAsObservable = sendAIMessageAsObservable;
|
|
26
25
|
/**
|
|
@@ -31,192 +30,62 @@ exports.sendAIMessageAsObservable = sendAIMessageAsObservable;
|
|
|
31
30
|
*/
|
|
32
31
|
const axios_1 = __importDefault(require("axios"));
|
|
33
32
|
const rxjs_1 = require("rxjs");
|
|
34
|
-
const
|
|
35
|
-
// ================================================================================
|
|
36
|
-
// TYPES AND ENUMS
|
|
37
|
-
// ================================================================================
|
|
38
|
-
/**
|
|
39
|
-
* Supported LLM providers.
|
|
40
|
-
*/
|
|
41
|
-
var LLMProvider;
|
|
42
|
-
(function (LLMProvider) {
|
|
43
|
-
LLMProvider["Anthropic"] = "anthropic";
|
|
44
|
-
LLMProvider["OpenAI"] = "openai";
|
|
45
|
-
LLMProvider["Google"] = "google";
|
|
46
|
-
LLMProvider["xAI"] = "xai";
|
|
47
|
-
})(LLMProvider || (exports.LLMProvider = LLMProvider = {}));
|
|
48
|
-
// ================================================================================
|
|
49
|
-
// INTERNAL HELPERS
|
|
50
|
-
// ================================================================================
|
|
51
|
-
/**
|
|
52
|
-
* Maps an LLM provider to the corresponding organization preference key.
|
|
53
|
-
*/
|
|
54
|
-
const providerPreferenceKeys = {
|
|
55
|
-
[LLMProvider.Anthropic]: 'AnthropicAPIKey',
|
|
56
|
-
[LLMProvider.OpenAI]: 'OpenAIAPIKey',
|
|
57
|
-
[LLMProvider.Google]: 'GoogleAPIKey',
|
|
58
|
-
[LLMProvider.xAI]: 'xAIAPIKey'
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Detects the LLM provider from a model name string.
|
|
62
|
-
*
|
|
63
|
-
* @param model - The model identifier (e.g. 'claude-3-sonnet', 'gpt-4o', 'gemini-2.0-flash', 'grok-3')
|
|
64
|
-
* @returns The detected LLMProvider
|
|
65
|
-
* @throws Error if the model name cannot be mapped to a known provider
|
|
66
|
-
*/
|
|
67
|
-
function detectProvider(model) {
|
|
68
|
-
const lowerModel = model.toLowerCase();
|
|
69
|
-
if (lowerModel.startsWith('claude')) {
|
|
70
|
-
return LLMProvider.Anthropic;
|
|
71
|
-
}
|
|
72
|
-
if (lowerModel.startsWith('gpt') || lowerModel.startsWith('o1') || lowerModel.startsWith('o3') || lowerModel.startsWith('o4')) {
|
|
73
|
-
return LLMProvider.OpenAI;
|
|
74
|
-
}
|
|
75
|
-
if (lowerModel.startsWith('gemini')) {
|
|
76
|
-
return LLMProvider.Google;
|
|
77
|
-
}
|
|
78
|
-
if (lowerModel.startsWith('grok')) {
|
|
79
|
-
return LLMProvider.xAI;
|
|
80
|
-
}
|
|
81
|
-
throw new Error(`Unable to detect LLM provider for model "${model}". ` +
|
|
82
|
-
`Supported model prefixes: claude (Anthropic), gpt/o1/o3/o4 (OpenAI), gemini (Google), grok (xAI).`);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Fetches the API key for the given provider from organization preferences.
|
|
86
|
-
*/
|
|
87
|
-
function getApiKey(provider) {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
const prefKey = providerPreferenceKeys[provider];
|
|
90
|
-
const apiKey = yield (0, preferences_1.getOrganizationPreference)(prefKey);
|
|
91
|
-
if (!apiKey) {
|
|
92
|
-
throw new Error(`API key not configured. Set the "${prefKey}" organization preference to use ${provider} models.`);
|
|
93
|
-
}
|
|
94
|
-
return apiKey;
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Sends a message to the Anthropic Messages API and returns the response text.
|
|
99
|
-
*/
|
|
100
|
-
function callAnthropic(model, message, apiKey, options) {
|
|
101
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
var _a;
|
|
103
|
-
const body = {
|
|
104
|
-
model,
|
|
105
|
-
max_tokens: (_a = options.maxTokens) !== null && _a !== void 0 ? _a : 1024,
|
|
106
|
-
messages: [{ role: 'user', content: message }]
|
|
107
|
-
};
|
|
108
|
-
if (options.systemPrompt) {
|
|
109
|
-
body.system = options.systemPrompt;
|
|
110
|
-
}
|
|
111
|
-
const response = yield axios_1.default.post('https://api.anthropic.com/v1/messages', body, {
|
|
112
|
-
headers: {
|
|
113
|
-
'x-api-key': apiKey,
|
|
114
|
-
'anthropic-version': '2023-06-01',
|
|
115
|
-
'Content-Type': 'application/json'
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
return response.data.content[0].text;
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Sends a message to an OpenAI-compatible chat completions API and returns the response text.
|
|
123
|
-
* Used for both OpenAI and xAI (which uses the same API format).
|
|
124
|
-
*/
|
|
125
|
-
function callOpenAICompatible(baseUrl, model, message, apiKey, options) {
|
|
126
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
var _a;
|
|
128
|
-
const messages = [];
|
|
129
|
-
if (options.systemPrompt) {
|
|
130
|
-
messages.push({ role: 'system', content: options.systemPrompt });
|
|
131
|
-
}
|
|
132
|
-
messages.push({ role: 'user', content: message });
|
|
133
|
-
// GPT-5.x and newer models require max_completion_tokens instead of max_tokens
|
|
134
|
-
const lowerModel = model.toLowerCase();
|
|
135
|
-
const useMaxCompletionTokens = lowerModel.startsWith('gpt-5') || lowerModel.startsWith('gpt-6');
|
|
136
|
-
const tokenLimit = (_a = options.maxTokens) !== null && _a !== void 0 ? _a : 1024;
|
|
137
|
-
const body = Object.assign({ model,
|
|
138
|
-
messages }, (useMaxCompletionTokens
|
|
139
|
-
? { max_completion_tokens: tokenLimit }
|
|
140
|
-
: { max_tokens: tokenLimit }));
|
|
141
|
-
const response = yield axios_1.default.post(`${baseUrl}/chat/completions`, body, {
|
|
142
|
-
headers: {
|
|
143
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
144
|
-
'Content-Type': 'application/json'
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
return response.data.choices[0].message.content;
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Sends a message to the Google Gemini API and returns the response text.
|
|
152
|
-
*/
|
|
153
|
-
function callGoogle(model, message, apiKey, options) {
|
|
154
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
-
var _a;
|
|
156
|
-
const contents = [];
|
|
157
|
-
if (options.systemPrompt) {
|
|
158
|
-
contents.push({ role: 'user', parts: [{ text: options.systemPrompt }] });
|
|
159
|
-
contents.push({ role: 'model', parts: [{ text: 'Understood.' }] });
|
|
160
|
-
}
|
|
161
|
-
contents.push({ role: 'user', parts: [{ text: message }] });
|
|
162
|
-
const body = {
|
|
163
|
-
contents,
|
|
164
|
-
generationConfig: {
|
|
165
|
-
maxOutputTokens: (_a = options.maxTokens) !== null && _a !== void 0 ? _a : 1024
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
const response = yield axios_1.default.post(`https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent?key=${apiKey}`, body, {
|
|
169
|
-
headers: { 'Content-Type': 'application/json' }
|
|
170
|
-
});
|
|
171
|
-
return response.data.candidates[0].content.parts[0].text;
|
|
172
|
-
});
|
|
173
|
-
}
|
|
33
|
+
const sdk_general_1 = require("./sdk-general");
|
|
174
34
|
// ================================================================================
|
|
175
35
|
// PUBLIC API
|
|
176
36
|
// ================================================================================
|
|
177
37
|
/**
|
|
178
38
|
* Sends a message to an LLM and returns its text response.
|
|
179
39
|
*
|
|
180
|
-
*
|
|
181
|
-
* API key
|
|
182
|
-
*
|
|
183
|
-
* -
|
|
184
|
-
* -
|
|
185
|
-
* -
|
|
40
|
+
* All requests are proxied through the Halix service, which handles provider
|
|
41
|
+
* authentication and API key management server-side. The LLM provider is
|
|
42
|
+
* automatically detected from the model name:
|
|
43
|
+
* - Anthropic (claude-*)
|
|
44
|
+
* - OpenAI (gpt-*, o1-*, o3-*, o4-*)
|
|
45
|
+
* - Google (gemini-*)
|
|
46
|
+
* - xAI (grok-*)
|
|
186
47
|
*
|
|
187
48
|
* @param message - The user message to send to the model
|
|
188
|
-
* @param model - The model identifier (e.g. 'claude-
|
|
49
|
+
* @param model - The model identifier (e.g. 'claude-sonnet-4-5', 'gpt-4.1', 'gemini-3-pro-preview', 'grok-3')
|
|
189
50
|
* @param options - Optional configuration (system prompt, max tokens)
|
|
190
51
|
* @returns Promise<string> - The model's text response
|
|
191
|
-
* @throws Error if SDK not initialized
|
|
52
|
+
* @throws Error if SDK not initialized or the request fails
|
|
192
53
|
*
|
|
193
54
|
* @example
|
|
194
55
|
* // Simple usage
|
|
195
|
-
* const response = await sendAIMessage('What is the capital of France?', 'gpt-
|
|
56
|
+
* const response = await sendAIMessage('What is the capital of France?', 'gpt-4.1');
|
|
196
57
|
*
|
|
197
58
|
* @example
|
|
198
59
|
* // With options
|
|
199
60
|
* const response = await sendAIMessage(
|
|
200
61
|
* 'Summarize this document.',
|
|
201
|
-
* 'claude-
|
|
62
|
+
* 'claude-sonnet-4-5',
|
|
202
63
|
* { systemPrompt: 'You are a helpful assistant.', maxTokens: 2048 }
|
|
203
64
|
* );
|
|
204
65
|
*/
|
|
205
66
|
function sendAIMessage(message, model, options) {
|
|
206
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
case LLMProvider.Anthropic:
|
|
212
|
-
return callAnthropic(model, message, apiKey, resolvedOptions);
|
|
213
|
-
case LLMProvider.OpenAI:
|
|
214
|
-
return callOpenAICompatible('https://api.openai.com/v1', model, message, apiKey, resolvedOptions);
|
|
215
|
-
case LLMProvider.Google:
|
|
216
|
-
return callGoogle(model, message, apiKey, resolvedOptions);
|
|
217
|
-
case LLMProvider.xAI:
|
|
218
|
-
return callOpenAICompatible('https://api.x.ai/v1', model, message, apiKey, resolvedOptions);
|
|
68
|
+
if (!sdk_general_1.getAuthToken) {
|
|
69
|
+
const errorMessage = 'SDK not initialized.';
|
|
70
|
+
console.error(errorMessage);
|
|
71
|
+
throw new Error(errorMessage);
|
|
219
72
|
}
|
|
73
|
+
const url = `${sdk_general_1.serviceAddress}/assistant/sandboxes/${sdk_general_1.sandboxKey}/sendMessage`;
|
|
74
|
+
const body = {
|
|
75
|
+
message,
|
|
76
|
+
model,
|
|
77
|
+
};
|
|
78
|
+
if (options === null || options === void 0 ? void 0 : options.systemPrompt) {
|
|
79
|
+
body.systemPrompt = options.systemPrompt;
|
|
80
|
+
}
|
|
81
|
+
if (options === null || options === void 0 ? void 0 : options.maxTokens) {
|
|
82
|
+
body.maxTokens = options.maxTokens;
|
|
83
|
+
}
|
|
84
|
+
const authToken = yield (0, rxjs_1.lastValueFrom)((0, sdk_general_1.getAuthToken)());
|
|
85
|
+
const response = yield axios_1.default.post(url, body, {
|
|
86
|
+
headers: { 'Authorization': `Bearer ${authToken}` },
|
|
87
|
+
});
|
|
88
|
+
return response.data;
|
|
220
89
|
});
|
|
221
90
|
}
|
|
222
91
|
/**
|
package/lib/cjs/index.js
CHANGED
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
// Unauthorized use outside the Halix platform is prohibited.
|
|
9
9
|
// Full license terms available in the LICENSE file.
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.getValueFromObject = exports.compareValues = exports.sortObjectArray = exports.sendAIMessageAsObservable = exports.sendAIMessage = exports.
|
|
12
|
-
exports.debounceFn = void 0;
|
|
11
|
+
exports.debounceFn = exports.getValueFromObject = exports.compareValues = exports.sortObjectArray = exports.sendAIMessageAsObservable = exports.sendAIMessage = exports.getAggregateDataAsObservable = exports.getAggregateData = exports.AggregationResponse = exports.massDeleteAsObservable = exports.massDelete = exports.massEditAsObservable = exports.massEdit = exports.getListDataAsObservable = exports.getListData = exports.getOrganizationPreferenceAsObservable = exports.getUserPreferenceAsObservable = exports.getOrganizationPreference = exports.getUserPreference = exports.sendMessageAsObservable = exports.sendMessage = exports.MessageMethod = exports.createOrUpdateResourceAsObservable = exports.createOrUpdateResource = exports.sendFileContentsAsObservable = exports.sendFileContents = exports.saveResourceAsObservable = exports.saveResource = exports.getOrCreateResourceAsObservable = exports.getOrCreateResource = exports.deleteRelatedObjectsAsObservable = exports.deleteRelatedObjects = exports.deleteRelatedObjectAsObservable = exports.deleteRelatedObject = exports.saveRelatedObjectAsObservable = exports.saveRelatedObject = exports.getRelatedObjectsAsObservable = exports.getRelatedObjects = exports.getObjectAsObservable = exports.getObject = exports.prepareErrorResponse = exports.prepareSuccessResponse = exports.initialize = exports.useBody = exports.params = exports.userContext = exports.actionSubject = exports.serviceAddress = exports.sandboxKey = exports.getAuthToken = void 0;
|
|
13
12
|
/**
|
|
14
13
|
* @module @halix/action-sdk
|
|
15
14
|
* @description Halix Platform action SDK for developing NodeJS Lambda-based actions on the Halix
|
|
@@ -104,8 +103,6 @@ Object.defineProperty(exports, "getAggregateDataAsObservable", { enumerable: tru
|
|
|
104
103
|
// AI FUNCTIONS
|
|
105
104
|
// ================================================================================
|
|
106
105
|
var ai_1 = require("./ai");
|
|
107
|
-
// AI Enums
|
|
108
|
-
Object.defineProperty(exports, "LLMProvider", { enumerable: true, get: function () { return ai_1.LLMProvider; } });
|
|
109
106
|
// AI Functions
|
|
110
107
|
Object.defineProperty(exports, "sendAIMessage", { enumerable: true, get: function () { return ai_1.sendAIMessage; } });
|
|
111
108
|
Object.defineProperty(exports, "sendAIMessageAsObservable", { enumerable: true, get: function () { return ai_1.sendAIMessageAsObservable; } });
|
package/lib/cjs/types/ai.d.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
/**
|
|
3
|
-
* Supported LLM providers.
|
|
4
|
-
*/
|
|
5
|
-
export declare enum LLMProvider {
|
|
6
|
-
Anthropic = "anthropic",
|
|
7
|
-
OpenAI = "openai",
|
|
8
|
-
Google = "google",
|
|
9
|
-
xAI = "xai"
|
|
10
|
-
}
|
|
11
2
|
/**
|
|
12
3
|
* Options for configuring an AI message request.
|
|
13
4
|
*/
|
|
@@ -20,28 +11,29 @@ export interface AIRequestOptions {
|
|
|
20
11
|
/**
|
|
21
12
|
* Sends a message to an LLM and returns its text response.
|
|
22
13
|
*
|
|
23
|
-
*
|
|
24
|
-
* API key
|
|
25
|
-
*
|
|
26
|
-
* -
|
|
27
|
-
* -
|
|
28
|
-
* -
|
|
14
|
+
* All requests are proxied through the Halix service, which handles provider
|
|
15
|
+
* authentication and API key management server-side. The LLM provider is
|
|
16
|
+
* automatically detected from the model name:
|
|
17
|
+
* - Anthropic (claude-*)
|
|
18
|
+
* - OpenAI (gpt-*, o1-*, o3-*, o4-*)
|
|
19
|
+
* - Google (gemini-*)
|
|
20
|
+
* - xAI (grok-*)
|
|
29
21
|
*
|
|
30
22
|
* @param message - The user message to send to the model
|
|
31
|
-
* @param model - The model identifier (e.g. 'claude-
|
|
23
|
+
* @param model - The model identifier (e.g. 'claude-sonnet-4-5', 'gpt-4.1', 'gemini-3-pro-preview', 'grok-3')
|
|
32
24
|
* @param options - Optional configuration (system prompt, max tokens)
|
|
33
25
|
* @returns Promise<string> - The model's text response
|
|
34
|
-
* @throws Error if SDK not initialized
|
|
26
|
+
* @throws Error if SDK not initialized or the request fails
|
|
35
27
|
*
|
|
36
28
|
* @example
|
|
37
29
|
* // Simple usage
|
|
38
|
-
* const response = await sendAIMessage('What is the capital of France?', 'gpt-
|
|
30
|
+
* const response = await sendAIMessage('What is the capital of France?', 'gpt-4.1');
|
|
39
31
|
*
|
|
40
32
|
* @example
|
|
41
33
|
* // With options
|
|
42
34
|
* const response = await sendAIMessage(
|
|
43
35
|
* 'Summarize this document.',
|
|
44
|
-
* 'claude-
|
|
36
|
+
* 'claude-sonnet-4-5',
|
|
45
37
|
* { systemPrompt: 'You are a helpful assistant.', maxTokens: 2048 }
|
|
46
38
|
* );
|
|
47
39
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../../src/ai.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAQ,UAAU,
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../../src/ai.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAQ,UAAU,EAAiB,MAAM,MAAM,CAAC;AAOvD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CA4B/G;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,UAAU,CAAC,MAAM,CAAC,CAExH"}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -10,6 +10,6 @@ export { MessageMethod, type MessageRequest, sendMessage, sendMessageAsObservabl
|
|
|
10
10
|
export { getUserPreference, getOrganizationPreference, getUserPreferenceAsObservable, getOrganizationPreferenceAsObservable } from './preferences';
|
|
11
11
|
export { type SortField, type DataSortField, type BaseListDataRequest, type PagedListDataRequest, type ListDataResponse, type ListDataOptions, type ListDataSearchOptions, type MassEditValueType, type MassEditRequest, type MassDeleteRequest, type MassChangeResponse, getListData, getListDataAsObservable, massEdit, massEditAsObservable, massDelete, massDeleteAsObservable } from './lists';
|
|
12
12
|
export { AggregationResponse, type AggregationRequest, type AggregationRow, type AggregationGroup, type AggregationSort, type Aggregation, type AggregationGroupTransform, type TransformType, type AggregationType, getAggregateData, getAggregateDataAsObservable } from './data-aggregate';
|
|
13
|
-
export {
|
|
13
|
+
export { type AIRequestOptions, sendAIMessage, sendAIMessageAsObservable } from './ai';
|
|
14
14
|
export { sortObjectArray, compareValues, getValueFromObject, debounceFn } from './utilities';
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AASA;;;;GAIG;AAMH,OAAO,EAEH,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,MAAM,EACN,OAAO,EAGP,UAAU,EAGV,KAAK,WAAW,EAChB,KAAK,iBAAiB,EAGtB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAGlB,sBAAsB,EACtB,oBAA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,EAGvB,WAAW,EACX,uBAAuB,EACvB,QAAQ,EACR,oBAAoB,EACpB,UAAU,EACV,sBAAsB,EACzB,MAAM,SAAS,CAAC;AAMjB,OAAO,EAEH,mBAAmB,EAGnB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,eAAe,EAGpB,gBAAgB,EAChB,4BAA4B,EAC/B,MAAM,kBAAkB,CAAC;AAM1B,OAAO,EAEH,KAAK,gBAAgB,EAGrB,aAAa,EACb,yBAAyB,EAC5B,MAAM,MAAM,CAAC;AAMd,OAAO,EACH,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,UAAU,EACb,MAAM,aAAa,CAAC"}
|
package/lib/esm/ai.js
CHANGED
|
@@ -13,184 +13,62 @@
|
|
|
13
13
|
* using API keys stored as organization preferences.
|
|
14
14
|
*/
|
|
15
15
|
import axios from 'axios';
|
|
16
|
-
import { from } from 'rxjs';
|
|
17
|
-
import {
|
|
18
|
-
// ================================================================================
|
|
19
|
-
// TYPES AND ENUMS
|
|
20
|
-
// ================================================================================
|
|
21
|
-
/**
|
|
22
|
-
* Supported LLM providers.
|
|
23
|
-
*/
|
|
24
|
-
export var LLMProvider;
|
|
25
|
-
(function (LLMProvider) {
|
|
26
|
-
LLMProvider["Anthropic"] = "anthropic";
|
|
27
|
-
LLMProvider["OpenAI"] = "openai";
|
|
28
|
-
LLMProvider["Google"] = "google";
|
|
29
|
-
LLMProvider["xAI"] = "xai";
|
|
30
|
-
})(LLMProvider || (LLMProvider = {}));
|
|
31
|
-
// ================================================================================
|
|
32
|
-
// INTERNAL HELPERS
|
|
33
|
-
// ================================================================================
|
|
34
|
-
/**
|
|
35
|
-
* Maps an LLM provider to the corresponding organization preference key.
|
|
36
|
-
*/
|
|
37
|
-
const providerPreferenceKeys = {
|
|
38
|
-
[LLMProvider.Anthropic]: 'AnthropicAPIKey',
|
|
39
|
-
[LLMProvider.OpenAI]: 'OpenAIAPIKey',
|
|
40
|
-
[LLMProvider.Google]: 'GoogleAPIKey',
|
|
41
|
-
[LLMProvider.xAI]: 'xAIAPIKey'
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Detects the LLM provider from a model name string.
|
|
45
|
-
*
|
|
46
|
-
* @param model - The model identifier (e.g. 'claude-3-sonnet', 'gpt-4o', 'gemini-2.0-flash', 'grok-3')
|
|
47
|
-
* @returns The detected LLMProvider
|
|
48
|
-
* @throws Error if the model name cannot be mapped to a known provider
|
|
49
|
-
*/
|
|
50
|
-
function detectProvider(model) {
|
|
51
|
-
const lowerModel = model.toLowerCase();
|
|
52
|
-
if (lowerModel.startsWith('claude')) {
|
|
53
|
-
return LLMProvider.Anthropic;
|
|
54
|
-
}
|
|
55
|
-
if (lowerModel.startsWith('gpt') || lowerModel.startsWith('o1') || lowerModel.startsWith('o3') || lowerModel.startsWith('o4')) {
|
|
56
|
-
return LLMProvider.OpenAI;
|
|
57
|
-
}
|
|
58
|
-
if (lowerModel.startsWith('gemini')) {
|
|
59
|
-
return LLMProvider.Google;
|
|
60
|
-
}
|
|
61
|
-
if (lowerModel.startsWith('grok')) {
|
|
62
|
-
return LLMProvider.xAI;
|
|
63
|
-
}
|
|
64
|
-
throw new Error(`Unable to detect LLM provider for model "${model}". ` +
|
|
65
|
-
`Supported model prefixes: claude (Anthropic), gpt/o1/o3/o4 (OpenAI), gemini (Google), grok (xAI).`);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Fetches the API key for the given provider from organization preferences.
|
|
69
|
-
*/
|
|
70
|
-
async function getApiKey(provider) {
|
|
71
|
-
const prefKey = providerPreferenceKeys[provider];
|
|
72
|
-
const apiKey = await getOrganizationPreference(prefKey);
|
|
73
|
-
if (!apiKey) {
|
|
74
|
-
throw new Error(`API key not configured. Set the "${prefKey}" organization preference to use ${provider} models.`);
|
|
75
|
-
}
|
|
76
|
-
return apiKey;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Sends a message to the Anthropic Messages API and returns the response text.
|
|
80
|
-
*/
|
|
81
|
-
async function callAnthropic(model, message, apiKey, options) {
|
|
82
|
-
const body = {
|
|
83
|
-
model,
|
|
84
|
-
max_tokens: options.maxTokens ?? 1024,
|
|
85
|
-
messages: [{ role: 'user', content: message }]
|
|
86
|
-
};
|
|
87
|
-
if (options.systemPrompt) {
|
|
88
|
-
body.system = options.systemPrompt;
|
|
89
|
-
}
|
|
90
|
-
const response = await axios.post('https://api.anthropic.com/v1/messages', body, {
|
|
91
|
-
headers: {
|
|
92
|
-
'x-api-key': apiKey,
|
|
93
|
-
'anthropic-version': '2023-06-01',
|
|
94
|
-
'Content-Type': 'application/json'
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
return response.data.content[0].text;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Sends a message to an OpenAI-compatible chat completions API and returns the response text.
|
|
101
|
-
* Used for both OpenAI and xAI (which uses the same API format).
|
|
102
|
-
*/
|
|
103
|
-
async function callOpenAICompatible(baseUrl, model, message, apiKey, options) {
|
|
104
|
-
const messages = [];
|
|
105
|
-
if (options.systemPrompt) {
|
|
106
|
-
messages.push({ role: 'system', content: options.systemPrompt });
|
|
107
|
-
}
|
|
108
|
-
messages.push({ role: 'user', content: message });
|
|
109
|
-
// GPT-5.x and newer models require max_completion_tokens instead of max_tokens
|
|
110
|
-
const lowerModel = model.toLowerCase();
|
|
111
|
-
const useMaxCompletionTokens = lowerModel.startsWith('gpt-5') || lowerModel.startsWith('gpt-6');
|
|
112
|
-
const tokenLimit = options.maxTokens ?? 1024;
|
|
113
|
-
const body = {
|
|
114
|
-
model,
|
|
115
|
-
messages,
|
|
116
|
-
...(useMaxCompletionTokens
|
|
117
|
-
? { max_completion_tokens: tokenLimit }
|
|
118
|
-
: { max_tokens: tokenLimit })
|
|
119
|
-
};
|
|
120
|
-
const response = await axios.post(`${baseUrl}/chat/completions`, body, {
|
|
121
|
-
headers: {
|
|
122
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
123
|
-
'Content-Type': 'application/json'
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
return response.data.choices[0].message.content;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Sends a message to the Google Gemini API and returns the response text.
|
|
130
|
-
*/
|
|
131
|
-
async function callGoogle(model, message, apiKey, options) {
|
|
132
|
-
const contents = [];
|
|
133
|
-
if (options.systemPrompt) {
|
|
134
|
-
contents.push({ role: 'user', parts: [{ text: options.systemPrompt }] });
|
|
135
|
-
contents.push({ role: 'model', parts: [{ text: 'Understood.' }] });
|
|
136
|
-
}
|
|
137
|
-
contents.push({ role: 'user', parts: [{ text: message }] });
|
|
138
|
-
const body = {
|
|
139
|
-
contents,
|
|
140
|
-
generationConfig: {
|
|
141
|
-
maxOutputTokens: options.maxTokens ?? 1024
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
const response = await axios.post(`https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent?key=${apiKey}`, body, {
|
|
145
|
-
headers: { 'Content-Type': 'application/json' }
|
|
146
|
-
});
|
|
147
|
-
return response.data.candidates[0].content.parts[0].text;
|
|
148
|
-
}
|
|
16
|
+
import { from, lastValueFrom } from 'rxjs';
|
|
17
|
+
import { serviceAddress, getAuthToken, sandboxKey } from './sdk-general';
|
|
149
18
|
// ================================================================================
|
|
150
19
|
// PUBLIC API
|
|
151
20
|
// ================================================================================
|
|
152
21
|
/**
|
|
153
22
|
* Sends a message to an LLM and returns its text response.
|
|
154
23
|
*
|
|
155
|
-
*
|
|
156
|
-
* API key
|
|
157
|
-
*
|
|
158
|
-
* -
|
|
159
|
-
* -
|
|
160
|
-
* -
|
|
24
|
+
* All requests are proxied through the Halix service, which handles provider
|
|
25
|
+
* authentication and API key management server-side. The LLM provider is
|
|
26
|
+
* automatically detected from the model name:
|
|
27
|
+
* - Anthropic (claude-*)
|
|
28
|
+
* - OpenAI (gpt-*, o1-*, o3-*, o4-*)
|
|
29
|
+
* - Google (gemini-*)
|
|
30
|
+
* - xAI (grok-*)
|
|
161
31
|
*
|
|
162
32
|
* @param message - The user message to send to the model
|
|
163
|
-
* @param model - The model identifier (e.g. 'claude-
|
|
33
|
+
* @param model - The model identifier (e.g. 'claude-sonnet-4-5', 'gpt-4.1', 'gemini-3-pro-preview', 'grok-3')
|
|
164
34
|
* @param options - Optional configuration (system prompt, max tokens)
|
|
165
35
|
* @returns Promise<string> - The model's text response
|
|
166
|
-
* @throws Error if SDK not initialized
|
|
36
|
+
* @throws Error if SDK not initialized or the request fails
|
|
167
37
|
*
|
|
168
38
|
* @example
|
|
169
39
|
* // Simple usage
|
|
170
|
-
* const response = await sendAIMessage('What is the capital of France?', 'gpt-
|
|
40
|
+
* const response = await sendAIMessage('What is the capital of France?', 'gpt-4.1');
|
|
171
41
|
*
|
|
172
42
|
* @example
|
|
173
43
|
* // With options
|
|
174
44
|
* const response = await sendAIMessage(
|
|
175
45
|
* 'Summarize this document.',
|
|
176
|
-
* 'claude-
|
|
46
|
+
* 'claude-sonnet-4-5',
|
|
177
47
|
* { systemPrompt: 'You are a helpful assistant.', maxTokens: 2048 }
|
|
178
48
|
* );
|
|
179
49
|
*/
|
|
180
50
|
export async function sendAIMessage(message, model, options) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
case LLMProvider.Anthropic:
|
|
186
|
-
return callAnthropic(model, message, apiKey, resolvedOptions);
|
|
187
|
-
case LLMProvider.OpenAI:
|
|
188
|
-
return callOpenAICompatible('https://api.openai.com/v1', model, message, apiKey, resolvedOptions);
|
|
189
|
-
case LLMProvider.Google:
|
|
190
|
-
return callGoogle(model, message, apiKey, resolvedOptions);
|
|
191
|
-
case LLMProvider.xAI:
|
|
192
|
-
return callOpenAICompatible('https://api.x.ai/v1', model, message, apiKey, resolvedOptions);
|
|
51
|
+
if (!getAuthToken) {
|
|
52
|
+
const errorMessage = 'SDK not initialized.';
|
|
53
|
+
console.error(errorMessage);
|
|
54
|
+
throw new Error(errorMessage);
|
|
193
55
|
}
|
|
56
|
+
const url = `${serviceAddress}/assistant/sandboxes/${sandboxKey}/sendMessage`;
|
|
57
|
+
const body = {
|
|
58
|
+
message,
|
|
59
|
+
model,
|
|
60
|
+
};
|
|
61
|
+
if (options?.systemPrompt) {
|
|
62
|
+
body.systemPrompt = options.systemPrompt;
|
|
63
|
+
}
|
|
64
|
+
if (options?.maxTokens) {
|
|
65
|
+
body.maxTokens = options.maxTokens;
|
|
66
|
+
}
|
|
67
|
+
const authToken = await lastValueFrom(getAuthToken());
|
|
68
|
+
const response = await axios.post(url, body, {
|
|
69
|
+
headers: { 'Authorization': `Bearer ${authToken}` },
|
|
70
|
+
});
|
|
71
|
+
return response.data;
|
|
194
72
|
}
|
|
195
73
|
/**
|
|
196
74
|
* Observable version of sendAIMessage. See sendAIMessage for details.
|
package/lib/esm/ai.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../../src/ai.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,mCAAmC;AACnC,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7D,oDAAoD;AAEpD;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAc,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../../src/ai.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,mCAAmC;AACnC,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7D,oDAAoD;AAEpD;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAc,aAAa,EAAE,MAAM,MA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map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,mCAAmC;AACnC,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7D,oDAAoD;AAEpD;;;;GAIG;AAEH,mFAAmF;AACnF,sDAAsD;AACtD,mFAAmF;AAEnF,OAAO;AACH,UAAU;AACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,MAAM,EACN,OAAO;AAEP,iBAAiB;AACjB,UAAU;AAkBV,mBAAmB;AACnB,sBAAsB,EACtB,oBAAoB,EACvB,MAAM,eAAe,CAAC;AAEvB,mFAAmF;AACnF,sBAAsB;AACtB,mFAAmF;AAEnF,OAAO;AAIH,iBAAiB;AACjB,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,6BAA6B;AAE7B,YAAY;AACZ,iBAAiB,EACjB,6BAA6B;AAE7B,cAAc;AACd,mBAAmB,EACnB,+BAA+B,EAC/B,oBAAoB,EACpB,gCAAgC,EACnC,MAAM,aAAa,CAAC;AAErB,mFAAmF;AACnF,oBAAoB;AACpB,mFAAmF;AAEnF,OAAO;AAIH,oBAAoB;AACpB,mBAAmB,EACnB,+BAA+B,EAC/B,YAAY,EACZ,wBAAwB,EACxB,gBAAgB,EAChB,4BAA4B,EAC5B,sBAAsB,EACtB,kCAAkC,EACrC,MAAM,WAAW,CAAC;AAEnB,mFAAmF;AACnF,sBAAsB;AACtB,mFAAmF;AAEnF,OAAO;AACH,kBAAkB;AAClB,aAAa;AAKb,sBAAsB;AACtB,WAAW,EACX,uBAAuB,EAC1B,MAAM,aAAa,CAAC;AAErB,mFAAmF;AACnF,uBAAuB;AACvB,mFAAmF;AAEnF,OAAO;AACH,uBAAuB;AACvB,iBAAiB,EACjB,yBAAyB,EACzB,6BAA6B,EAC7B,qCAAqC,EACxC,MAAM,eAAe,CAAC;AAEvB,mFAAmF;AACnF,sBAAsB;AACtB,mFAAmF;AAEnF,OAAO;AAcH,YAAY;AACZ,WAAW,EACX,uBAAuB,EACvB,QAAQ,EACR,oBAAoB,EACpB,UAAU,EACV,sBAAsB,EACzB,MAAM,SAAS,CAAC;AAEjB,mFAAmF;AACnF,2BAA2B;AAC3B,mFAAmF;AAEnF,OAAO;AACH,UAAU;AACV,mBAAmB;AAYnB,YAAY;AACZ,gBAAgB,EAChB,4BAA4B,EAC/B,MAAM,kBAAkB,CAAC;AAE1B,mFAAmF;AACnF,eAAe;AACf,mFAAmF;AAEnF,OAAO;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,mCAAmC;AACnC,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7D,oDAAoD;AAEpD;;;;GAIG;AAEH,mFAAmF;AACnF,sDAAsD;AACtD,mFAAmF;AAEnF,OAAO;AACH,UAAU;AACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,MAAM,EACN,OAAO;AAEP,iBAAiB;AACjB,UAAU;AAkBV,mBAAmB;AACnB,sBAAsB,EACtB,oBAAoB,EACvB,MAAM,eAAe,CAAC;AAEvB,mFAAmF;AACnF,sBAAsB;AACtB,mFAAmF;AAEnF,OAAO;AAIH,iBAAiB;AACjB,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,6BAA6B;AAE7B,YAAY;AACZ,iBAAiB,EACjB,6BAA6B;AAE7B,cAAc;AACd,mBAAmB,EACnB,+BAA+B,EAC/B,oBAAoB,EACpB,gCAAgC,EACnC,MAAM,aAAa,CAAC;AAErB,mFAAmF;AACnF,oBAAoB;AACpB,mFAAmF;AAEnF,OAAO;AAIH,oBAAoB;AACpB,mBAAmB,EACnB,+BAA+B,EAC/B,YAAY,EACZ,wBAAwB,EACxB,gBAAgB,EAChB,4BAA4B,EAC5B,sBAAsB,EACtB,kCAAkC,EACrC,MAAM,WAAW,CAAC;AAEnB,mFAAmF;AACnF,sBAAsB;AACtB,mFAAmF;AAEnF,OAAO;AACH,kBAAkB;AAClB,aAAa;AAKb,sBAAsB;AACtB,WAAW,EACX,uBAAuB,EAC1B,MAAM,aAAa,CAAC;AAErB,mFAAmF;AACnF,uBAAuB;AACvB,mFAAmF;AAEnF,OAAO;AACH,uBAAuB;AACvB,iBAAiB,EACjB,yBAAyB,EACzB,6BAA6B,EAC7B,qCAAqC,EACxC,MAAM,eAAe,CAAC;AAEvB,mFAAmF;AACnF,sBAAsB;AACtB,mFAAmF;AAEnF,OAAO;AAcH,YAAY;AACZ,WAAW,EACX,uBAAuB,EACvB,QAAQ,EACR,oBAAoB,EACpB,UAAU,EACV,sBAAsB,EACzB,MAAM,SAAS,CAAC;AAEjB,mFAAmF;AACnF,2BAA2B;AAC3B,mFAAmF;AAEnF,OAAO;AACH,UAAU;AACV,mBAAmB;AAYnB,YAAY;AACZ,gBAAgB,EAChB,4BAA4B,EAC/B,MAAM,kBAAkB,CAAC;AAE1B,mFAAmF;AACnF,eAAe;AACf,mFAAmF;AAEnF,OAAO;AAIH,eAAe;AACf,aAAa,EACb,yBAAyB,EAC5B,MAAM,MAAM,CAAC;AAEd,mFAAmF;AACnF,oBAAoB;AACpB,mFAAmF;AAEnF,OAAO,EACH,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,UAAU,EACb,MAAM,aAAa,CAAC"}
|
package/lib/esm/index.mjs
CHANGED
|
@@ -69,8 +69,6 @@ getAggregateData, getAggregateDataAsObservable } from './data-aggregate';
|
|
|
69
69
|
// AI FUNCTIONS
|
|
70
70
|
// ================================================================================
|
|
71
71
|
export {
|
|
72
|
-
// AI Enums
|
|
73
|
-
LLMProvider,
|
|
74
72
|
// AI Functions
|
|
75
73
|
sendAIMessage, sendAIMessageAsObservable } from './ai';
|
|
76
74
|
// ================================================================================
|
package/lib/esm/types/ai.d.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
/**
|
|
3
|
-
* Supported LLM providers.
|
|
4
|
-
*/
|
|
5
|
-
export declare enum LLMProvider {
|
|
6
|
-
Anthropic = "anthropic",
|
|
7
|
-
OpenAI = "openai",
|
|
8
|
-
Google = "google",
|
|
9
|
-
xAI = "xai"
|
|
10
|
-
}
|
|
11
2
|
/**
|
|
12
3
|
* Options for configuring an AI message request.
|
|
13
4
|
*/
|
|
@@ -20,28 +11,29 @@ export interface AIRequestOptions {
|
|
|
20
11
|
/**
|
|
21
12
|
* Sends a message to an LLM and returns its text response.
|
|
22
13
|
*
|
|
23
|
-
*
|
|
24
|
-
* API key
|
|
25
|
-
*
|
|
26
|
-
* -
|
|
27
|
-
* -
|
|
28
|
-
* -
|
|
14
|
+
* All requests are proxied through the Halix service, which handles provider
|
|
15
|
+
* authentication and API key management server-side. The LLM provider is
|
|
16
|
+
* automatically detected from the model name:
|
|
17
|
+
* - Anthropic (claude-*)
|
|
18
|
+
* - OpenAI (gpt-*, o1-*, o3-*, o4-*)
|
|
19
|
+
* - Google (gemini-*)
|
|
20
|
+
* - xAI (grok-*)
|
|
29
21
|
*
|
|
30
22
|
* @param message - The user message to send to the model
|
|
31
|
-
* @param model - The model identifier (e.g. 'claude-
|
|
23
|
+
* @param model - The model identifier (e.g. 'claude-sonnet-4-5', 'gpt-4.1', 'gemini-3-pro-preview', 'grok-3')
|
|
32
24
|
* @param options - Optional configuration (system prompt, max tokens)
|
|
33
25
|
* @returns Promise<string> - The model's text response
|
|
34
|
-
* @throws Error if SDK not initialized
|
|
26
|
+
* @throws Error if SDK not initialized or the request fails
|
|
35
27
|
*
|
|
36
28
|
* @example
|
|
37
29
|
* // Simple usage
|
|
38
|
-
* const response = await sendAIMessage('What is the capital of France?', 'gpt-
|
|
30
|
+
* const response = await sendAIMessage('What is the capital of France?', 'gpt-4.1');
|
|
39
31
|
*
|
|
40
32
|
* @example
|
|
41
33
|
* // With options
|
|
42
34
|
* const response = await sendAIMessage(
|
|
43
35
|
* 'Summarize this document.',
|
|
44
|
-
* 'claude-
|
|
36
|
+
* 'claude-sonnet-4-5',
|
|
45
37
|
* { systemPrompt: 'You are a helpful assistant.', maxTokens: 2048 }
|
|
46
38
|
* );
|
|
47
39
|
*/
|
package/lib/esm/types/index.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export { MessageMethod, type MessageRequest, sendMessage, sendMessageAsObservabl
|
|
|
10
10
|
export { getUserPreference, getOrganizationPreference, getUserPreferenceAsObservable, getOrganizationPreferenceAsObservable } from './preferences';
|
|
11
11
|
export { type SortField, type DataSortField, type BaseListDataRequest, type PagedListDataRequest, type ListDataResponse, type ListDataOptions, type ListDataSearchOptions, type MassEditValueType, type MassEditRequest, type MassDeleteRequest, type MassChangeResponse, getListData, getListDataAsObservable, massEdit, massEditAsObservable, massDelete, massDeleteAsObservable } from './lists';
|
|
12
12
|
export { AggregationResponse, type AggregationRequest, type AggregationRow, type AggregationGroup, type AggregationSort, type Aggregation, type AggregationGroupTransform, type TransformType, type AggregationType, getAggregateData, getAggregateDataAsObservable } from './data-aggregate';
|
|
13
|
-
export {
|
|
13
|
+
export { type AIRequestOptions, sendAIMessage, sendAIMessageAsObservable } from './ai';
|
|
14
14
|
export { sortObjectArray, compareValues, getValueFromObject, debounceFn } from './utilities';
|