work in progress adding roles to personas

# Conflicts:
#	app/models/ai_persona.rb
This commit is contained in:
Sam Saffron 2024-05-01 15:39:13 +10:00
parent acd3ac2371
commit 6351c401f8
No known key found for this signature in database
GPG Key ID: B9606168D2FFD9F5
6 changed files with 49 additions and 1 deletions

View File

@ -125,6 +125,7 @@ module DiscourseAi
:rag_chunk_overlap_tokens, :rag_chunk_overlap_tokens,
:rag_conversation_chunks, :rag_conversation_chunks,
:question_consolidator_llm, :question_consolidator_llm,
:role,
allowed_group_ids: [], allowed_group_ids: [],
rag_uploads: [:id], rag_uploads: [:id],
) )

View File

@ -23,7 +23,12 @@ class LocalizedAiPersonaSerializer < ApplicationSerializer
:rag_chunk_tokens, :rag_chunk_tokens,
:rag_chunk_overlap_tokens, :rag_chunk_overlap_tokens,
:rag_conversation_chunks, :rag_conversation_chunks,
:question_consolidator_llm :question_consolidator_llm,
:role,
:role_tags,
:role_category_ids,
:role_whispers,
:role_max_responses_per_hour
has_one :user, serializer: BasicUserSerializer, embed: :object has_one :user, serializer: BasicUserSerializer, embed: :object
has_many :rag_uploads, serializer: UploadSerializer, embed: :object has_many :rag_uploads, serializer: UploadSerializer, embed: :object

View File

@ -26,6 +26,9 @@ const CREATE_ATTRIBUTES = [
"rag_chunk_overlap_tokens", "rag_chunk_overlap_tokens",
"rag_conversation_chunks", "rag_conversation_chunks",
"question_consolidator_llm", "question_consolidator_llm",
"role",
"role_category_ids",
"role_whispers",
]; ];
const SYSTEM_ATTRIBUTES = [ const SYSTEM_ATTRIBUTES = [

View File

@ -23,6 +23,7 @@ import DTooltip from "float-kit/components/d-tooltip";
import AiCommandSelector from "./ai-command-selector"; import AiCommandSelector from "./ai-command-selector";
import AiLlmSelector from "./ai-llm-selector"; import AiLlmSelector from "./ai-llm-selector";
import AiPersonaCommandOptions from "./ai-persona-command-options"; import AiPersonaCommandOptions from "./ai-persona-command-options";
import RoleSelector from "./ai-persona-role-selector";
import PersonaRagUploader from "./persona-rag-uploader"; import PersonaRagUploader from "./persona-rag-uploader";
export default class PersonaEditor extends Component { export default class PersonaEditor extends Component {
@ -336,6 +337,14 @@ export default class PersonaEditor extends Component {
disabled={{this.editingModel.system}} disabled={{this.editingModel.system}}
/> />
</div> </div>
<div class="control-group ai-persona-editor__role">
<label>{{I18n.t "discourse_ai.ai_persona.role"}}</label>
<RoleSelector
class="ai-persona-editor__role_selctor"
@value={{this.editingModel.role}}
@disabled={{this.editingModel.system}}
/>
</div>
<div class="control-group"> <div class="control-group">
<label>{{I18n.t "discourse_ai.ai_persona.default_llm"}}</label> <label>{{I18n.t "discourse_ai.ai_persona.default_llm"}}</label>
<AiLlmSelector <AiLlmSelector

View File

@ -0,0 +1,26 @@
import { computed, observer } from "@ember/object";
import I18n from "discourse-i18n";
import ComboBox from "select-kit/components/combo-box";
export default ComboBox.extend({
_modelDisabledChanged: observer("attrs.disabled", function () {
this.selectKit.options.set("disabled", this.get("attrs.disabled.value"));
}),
content: computed(function () {
return [
{
id: "bot",
name: I18n.t("discourse_ai.ai_persona.role_options.bot"),
},
{
id: "message_responder",
name: I18n.t("discourse_ai.ai_persona.role_options.message_responder"),
},
];
}),
selectKitOptions: {
filterable: false,
},
});

View File

@ -137,6 +137,10 @@ en:
mentionable: Mentionable mentionable: Mentionable
mentionable_help: If enabled, users in allowed groups can mention this user in posts and messages, the AI will respond as this persona. mentionable_help: If enabled, users in allowed groups can mention this user in posts and messages, the AI will respond as this persona.
user: User user: User
role: Role
role_options:
bot: Bot
message_responder: Message Responder
create_user: Create User create_user: Create User
create_user_help: You can optionally attach a user to this persona. If you do, the AI will use this user to respond to requests. create_user_help: You can optionally attach a user to this persona. If you do, the AI will use this user to respond to requests.
default_llm: Default Language Model default_llm: Default Language Model