2023-12-07 16:42:56 -05:00
|
|
|
import { tracked } from "@glimmer/tracking";
|
2024-02-15 00:37:59 -05:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
FEATURE: UI to update ai personas on admin page (#290)
Introduces a UI to manage customizable personas (admin only feature)
Part of the change was some extensive internal refactoring:
- AIBot now has a persona set in the constructor, once set it never changes
- Command now takes in bot as a constructor param, so it has the correct persona and is not generating AIBot objects on the fly
- Added a .prettierignore file, due to the way ALE is configured in nvim it is a pre-req for prettier to work
- Adds a bunch of validations on the AIPersona model, system personas (artist/creative etc...) are all seeded. We now ensure
- name uniqueness, and only allow certain properties to be touched for system personas.
- (JS note) the client side design takes advantage of nested routes, the parent route for personas gets all the personas via this.store.findAll("ai-persona") then child routes simply reach into this model to find a particular persona.
- (JS note) data is sideloaded into the ai-persona model the meta property supplied from the controller, resultSetMeta
- This removes ai_bot_enabled_personas and ai_bot_enabled_chat_commands, both should be controlled from the UI on a per persona basis
- Fixes a long standing bug in token accounting ... we were doing to_json.length instead of to_json.to_s.length
- Amended it so {commands} are always inserted at the end unconditionally, no need to add it to the template of the system message as it just confuses things
- Adds a concept of required_commands to stock personas, these are commands that must be configured for this stock persona to show up.
- Refactored tests so we stop requiring inference_stubs, it was very confusing to need it, added to plugin.rb for now which at least is clearer
- Migrates the persona selector to gjs
---------
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Co-authored-by: Martin Brennan <martin@discourse.org>
2023-11-21 00:56:43 -05:00
|
|
|
import RestModel from "discourse/models/rest";
|
|
|
|
|
2024-04-12 09:32:46 -04:00
|
|
|
const CREATE_ATTRIBUTES = [
|
2024-04-09 10:03:07 -04:00
|
|
|
"id",
|
FEATURE: UI to update ai personas on admin page (#290)
Introduces a UI to manage customizable personas (admin only feature)
Part of the change was some extensive internal refactoring:
- AIBot now has a persona set in the constructor, once set it never changes
- Command now takes in bot as a constructor param, so it has the correct persona and is not generating AIBot objects on the fly
- Added a .prettierignore file, due to the way ALE is configured in nvim it is a pre-req for prettier to work
- Adds a bunch of validations on the AIPersona model, system personas (artist/creative etc...) are all seeded. We now ensure
- name uniqueness, and only allow certain properties to be touched for system personas.
- (JS note) the client side design takes advantage of nested routes, the parent route for personas gets all the personas via this.store.findAll("ai-persona") then child routes simply reach into this model to find a particular persona.
- (JS note) data is sideloaded into the ai-persona model the meta property supplied from the controller, resultSetMeta
- This removes ai_bot_enabled_personas and ai_bot_enabled_chat_commands, both should be controlled from the UI on a per persona basis
- Fixes a long standing bug in token accounting ... we were doing to_json.length instead of to_json.to_s.length
- Amended it so {commands} are always inserted at the end unconditionally, no need to add it to the template of the system message as it just confuses things
- Adds a concept of required_commands to stock personas, these are commands that must be configured for this stock persona to show up.
- Refactored tests so we stop requiring inference_stubs, it was very confusing to need it, added to plugin.rb for now which at least is clearer
- Migrates the persona selector to gjs
---------
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Co-authored-by: Martin Brennan <martin@discourse.org>
2023-11-21 00:56:43 -05:00
|
|
|
"name",
|
|
|
|
"description",
|
2024-06-11 04:14:14 -04:00
|
|
|
"tools",
|
FEATURE: UI to update ai personas on admin page (#290)
Introduces a UI to manage customizable personas (admin only feature)
Part of the change was some extensive internal refactoring:
- AIBot now has a persona set in the constructor, once set it never changes
- Command now takes in bot as a constructor param, so it has the correct persona and is not generating AIBot objects on the fly
- Added a .prettierignore file, due to the way ALE is configured in nvim it is a pre-req for prettier to work
- Adds a bunch of validations on the AIPersona model, system personas (artist/creative etc...) are all seeded. We now ensure
- name uniqueness, and only allow certain properties to be touched for system personas.
- (JS note) the client side design takes advantage of nested routes, the parent route for personas gets all the personas via this.store.findAll("ai-persona") then child routes simply reach into this model to find a particular persona.
- (JS note) data is sideloaded into the ai-persona model the meta property supplied from the controller, resultSetMeta
- This removes ai_bot_enabled_personas and ai_bot_enabled_chat_commands, both should be controlled from the UI on a per persona basis
- Fixes a long standing bug in token accounting ... we were doing to_json.length instead of to_json.to_s.length
- Amended it so {commands} are always inserted at the end unconditionally, no need to add it to the template of the system message as it just confuses things
- Adds a concept of required_commands to stock personas, these are commands that must be configured for this stock persona to show up.
- Refactored tests so we stop requiring inference_stubs, it was very confusing to need it, added to plugin.rb for now which at least is clearer
- Migrates the persona selector to gjs
---------
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Co-authored-by: Martin Brennan <martin@discourse.org>
2023-11-21 00:56:43 -05:00
|
|
|
"system_prompt",
|
|
|
|
"allowed_group_ids",
|
|
|
|
"enabled",
|
|
|
|
"system",
|
|
|
|
"priority",
|
2024-02-02 15:09:34 -05:00
|
|
|
"top_p",
|
|
|
|
"temperature",
|
2024-02-15 00:37:59 -05:00
|
|
|
"user_id",
|
|
|
|
"default_llm",
|
2024-10-15 16:20:31 -04:00
|
|
|
"force_default_llm",
|
2024-02-15 00:37:59 -05:00
|
|
|
"user",
|
|
|
|
"max_context_posts",
|
FEATURE: Add vision support to AI personas (Claude 3) (#546)
This commit adds the ability to enable vision for AI personas, allowing them to understand images that are posted in the conversation.
For personas with vision enabled, any images the user has posted will be resized to be within the configured max_pixels limit, base64 encoded and included in the prompt sent to the AI provider.
The persona editor allows enabling/disabling vision and has a dropdown to select the max supported image size (low, medium, high). Vision is disabled by default.
This initial vision support has been tested and implemented with Anthropic's claude-3 models which accept images in a special format as part of the prompt.
Other integrations will need to be updated to support images.
Several specs were added to test the new functionality at the persona, prompt building and API layers.
- Gemini is omitted, pending API support for Gemini 1.5. Current Gemini bot is not performing well, adding images is unlikely to make it perform any better.
- Open AI is omitted, vision support on GPT-4 it limited in that the API has no tool support when images are enabled so we would need to full back to a different prompting technique, something that would add lots of complexity
---------
Co-authored-by: Martin Brennan <martin@discourse.org>
2024-03-26 23:30:11 -04:00
|
|
|
"vision_enabled",
|
|
|
|
"vision_max_pixels",
|
FEATURE: AI Bot RAG support. (#537)
This PR lets you associate uploads to an AI persona, which we'll split and generate embeddings from. When building the system prompt to get a bot reply, we'll do a similarity search followed by a re-ranking (if available). This will let us find the most relevant fragments from the body of knowledge you associated with the persona, resulting in better, more informed responses.
For now, we'll only allow plain-text files, but this will change in the future.
Commits:
* FEATURE: RAG embeddings for the AI Bot
This first commit introduces a UI where admins can upload text files, which we'll store, split into fragments,
and generate embeddings of. In a next commit, we'll use those to give the bot additional information during
conversations.
* Basic asymmetric similarity search to provide guidance in system prompt
* Fix tests and lint
* Apply reranker to fragments
* Uploads filter, css adjustments and file validations
* Add placeholder for rag fragments
* Update annotations
2024-04-01 12:43:34 -04:00
|
|
|
"rag_uploads",
|
2024-04-12 09:32:46 -04:00
|
|
|
"rag_chunk_tokens",
|
|
|
|
"rag_chunk_overlap_tokens",
|
|
|
|
"rag_conversation_chunks",
|
FEATURE: Add Question Consolidator for robust Upload support in Personas (#596)
This commit introduces a new feature for AI Personas called the "Question Consolidator LLM". The purpose of the Question Consolidator is to consolidate a user's latest question into a self-contained, context-rich question before querying the vector database for relevant fragments. This helps improve the quality and relevance of the retrieved fragments.
Previous to this change we used the last 10 interactions, this is not ideal cause the RAG would "lock on" to an answer.
EG:
- User: how many cars are there in europe
- Model: detailed answer about cars in europe including the term car and vehicle many times
- User: Nice, what about trains are there in the US
In the above example "trains" and "US" becomes very low signal given there are pages and pages talking about cars and europe. This mean retrieval is sub optimal.
Instead, we pass the history to the "question consolidator", it would simply consolidate the question to "How many trains are there in the United States", which would make it fare easier for the vector db to find relevant content.
The llm used for question consolidator can often be less powerful than the model you are talking to, we recommend using lighter weight and fast models cause the task is very simple. This is configurable from the persona ui.
This PR also removes support for {uploads} placeholder, this is too complicated to get right and we want freedom to shift RAG implementation.
Key changes:
1. Added a new `question_consolidator_llm` column to the `ai_personas` table to store the LLM model used for question consolidation.
2. Implemented the `QuestionConsolidator` module which handles the logic for consolidating the user's latest question. It extracts the relevant user and model messages from the conversation history, truncates them if needed to fit within the token limit, and generates a consolidated question prompt.
3. Updated the `Persona` class to use the Question Consolidator LLM (if configured) when crafting the RAG fragments prompt. It passes the conversation context to the consolidator to generate a self-contained question.
4. Added UI elements in the AI Persona editor to allow selecting the Question Consolidator LLM. Also made some UI tweaks to conditionally show/hide certain options based on persona configuration.
5. Wrote unit tests for the QuestionConsolidator module and updated existing persona tests to cover the new functionality.
This feature enables AI Personas to better understand the context and intent behind a user's question by consolidating the conversation history into a single, focused question. This can lead to more relevant and accurate responses from the AI assistant.
2024-04-29 23:49:21 -04:00
|
|
|
"question_consolidator_llm",
|
2024-05-05 19:49:02 -04:00
|
|
|
"allow_chat",
|
2024-06-11 04:14:14 -04:00
|
|
|
"tool_details",
|
2024-10-10 16:23:42 -04:00
|
|
|
"forced_tool_count",
|
2024-10-15 16:20:31 -04:00
|
|
|
"allow_personal_messages",
|
|
|
|
"allow_topic_mentions",
|
|
|
|
"allow_chat_channel_mentions",
|
|
|
|
"allow_chat_direct_messages",
|
2024-04-15 09:22:06 -04:00
|
|
|
];
|
2024-04-12 09:32:46 -04:00
|
|
|
|
2024-03-03 17:56:59 -05:00
|
|
|
const SYSTEM_ATTRIBUTES = [
|
2024-04-09 10:03:07 -04:00
|
|
|
"id",
|
2024-03-03 17:56:59 -05:00
|
|
|
"allowed_group_ids",
|
|
|
|
"enabled",
|
|
|
|
"system",
|
|
|
|
"priority",
|
|
|
|
"user_id",
|
|
|
|
"default_llm",
|
2024-10-15 16:20:31 -04:00
|
|
|
"force_default_llm",
|
2024-03-03 17:56:59 -05:00
|
|
|
"user",
|
|
|
|
"max_context_posts",
|
FEATURE: Add vision support to AI personas (Claude 3) (#546)
This commit adds the ability to enable vision for AI personas, allowing them to understand images that are posted in the conversation.
For personas with vision enabled, any images the user has posted will be resized to be within the configured max_pixels limit, base64 encoded and included in the prompt sent to the AI provider.
The persona editor allows enabling/disabling vision and has a dropdown to select the max supported image size (low, medium, high). Vision is disabled by default.
This initial vision support has been tested and implemented with Anthropic's claude-3 models which accept images in a special format as part of the prompt.
Other integrations will need to be updated to support images.
Several specs were added to test the new functionality at the persona, prompt building and API layers.
- Gemini is omitted, pending API support for Gemini 1.5. Current Gemini bot is not performing well, adding images is unlikely to make it perform any better.
- Open AI is omitted, vision support on GPT-4 it limited in that the API has no tool support when images are enabled so we would need to full back to a different prompting technique, something that would add lots of complexity
---------
Co-authored-by: Martin Brennan <martin@discourse.org>
2024-03-26 23:30:11 -04:00
|
|
|
"vision_enabled",
|
|
|
|
"vision_max_pixels",
|
FEATURE: AI Bot RAG support. (#537)
This PR lets you associate uploads to an AI persona, which we'll split and generate embeddings from. When building the system prompt to get a bot reply, we'll do a similarity search followed by a re-ranking (if available). This will let us find the most relevant fragments from the body of knowledge you associated with the persona, resulting in better, more informed responses.
For now, we'll only allow plain-text files, but this will change in the future.
Commits:
* FEATURE: RAG embeddings for the AI Bot
This first commit introduces a UI where admins can upload text files, which we'll store, split into fragments,
and generate embeddings of. In a next commit, we'll use those to give the bot additional information during
conversations.
* Basic asymmetric similarity search to provide guidance in system prompt
* Fix tests and lint
* Apply reranker to fragments
* Uploads filter, css adjustments and file validations
* Add placeholder for rag fragments
* Update annotations
2024-04-01 12:43:34 -04:00
|
|
|
"rag_uploads",
|
2024-04-12 09:32:46 -04:00
|
|
|
"rag_chunk_tokens",
|
|
|
|
"rag_chunk_overlap_tokens",
|
|
|
|
"rag_conversation_chunks",
|
FEATURE: Add Question Consolidator for robust Upload support in Personas (#596)
This commit introduces a new feature for AI Personas called the "Question Consolidator LLM". The purpose of the Question Consolidator is to consolidate a user's latest question into a self-contained, context-rich question before querying the vector database for relevant fragments. This helps improve the quality and relevance of the retrieved fragments.
Previous to this change we used the last 10 interactions, this is not ideal cause the RAG would "lock on" to an answer.
EG:
- User: how many cars are there in europe
- Model: detailed answer about cars in europe including the term car and vehicle many times
- User: Nice, what about trains are there in the US
In the above example "trains" and "US" becomes very low signal given there are pages and pages talking about cars and europe. This mean retrieval is sub optimal.
Instead, we pass the history to the "question consolidator", it would simply consolidate the question to "How many trains are there in the United States", which would make it fare easier for the vector db to find relevant content.
The llm used for question consolidator can often be less powerful than the model you are talking to, we recommend using lighter weight and fast models cause the task is very simple. This is configurable from the persona ui.
This PR also removes support for {uploads} placeholder, this is too complicated to get right and we want freedom to shift RAG implementation.
Key changes:
1. Added a new `question_consolidator_llm` column to the `ai_personas` table to store the LLM model used for question consolidation.
2. Implemented the `QuestionConsolidator` module which handles the logic for consolidating the user's latest question. It extracts the relevant user and model messages from the conversation history, truncates them if needed to fit within the token limit, and generates a consolidated question prompt.
3. Updated the `Persona` class to use the Question Consolidator LLM (if configured) when crafting the RAG fragments prompt. It passes the conversation context to the consolidator to generate a self-contained question.
4. Added UI elements in the AI Persona editor to allow selecting the Question Consolidator LLM. Also made some UI tweaks to conditionally show/hide certain options based on persona configuration.
5. Wrote unit tests for the QuestionConsolidator module and updated existing persona tests to cover the new functionality.
This feature enables AI Personas to better understand the context and intent behind a user's question by consolidating the conversation history into a single, focused question. This can lead to more relevant and accurate responses from the AI assistant.
2024-04-29 23:49:21 -04:00
|
|
|
"question_consolidator_llm",
|
2024-06-11 04:14:14 -04:00
|
|
|
"tool_details",
|
2024-10-15 16:20:31 -04:00
|
|
|
"allow_personal_messages",
|
|
|
|
"allow_topic_mentions",
|
|
|
|
"allow_chat_channel_mentions",
|
|
|
|
"allow_chat_direct_messages",
|
2024-03-03 17:56:59 -05:00
|
|
|
];
|
|
|
|
|
2024-06-11 04:14:14 -04:00
|
|
|
class ToolOption {
|
2023-12-07 16:42:56 -05:00
|
|
|
@tracked value = null;
|
|
|
|
}
|
|
|
|
|
FEATURE: UI to update ai personas on admin page (#290)
Introduces a UI to manage customizable personas (admin only feature)
Part of the change was some extensive internal refactoring:
- AIBot now has a persona set in the constructor, once set it never changes
- Command now takes in bot as a constructor param, so it has the correct persona and is not generating AIBot objects on the fly
- Added a .prettierignore file, due to the way ALE is configured in nvim it is a pre-req for prettier to work
- Adds a bunch of validations on the AIPersona model, system personas (artist/creative etc...) are all seeded. We now ensure
- name uniqueness, and only allow certain properties to be touched for system personas.
- (JS note) the client side design takes advantage of nested routes, the parent route for personas gets all the personas via this.store.findAll("ai-persona") then child routes simply reach into this model to find a particular persona.
- (JS note) data is sideloaded into the ai-persona model the meta property supplied from the controller, resultSetMeta
- This removes ai_bot_enabled_personas and ai_bot_enabled_chat_commands, both should be controlled from the UI on a per persona basis
- Fixes a long standing bug in token accounting ... we were doing to_json.length instead of to_json.to_s.length
- Amended it so {commands} are always inserted at the end unconditionally, no need to add it to the template of the system message as it just confuses things
- Adds a concept of required_commands to stock personas, these are commands that must be configured for this stock persona to show up.
- Refactored tests so we stop requiring inference_stubs, it was very confusing to need it, added to plugin.rb for now which at least is clearer
- Migrates the persona selector to gjs
---------
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Co-authored-by: Martin Brennan <martin@discourse.org>
2023-11-21 00:56:43 -05:00
|
|
|
export default class AiPersona extends RestModel {
|
2023-12-07 16:42:56 -05:00
|
|
|
// this code is here to convert the wire schema to easier to work with object
|
2024-06-11 04:14:14 -04:00
|
|
|
// on the wire we pass in/out tools as an Array.
|
2024-10-04 19:46:57 -04:00
|
|
|
// [[ToolName, {option1: value, option2: value}, force], ToolName2, ToolName3]
|
2024-06-11 04:14:14 -04:00
|
|
|
// So we rework this into a "tools" property and nested toolOptions
|
2023-12-07 16:42:56 -05:00
|
|
|
init(properties) {
|
2024-10-04 19:46:57 -04:00
|
|
|
this.forcedTools = [];
|
2024-06-11 04:14:14 -04:00
|
|
|
if (properties.tools) {
|
|
|
|
properties.tools = properties.tools.map((tool) => {
|
|
|
|
if (typeof tool === "string") {
|
|
|
|
return tool;
|
2023-12-07 16:42:56 -05:00
|
|
|
} else {
|
2024-10-04 19:46:57 -04:00
|
|
|
let [toolId, options, force] = tool;
|
2023-12-07 16:42:56 -05:00
|
|
|
for (let optionId in options) {
|
|
|
|
if (!options.hasOwnProperty(optionId)) {
|
|
|
|
continue;
|
|
|
|
}
|
2024-06-11 04:14:14 -04:00
|
|
|
this.getToolOption(toolId, optionId).value = options[optionId];
|
2023-12-07 16:42:56 -05:00
|
|
|
}
|
2024-10-04 19:46:57 -04:00
|
|
|
if (force) {
|
|
|
|
this.forcedTools.push(toolId);
|
|
|
|
}
|
2024-06-11 04:14:14 -04:00
|
|
|
return toolId;
|
2023-12-07 16:42:56 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
super.init(properties);
|
2024-06-11 04:14:14 -04:00
|
|
|
this.tools = properties.tools;
|
2023-12-07 16:42:56 -05:00
|
|
|
}
|
|
|
|
|
2024-02-15 00:37:59 -05:00
|
|
|
async createUser() {
|
|
|
|
const result = await ajax(
|
|
|
|
`/admin/plugins/discourse-ai/ai-personas/${this.id}/create-user.json`,
|
|
|
|
{
|
|
|
|
type: "POST",
|
|
|
|
}
|
|
|
|
);
|
|
|
|
this.user = result.user;
|
|
|
|
this.user_id = this.user.id;
|
|
|
|
return this.user;
|
|
|
|
}
|
|
|
|
|
2024-06-11 04:14:14 -04:00
|
|
|
getToolOption(toolId, optionId) {
|
|
|
|
this.toolOptions ||= {};
|
|
|
|
this.toolOptions[toolId] ||= {};
|
|
|
|
return (this.toolOptions[toolId][optionId] ||= new ToolOption());
|
2023-12-07 16:42:56 -05:00
|
|
|
}
|
|
|
|
|
2024-06-11 04:14:14 -04:00
|
|
|
populateToolOptions(attrs) {
|
|
|
|
if (!attrs.tools) {
|
2023-12-07 16:42:56 -05:00
|
|
|
return;
|
|
|
|
}
|
2024-06-11 04:14:14 -04:00
|
|
|
let toolsWithOptions = [];
|
|
|
|
attrs.tools.forEach((toolId) => {
|
|
|
|
if (typeof toolId !== "string") {
|
|
|
|
toolId = toolId[0];
|
2023-12-07 16:42:56 -05:00
|
|
|
}
|
2024-10-04 19:46:57 -04:00
|
|
|
|
|
|
|
let force = this.forcedTools.includes(toolId);
|
2024-06-11 04:14:14 -04:00
|
|
|
if (this.toolOptions && this.toolOptions[toolId]) {
|
|
|
|
let options = this.toolOptions[toolId];
|
2023-12-07 16:42:56 -05:00
|
|
|
let optionsWithValues = {};
|
|
|
|
for (let optionId in options) {
|
|
|
|
if (!options.hasOwnProperty(optionId)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
let option = options[optionId];
|
|
|
|
optionsWithValues[optionId] = option.value;
|
|
|
|
}
|
2024-10-04 19:46:57 -04:00
|
|
|
toolsWithOptions.push([toolId, optionsWithValues, force]);
|
2023-12-07 16:42:56 -05:00
|
|
|
} else {
|
2024-10-04 19:46:57 -04:00
|
|
|
toolsWithOptions.push([toolId, {}, force]);
|
2023-12-07 16:42:56 -05:00
|
|
|
}
|
|
|
|
});
|
2024-06-11 04:14:14 -04:00
|
|
|
attrs.tools = toolsWithOptions;
|
2023-12-07 16:42:56 -05:00
|
|
|
}
|
|
|
|
|
FEATURE: UI to update ai personas on admin page (#290)
Introduces a UI to manage customizable personas (admin only feature)
Part of the change was some extensive internal refactoring:
- AIBot now has a persona set in the constructor, once set it never changes
- Command now takes in bot as a constructor param, so it has the correct persona and is not generating AIBot objects on the fly
- Added a .prettierignore file, due to the way ALE is configured in nvim it is a pre-req for prettier to work
- Adds a bunch of validations on the AIPersona model, system personas (artist/creative etc...) are all seeded. We now ensure
- name uniqueness, and only allow certain properties to be touched for system personas.
- (JS note) the client side design takes advantage of nested routes, the parent route for personas gets all the personas via this.store.findAll("ai-persona") then child routes simply reach into this model to find a particular persona.
- (JS note) data is sideloaded into the ai-persona model the meta property supplied from the controller, resultSetMeta
- This removes ai_bot_enabled_personas and ai_bot_enabled_chat_commands, both should be controlled from the UI on a per persona basis
- Fixes a long standing bug in token accounting ... we were doing to_json.length instead of to_json.to_s.length
- Amended it so {commands} are always inserted at the end unconditionally, no need to add it to the template of the system message as it just confuses things
- Adds a concept of required_commands to stock personas, these are commands that must be configured for this stock persona to show up.
- Refactored tests so we stop requiring inference_stubs, it was very confusing to need it, added to plugin.rb for now which at least is clearer
- Migrates the persona selector to gjs
---------
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Co-authored-by: Martin Brennan <martin@discourse.org>
2023-11-21 00:56:43 -05:00
|
|
|
updateProperties() {
|
2024-03-03 17:56:59 -05:00
|
|
|
let attrs = this.system
|
|
|
|
? this.getProperties(SYSTEM_ATTRIBUTES)
|
2024-04-15 09:22:06 -04:00
|
|
|
: this.getProperties(CREATE_ATTRIBUTES);
|
FEATURE: UI to update ai personas on admin page (#290)
Introduces a UI to manage customizable personas (admin only feature)
Part of the change was some extensive internal refactoring:
- AIBot now has a persona set in the constructor, once set it never changes
- Command now takes in bot as a constructor param, so it has the correct persona and is not generating AIBot objects on the fly
- Added a .prettierignore file, due to the way ALE is configured in nvim it is a pre-req for prettier to work
- Adds a bunch of validations on the AIPersona model, system personas (artist/creative etc...) are all seeded. We now ensure
- name uniqueness, and only allow certain properties to be touched for system personas.
- (JS note) the client side design takes advantage of nested routes, the parent route for personas gets all the personas via this.store.findAll("ai-persona") then child routes simply reach into this model to find a particular persona.
- (JS note) data is sideloaded into the ai-persona model the meta property supplied from the controller, resultSetMeta
- This removes ai_bot_enabled_personas and ai_bot_enabled_chat_commands, both should be controlled from the UI on a per persona basis
- Fixes a long standing bug in token accounting ... we were doing to_json.length instead of to_json.to_s.length
- Amended it so {commands} are always inserted at the end unconditionally, no need to add it to the template of the system message as it just confuses things
- Adds a concept of required_commands to stock personas, these are commands that must be configured for this stock persona to show up.
- Refactored tests so we stop requiring inference_stubs, it was very confusing to need it, added to plugin.rb for now which at least is clearer
- Migrates the persona selector to gjs
---------
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Co-authored-by: Martin Brennan <martin@discourse.org>
2023-11-21 00:56:43 -05:00
|
|
|
attrs.id = this.id;
|
2024-06-11 04:14:14 -04:00
|
|
|
this.populateToolOptions(attrs);
|
FEATURE: UI to update ai personas on admin page (#290)
Introduces a UI to manage customizable personas (admin only feature)
Part of the change was some extensive internal refactoring:
- AIBot now has a persona set in the constructor, once set it never changes
- Command now takes in bot as a constructor param, so it has the correct persona and is not generating AIBot objects on the fly
- Added a .prettierignore file, due to the way ALE is configured in nvim it is a pre-req for prettier to work
- Adds a bunch of validations on the AIPersona model, system personas (artist/creative etc...) are all seeded. We now ensure
- name uniqueness, and only allow certain properties to be touched for system personas.
- (JS note) the client side design takes advantage of nested routes, the parent route for personas gets all the personas via this.store.findAll("ai-persona") then child routes simply reach into this model to find a particular persona.
- (JS note) data is sideloaded into the ai-persona model the meta property supplied from the controller, resultSetMeta
- This removes ai_bot_enabled_personas and ai_bot_enabled_chat_commands, both should be controlled from the UI on a per persona basis
- Fixes a long standing bug in token accounting ... we were doing to_json.length instead of to_json.to_s.length
- Amended it so {commands} are always inserted at the end unconditionally, no need to add it to the template of the system message as it just confuses things
- Adds a concept of required_commands to stock personas, these are commands that must be configured for this stock persona to show up.
- Refactored tests so we stop requiring inference_stubs, it was very confusing to need it, added to plugin.rb for now which at least is clearer
- Migrates the persona selector to gjs
---------
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Co-authored-by: Martin Brennan <martin@discourse.org>
2023-11-21 00:56:43 -05:00
|
|
|
return attrs;
|
|
|
|
}
|
|
|
|
|
|
|
|
createProperties() {
|
2024-04-12 09:32:46 -04:00
|
|
|
let attrs = this.getProperties(CREATE_ATTRIBUTES);
|
2024-06-11 04:14:14 -04:00
|
|
|
this.populateToolOptions(attrs);
|
2023-12-07 16:42:56 -05:00
|
|
|
return attrs;
|
FEATURE: UI to update ai personas on admin page (#290)
Introduces a UI to manage customizable personas (admin only feature)
Part of the change was some extensive internal refactoring:
- AIBot now has a persona set in the constructor, once set it never changes
- Command now takes in bot as a constructor param, so it has the correct persona and is not generating AIBot objects on the fly
- Added a .prettierignore file, due to the way ALE is configured in nvim it is a pre-req for prettier to work
- Adds a bunch of validations on the AIPersona model, system personas (artist/creative etc...) are all seeded. We now ensure
- name uniqueness, and only allow certain properties to be touched for system personas.
- (JS note) the client side design takes advantage of nested routes, the parent route for personas gets all the personas via this.store.findAll("ai-persona") then child routes simply reach into this model to find a particular persona.
- (JS note) data is sideloaded into the ai-persona model the meta property supplied from the controller, resultSetMeta
- This removes ai_bot_enabled_personas and ai_bot_enabled_chat_commands, both should be controlled from the UI on a per persona basis
- Fixes a long standing bug in token accounting ... we were doing to_json.length instead of to_json.to_s.length
- Amended it so {commands} are always inserted at the end unconditionally, no need to add it to the template of the system message as it just confuses things
- Adds a concept of required_commands to stock personas, these are commands that must be configured for this stock persona to show up.
- Refactored tests so we stop requiring inference_stubs, it was very confusing to need it, added to plugin.rb for now which at least is clearer
- Migrates the persona selector to gjs
---------
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Co-authored-by: Martin Brennan <martin@discourse.org>
2023-11-21 00:56:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
workingCopy() {
|
2024-04-15 09:22:06 -04:00
|
|
|
let attrs = this.getProperties(CREATE_ATTRIBUTES);
|
2024-06-11 04:14:14 -04:00
|
|
|
this.populateToolOptions(attrs);
|
2024-10-04 19:46:57 -04:00
|
|
|
|
|
|
|
const persona = AiPersona.create(attrs);
|
|
|
|
persona.forcedTools = (this.forcedTools || []).slice();
|
2024-10-10 16:23:42 -04:00
|
|
|
persona.forced_tool_count = this.forced_tool_count || -1;
|
2024-10-04 19:46:57 -04:00
|
|
|
return persona;
|
FEATURE: UI to update ai personas on admin page (#290)
Introduces a UI to manage customizable personas (admin only feature)
Part of the change was some extensive internal refactoring:
- AIBot now has a persona set in the constructor, once set it never changes
- Command now takes in bot as a constructor param, so it has the correct persona and is not generating AIBot objects on the fly
- Added a .prettierignore file, due to the way ALE is configured in nvim it is a pre-req for prettier to work
- Adds a bunch of validations on the AIPersona model, system personas (artist/creative etc...) are all seeded. We now ensure
- name uniqueness, and only allow certain properties to be touched for system personas.
- (JS note) the client side design takes advantage of nested routes, the parent route for personas gets all the personas via this.store.findAll("ai-persona") then child routes simply reach into this model to find a particular persona.
- (JS note) data is sideloaded into the ai-persona model the meta property supplied from the controller, resultSetMeta
- This removes ai_bot_enabled_personas and ai_bot_enabled_chat_commands, both should be controlled from the UI on a per persona basis
- Fixes a long standing bug in token accounting ... we were doing to_json.length instead of to_json.to_s.length
- Amended it so {commands} are always inserted at the end unconditionally, no need to add it to the template of the system message as it just confuses things
- Adds a concept of required_commands to stock personas, these are commands that must be configured for this stock persona to show up.
- Refactored tests so we stop requiring inference_stubs, it was very confusing to need it, added to plugin.rb for now which at least is clearer
- Migrates the persona selector to gjs
---------
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Co-authored-by: Martin Brennan <martin@discourse.org>
2023-11-21 00:56:43 -05:00
|
|
|
}
|
|
|
|
}
|