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

Conversation

@SamSaffron
Copy link
Member

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

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)
Copy link
Contributor

@nattsw nattsw Apr 8, 2025

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.

Copy link
Member Author

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?

Copy link
Contributor

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.

Comment on lines +520 to +524
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)
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Contributor

@nattsw nattsw left a 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
@SamSaffron SamSaffron merged commit e159840 into main Apr 9, 2025
6 checks passed
@SamSaffron SamSaffron deleted the persona-editing branch April 9, 2025 05:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants