@rimori/client 2.5.11-next.1 → 2.5.11-next.3

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.
@@ -114,14 +114,14 @@ export interface RimoriPluginConfig<T extends object = object> {
114
114
  topics?: string[];
115
115
  };
116
116
  }
117
+ /**
118
+ * Tool definition for AI function calling.
119
+ * Used when the LLM needs to call external functions/APIs during generation.
120
+ */
117
121
  export interface Tool {
118
122
  name: string;
119
123
  description: string;
120
- parameters: {
121
- name: string;
122
- description: string;
123
- type: 'string' | 'number' | 'boolean';
124
- }[];
124
+ parameters: FunctionToolParameter[];
125
125
  execute?: (args: Record<string, any>) => Promise<unknown> | unknown | void;
126
126
  }
127
127
  /**
@@ -185,5 +185,23 @@ type ToolParameterType = PrimitiveType | {
185
185
  * Primitive data types supported by the LLM tool system.
186
186
  * These align with JSON schema primitive types and TypeScript basic types.
187
187
  */
188
- type PrimitiveType = 'string' | 'number' | 'boolean';
188
+ export type PrimitiveType = 'string' | 'number' | 'boolean';
189
+ /**
190
+ * Parameter for function calling tools (flat structure with name).
191
+ * Uses the same optional properties as ToolParameter but restricted to primitive types.
192
+ */
193
+ export interface FunctionToolParameter {
194
+ /** The parameter name used in function calls */
195
+ name: string;
196
+ /** Human-readable description of the parameter's purpose and usage */
197
+ description: string;
198
+ /** The primitive data type of the parameter */
199
+ type: PrimitiveType;
200
+ /** Optional array of allowed values for enumerated parameters */
201
+ enum?: string[];
202
+ /** Whether the parameter is optional (defaults to required) */
203
+ optional?: boolean;
204
+ /** Whether the parameter is an array of the specified type */
205
+ isArray?: boolean;
206
+ }
189
207
  export {};
@@ -134,18 +134,17 @@ export class AIModule {
134
134
  }
135
135
  streamObject(params) {
136
136
  return __awaiter(this, void 0, void 0, function* () {
137
- console.log('todo: move this function into the AI Module');
138
137
  const { messages, responseSchema, onResult = () => null, cache = false, tools = [] } = params;
139
138
  const chatMessages = messages.map((message, index) => (Object.assign(Object.assign({}, message), { id: `${index + 1}` })));
140
139
  const response = yield fetch(`${this.backendUrl}/ai/llm`, {
141
- method: 'POST',
142
140
  body: JSON.stringify({
143
- stream: true,
144
- messages: chatMessages,
145
- responseSchema,
146
141
  cache,
147
142
  tools,
143
+ stream: true,
144
+ responseSchema,
145
+ messages: chatMessages,
148
146
  }),
147
+ method: 'POST',
149
148
  headers: { Authorization: `Bearer ${this.token}`, 'Content-Type': 'application/json' },
150
149
  });
151
150
  if (!response.ok) {
@@ -58,10 +58,11 @@ export declare class SharedContentController {
58
58
  }): Promise<SharedContent<T>>;
59
59
  /**
60
60
  * Search for shared content by topic using RAG (semantic similarity).
61
+ * Returns the first matching content that hasn't been completed by the user.
61
62
  * @param tableName - Name of the shared content table
62
63
  * @param topic - Topic to search for
63
- * @param limit - Maximum number of results
64
- * @returns Array of similar shared content
64
+ * @param limit - Maximum number of results to return (default: 10)
65
+ * @returns Matching shared content
65
66
  */
66
67
  searchByTopic<T>(tableName: string, topic: string, limit?: number): Promise<SharedContent<T>[]>;
67
68
  /**
@@ -57,37 +57,27 @@ export class SharedContentController {
57
57
  }
58
58
  /**
59
59
  * Search for shared content by topic using RAG (semantic similarity).
60
+ * Returns the first matching content that hasn't been completed by the user.
60
61
  * @param tableName - Name of the shared content table
61
62
  * @param topic - Topic to search for
62
- * @param limit - Maximum number of results
63
- * @returns Array of similar shared content
63
+ * @param limit - Maximum number of results to return (default: 10)
64
+ * @returns Matching shared content
64
65
  */
65
66
  searchByTopic(tableName_1, topic_1) {
66
67
  return __awaiter(this, arguments, void 0, function* (tableName, topic, limit = 10) {
67
- const fullTableName = this.getTableName(tableName);
68
- const completedTableName = this.getCompletedTableName(tableName);
69
- // Generate embedding for search topic
70
- const response = yield this.rimoriClient.runtime.fetchBackend('/ai/embedding', {
68
+ const response = yield this.rimoriClient.runtime.fetchBackend('/shared-content/get-by-topic', {
71
69
  method: 'POST',
72
70
  headers: { 'Content-Type': 'application/json' },
73
- body: JSON.stringify({ text: topic }),
71
+ body: JSON.stringify({
72
+ tableName,
73
+ limit,
74
+ filter: { title: { filterType: 'rag', value: topic } },
75
+ }),
74
76
  });
75
77
  if (!response.ok) {
76
- throw new Error(`Failed to generate embedding: ${response.statusText}`);
77
- }
78
- const { embedding } = yield response.json();
79
- // RPC call for vector similarity search with completion filtering
80
- const { data, error } = yield this.supabase.rpc('search_shared_content', {
81
- p_table_name: fullTableName,
82
- p_completed_table_name: completedTableName,
83
- p_embedding: JSON.stringify(embedding),
84
- p_limit: limit,
85
- });
86
- if (error) {
87
- console.error('Error searching shared content:', error);
88
- throw new Error('Error searching shared content');
78
+ throw new Error(`Failed to search shared content: ${response.statusText}`);
89
79
  }
90
- return data || [];
80
+ return (yield response.json());
91
81
  });
92
82
  }
93
83
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimori/client",
3
- "version": "2.5.11-next.1",
3
+ "version": "2.5.11-next.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {