Go to file
Sam 32b3004ce9
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-30 13:49:21 +10:00
.github/workflows Initial commit 2023-02-17 11:33:47 -03:00
admin/assets/javascripts/discourse FEATURE: allow tuning of RAG generation (#565) 2024-04-12 10:32:46 -03:00
app FEATURE: Add Question Consolidator for robust Upload support in Personas (#596) 2024-04-30 13:49:21 +10:00
assets FEATURE: Add Question Consolidator for robust Upload support in Personas (#596) 2024-04-30 13:49:21 +10:00
config FEATURE: Add Question Consolidator for robust Upload support in Personas (#596) 2024-04-30 13:49:21 +10:00
db FEATURE: Add Question Consolidator for robust Upload support in Personas (#596) 2024-04-30 13:49:21 +10:00
discourse_automation FEATURE: Mixtral/Mistral/Haiku Automation Support (#571) 2024-04-11 09:50:46 -03:00
lib FEATURE: Add Question Consolidator for robust Upload support in Personas (#596) 2024-04-30 13:49:21 +10:00
public/ai-share UX: adjust AI share styles for images and quotes (#567) 2024-04-09 15:36:45 -04:00
spec FEATURE: Add Question Consolidator for robust Upload support in Personas (#596) 2024-04-30 13:49:21 +10:00
test/javascripts FEATURE: Add Question Consolidator for robust Upload support in Personas (#596) 2024-04-30 13:49:21 +10:00
tokenizers FEATURE: Add BGE-M3 embeddings support (#569) 2024-04-10 17:24:01 -03:00
.discourse-compatibility DEV: Lower pinned version to fix unsupported API error on stable (#514) 2024-03-07 14:30:05 +00:00
.eslintrc.cjs DEV: Update linting configs (#280) 2023-11-03 11:30:09 +00:00
.gitignore Initial commit 2023-02-17 11:33:47 -03:00
.prettierignore FEATURE: UI to update ai personas on admin page (#290) 2023-11-21 16:56:43 +11:00
.prettierrc.cjs DEV: Update linting configs (#280) 2023-11-03 11:30:09 +00:00
.rubocop.yml DEV: Update linting configs (#280) 2023-11-03 11:30:09 +00:00
.streerc DEV: Update linting configs (#280) 2023-11-03 11:30:09 +00:00
.template-lintrc.cjs DEV: Update linting (#326) 2023-11-29 23:01:48 +01:00
Gemfile DEV: Update linting configs (#280) 2023-11-03 11:30:09 +00:00
Gemfile.lock DEV: Fix new Rubocop offenses 2024-03-06 15:23:29 +01:00
LICENSE Initial commit 2023-02-17 11:33:47 -03:00
README.md CHORE: Update Readme (#185) 2023-09-04 15:46:35 -03:00
package.json DEV: Update linting (#423) 2024-01-13 00:28:06 +01:00
plugin.rb FIX: Secure/unsecure uploads when sharing AI conversations (#554) 2024-04-11 10:00:41 +10:00
translator.yml UX: Display the indexing progress for RAG uploads (#557) 2024-04-09 11:03:07 -03:00
yarn.lock DEV: Update linting (#423) 2024-01-13 00:28:06 +01:00

README.md

Discourse AI Plugin

Plugin Summary

For more information, please see: https://meta.discourse.org/t/discourse-ai/259214?u=falco