@rimori/client 2.5.28-next.6 → 2.5.28-next.7
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.
|
@@ -35,24 +35,6 @@ export interface Message {
|
|
|
35
35
|
toolCalls?: ToolInvocation[];
|
|
36
36
|
}
|
|
37
37
|
export type OnLLMResponse = (id: string, response: string, finished: boolean, toolInvocations?: ToolInvocation[]) => void;
|
|
38
|
-
export interface ObjectRequest {
|
|
39
|
-
/**
|
|
40
|
-
* The tools that the AI can use.
|
|
41
|
-
*/
|
|
42
|
-
tool: AIObjectTool;
|
|
43
|
-
/**
|
|
44
|
-
* High level instructions for the AI to follow. Behaviour, tone, restrictions, etc.
|
|
45
|
-
* Example: "Act like a recipe writer."
|
|
46
|
-
*/
|
|
47
|
-
/** @deprecated Use server-side prompt definitions (prompt + variables) instead of building requests client-side. */
|
|
48
|
-
behaviour?: string;
|
|
49
|
-
/**
|
|
50
|
-
* The specific instruction for the AI to follow.
|
|
51
|
-
* Example: "Generate a recipe using chicken, rice and vegetables."
|
|
52
|
-
*/
|
|
53
|
-
/** @deprecated Use server-side prompt definitions (prompt + variables) instead of building requests client-side. */
|
|
54
|
-
instructions: string;
|
|
55
|
-
}
|
|
56
38
|
/**
|
|
57
39
|
* Controller for AI-related operations.
|
|
58
40
|
* Provides access to text generation, voice synthesis, and object generation.
|
|
@@ -120,8 +102,6 @@ export declare class AIModule {
|
|
|
120
102
|
tools?: Tool[];
|
|
121
103
|
cache?: boolean;
|
|
122
104
|
model?: string;
|
|
123
|
-
/** @deprecated Use uuid variable with resolver 'knowledgeEntry' in prompt definitions instead. */
|
|
124
|
-
knowledgeId?: string;
|
|
125
105
|
prompt?: string;
|
|
126
106
|
variables?: Record<string, any>;
|
|
127
107
|
}): Promise<string>;
|
|
@@ -142,8 +122,6 @@ export declare class AIModule {
|
|
|
142
122
|
* @returns The transcribed text.
|
|
143
123
|
*/
|
|
144
124
|
getTextFromVoice(file: Blob, language?: Language): Promise<string>;
|
|
145
|
-
/** @deprecated Used by legacy client-side prompt path. Will be removed once all plugins migrate to server-side prompt definitions. */
|
|
146
|
-
private getChatMessage;
|
|
147
125
|
/**
|
|
148
126
|
* Generate a structured object from a request using AI.
|
|
149
127
|
* @param request.cache Whether to cache the result (default: false).
|
|
@@ -154,17 +132,9 @@ export declare class AIModule {
|
|
|
154
132
|
* @returns The generated object.
|
|
155
133
|
*/
|
|
156
134
|
getObject<T = any>(params: {
|
|
157
|
-
/** @deprecated Use prompt + variables instead of client-side system prompts. */
|
|
158
|
-
systemPrompt?: string;
|
|
159
|
-
/** @deprecated Use prompt + variables instead. Schema is loaded server-side from the prompt definition. */
|
|
160
|
-
responseSchema?: AIObjectTool;
|
|
161
|
-
/** @deprecated Use prompt + variables instead of client-side user prompts. */
|
|
162
|
-
userPrompt?: string;
|
|
163
135
|
cache?: boolean;
|
|
164
136
|
tools?: Tool[];
|
|
165
137
|
model?: string;
|
|
166
|
-
/** @deprecated Use uuid variable with resolver 'knowledgeEntry' in prompt definitions instead. */
|
|
167
|
-
knowledgeId?: string;
|
|
168
138
|
prompt?: string;
|
|
169
139
|
variables?: Record<string, any>;
|
|
170
140
|
}): Promise<T>;
|
|
@@ -178,18 +148,10 @@ export declare class AIModule {
|
|
|
178
148
|
* @param request.variables Variables for the server-side prompt template.
|
|
179
149
|
*/
|
|
180
150
|
getStreamedObject<T = any>(params: {
|
|
181
|
-
/** @deprecated Use prompt + variables instead of client-side system prompts. */
|
|
182
|
-
systemPrompt?: string;
|
|
183
|
-
/** @deprecated Use prompt + variables instead. Schema is loaded server-side from the prompt definition. */
|
|
184
|
-
responseSchema?: AIObjectTool;
|
|
185
|
-
/** @deprecated Use prompt + variables instead of client-side user prompts. */
|
|
186
|
-
userPrompt?: string;
|
|
187
151
|
onResult: OnStreamedObjectResult<T>;
|
|
188
152
|
cache?: boolean;
|
|
189
153
|
tools?: Tool[];
|
|
190
154
|
model?: string;
|
|
191
|
-
/** @deprecated Use uuid variable with resolver 'knowledgeEntry' in prompt definitions instead. */
|
|
192
|
-
knowledgeId?: string;
|
|
193
155
|
prompt?: string;
|
|
194
156
|
variables?: Record<string, any>;
|
|
195
157
|
}): Promise<T>;
|
|
@@ -109,14 +109,13 @@ export class AIModule {
|
|
|
109
109
|
*/
|
|
110
110
|
getStreamedText(params) {
|
|
111
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
const { messages, onMessage, tools, cache = false, model,
|
|
112
|
+
const { messages, onMessage, tools, cache = false, model, prompt, variables, } = params;
|
|
113
113
|
const messageId = Math.random().toString(36).substring(3);
|
|
114
114
|
const { result } = yield this.streamObject({
|
|
115
115
|
cache,
|
|
116
116
|
tools,
|
|
117
117
|
model,
|
|
118
118
|
messages,
|
|
119
|
-
knowledgeId,
|
|
120
119
|
prompt,
|
|
121
120
|
variables,
|
|
122
121
|
onResult: ({ result }) => onMessage(messageId, result, false),
|
|
@@ -185,14 +184,6 @@ export class AIModule {
|
|
|
185
184
|
});
|
|
186
185
|
});
|
|
187
186
|
}
|
|
188
|
-
/** @deprecated Used by legacy client-side prompt path. Will be removed once all plugins migrate to server-side prompt definitions. */
|
|
189
|
-
getChatMessage(systemPrompt, userPrompt) {
|
|
190
|
-
const messages = [{ role: 'system', content: systemPrompt }];
|
|
191
|
-
if (userPrompt) {
|
|
192
|
-
messages.push({ role: 'user', content: userPrompt });
|
|
193
|
-
}
|
|
194
|
-
return messages;
|
|
195
|
-
}
|
|
196
187
|
/**
|
|
197
188
|
* Generate a structured object from a request using AI.
|
|
198
189
|
* @param request.cache Whether to cache the result (default: false).
|
|
@@ -204,14 +195,12 @@ export class AIModule {
|
|
|
204
195
|
*/
|
|
205
196
|
getObject(params) {
|
|
206
197
|
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
-
const {
|
|
198
|
+
const { cache = false, tools = [], model = undefined, prompt, variables } = params;
|
|
208
199
|
return yield this.streamObject({
|
|
209
|
-
|
|
210
|
-
messages: systemPrompt ? this.getChatMessage(systemPrompt, userPrompt) : [],
|
|
200
|
+
messages: [],
|
|
211
201
|
cache,
|
|
212
202
|
tools,
|
|
213
203
|
model,
|
|
214
|
-
knowledgeId,
|
|
215
204
|
prompt,
|
|
216
205
|
variables,
|
|
217
206
|
});
|
|
@@ -228,15 +217,13 @@ export class AIModule {
|
|
|
228
217
|
*/
|
|
229
218
|
getStreamedObject(params) {
|
|
230
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
231
|
-
const {
|
|
220
|
+
const { onResult, cache = false, tools = [], model = undefined, prompt, variables } = params;
|
|
232
221
|
return yield this.streamObject({
|
|
233
|
-
|
|
234
|
-
messages: systemPrompt ? this.getChatMessage(systemPrompt, userPrompt) : [],
|
|
222
|
+
messages: [],
|
|
235
223
|
onResult,
|
|
236
224
|
cache,
|
|
237
225
|
tools,
|
|
238
226
|
model,
|
|
239
|
-
knowledgeId,
|
|
240
227
|
prompt,
|
|
241
228
|
variables,
|
|
242
229
|
});
|
|
@@ -245,7 +232,7 @@ export class AIModule {
|
|
|
245
232
|
streamObject(params) {
|
|
246
233
|
return __awaiter(this, void 0, void 0, function* () {
|
|
247
234
|
var _a, _b, _c, _d, _e;
|
|
248
|
-
const { messages,
|
|
235
|
+
const { messages, onResult = () => null, cache = false, tools = [], model = undefined, prompt, variables, } = params;
|
|
249
236
|
const chatMessages = messages.map((message, index) => (Object.assign(Object.assign({}, message), { id: `${index + 1}` })));
|
|
250
237
|
const payload = {
|
|
251
238
|
cache,
|
|
@@ -253,15 +240,11 @@ export class AIModule {
|
|
|
253
240
|
stream: true,
|
|
254
241
|
messages: chatMessages,
|
|
255
242
|
model,
|
|
256
|
-
knowledge_id: knowledgeId,
|
|
257
243
|
session_token_id: (_a = this.sessionTokenId) !== null && _a !== void 0 ? _a : undefined,
|
|
258
244
|
};
|
|
259
245
|
if (prompt) {
|
|
260
246
|
payload.prompt = { name: this.resolvePromptName(prompt), variables: variables !== null && variables !== void 0 ? variables : {} };
|
|
261
247
|
}
|
|
262
|
-
if (responseSchema) {
|
|
263
|
-
payload.responseSchema = responseSchema;
|
|
264
|
-
}
|
|
265
248
|
const response = yield fetch(`${this.backendUrl}/ai/llm`, {
|
|
266
249
|
body: JSON.stringify(payload),
|
|
267
250
|
method: 'POST',
|