Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit c2ef8e2

Browse files
committed
allow for avatar handling and proper user handling
1 parent 8204f05 commit c2ef8e2

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

app/controllers/discourse_ai/ai_bot/artifacts_controller.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,18 @@ def build_parent_javascript(artifact)
302302
303303
if (!response.ok) throw new Error('Failed to get key-values');
304304
305-
return await response.json();
305+
const result = await response.json();
306+
const userMap = {};
307+
result.users.forEach(user => {
308+
userMap[user.id] = user;
309+
});
310+
result.key_values.forEach(kv => {
311+
if (kv.user_id && userMap[kv.user_id]) {
312+
kv.user = userMap[kv.user_id];
313+
}
314+
});
315+
316+
return result;
306317
}
307318
</script>
308319
JAVASCRIPT

lib/personas/tools/create_artifact.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,11 @@ def self.storage_api
316316
- keys_only (boolean) - Return only keys, not values
317317
- page (number) - Page number for pagination
318318
- per_page (number) - Items per page (max 100, default 100)
319-
- Returns: Promise<object> - { key_values: Array(key, value), has_more: boolean, total_count: number }
319+
- Returns: Promise<object> - { key_values: Array(key, value, user(username, name, avatar_template)), has_more: boolean, total_count: number }
320320
- Example: `const result = await window.discourseArtifact.index({ keys_only: true });`
321321
322+
- avatar_template: string - URL template for user avatars, MUST replace {size} with desired size in pixels (eg: 22)
323+
322324
### Storage Rules:
323325
- Each user can store up to 100 keys per artifact
324326
- Keys are scoped to the current user and artifact

0 commit comments

Comments
 (0)