-
Notifications
You must be signed in to change notification settings - Fork 40
FEATURE: allow tools to amend personas #1250
Conversation
Add API methods to AI tools for reading and updating personas, enabling more flexible AI workflows. This allows custom tools to: - Fetch persona information through discourse.getPersona() - Update personas with modified settings via discourse.updatePersona() - Also update using persona.update() These APIs enable new use cases like "trainable" moderation bots, where users with appropriate permissions can set and refine moderation rules through direct chat interactions, without needing admin panel access. Also adds a special API scope which allows people to lean on API for similar actions
| persona_id_or_name.to_i.to_s == persona_id_or_name | ||
| persona = AiPersona.find_by(id: persona_id_or_name.to_i) | ||
| else | ||
| persona = AiPersona.find_by(name: persona_id_or_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like name in the AiPersona model is not unique (same for _discourse_get_persona above).
Not sure if you want to add a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh it is I can see index_ai_personas_on_name unique, unless I am missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah no, it looks like I missed the index below the file.
| if updates["temperature"].is_a?(Numeric) | ||
| allowed_updates[:temperature] = updates["temperature"] | ||
| end | ||
|
|
||
| allowed_updates[:top_p] = updates["top_p"] if updates["top_p"].is_a?(Numeric) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume value validations are not in scope?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tricky, it all runs in JS so it is a custom engine of sorts, will leave it somewhat simple for now if ok
nattsw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks fine with some comments
This rather powerful hidden feature can allow custom tools to inject content into the context unconditionally it can be used for memory and similar features
Add API methods to AI tools for reading and updating personas, enabling
more flexible AI workflows. This allows custom tools to:
These APIs enable new use cases like "trainable" moderation bots, where
users with appropriate permissions can set and refine moderation rules
through direct chat interactions, without needing admin panel access.
Also adds a special API scope which allows people to lean on API
for similar actions