Commit Graph

622 Commits

Author SHA1 Message Date
Keegan George 3ea1e8efd8
UX: Hide AI preferences page completely if no settings for user 2024-05-27 12:44:17 -07:00
Keegan George 2b98e84acf
FIX: Reply broken when auto caption is enabled 2024-05-27 12:07:57 -07:00
Keegan George a1c649965f
FEATURE: Auto image captions (#637) 2024-05-27 10:49:24 -07:00
Sam baf88e7cfc
FEATURE: improve logging by including llm name (#640)
Log the language model name when logging api requests
2024-05-27 16:46:01 +10:00
Ted Johansson d8a0f44fed
FIX: Amend incorrect translation keys (#639)
I am enabling config.i18n.raise_on_missing_translations in core. This revealed a couple of broken translations in the plugin.
2024-05-24 20:00:36 +08:00
Sam f8381c0e8a
UX: suppress "this is a warning" (#636)
When triggering a PM from new-message route, we still had the UI
for "this is an official warning"

This removes that UI from bot messages, which is all clutter.
2024-05-23 12:55:33 +08:00
Sam d5c23f01ff
FIX: correct gemini streaming implementation (#632)
This also implements image support and gemini-flash support
2024-05-22 16:35:29 +10:00
Martin Brennan 06137ac706
FEATURE: Use DBreadcrumbsItem in admin UI (#631)
This commit uses the new DBreadcrumbsItem and DBreadcrumbsContainer
from core to show a path back to the admin plugins list.
2024-05-22 09:19:53 +10:00
Keegan George 59e63a2da9
FIX: Unresponsive post buttons due to Ask AI highlight (#635) 2024-05-21 13:58:37 -07:00
Roman Rizzi 3a9080dd14
FEATURE: Test LLM configuration (#634) 2024-05-21 13:35:50 -03:00
Discourse Translator Bot 2b473dd4a5
Update translations (#633) 2024-05-21 17:41:00 +02:00
Sam d4116ecfac
FEATURE: Add support for contextualizing a DM to a bot (#627)
This brings the context of the current topic on screen into chat
2024-05-21 17:17:02 +10:00
Sam 232f12eba6
FEATURE: JavaScript evaluation tool (#630)
This is similar to code interpreter by ChatGPT, except that it uses
JavaScript as the execution engine.

Safeguards were added to ensure memory is constrained and evaluation
times out.
2024-05-21 07:57:01 +10:00
dependabot[bot] 4d8d822351
Build(deps-dev): Bump rexml from 3.2.6 to 3.2.8 (#629)
Bumps [rexml](https://github.com/ruby/rexml) from 3.2.6 to 3.2.8.
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](https://github.com/ruby/rexml/compare/v3.2.6...v3.2.8)

---
updated-dependencies:
- dependency-name: rexml
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-16 23:54:10 +02:00
Roman Rizzi d8ebed8fb5
UX: Follow plugin user interface UI guidelines. (#628) 2024-05-16 14:28:57 -03:00
Roman Rizzi 1d786fbaaf
FEATURE: Set endpoint credentials directly from LlmModel. (#625)
* FEATURE: Set endpoint credentials directly from LlmModel.

Drop Llama2Tokenizer since we no longer use it.

* Allow http for custom LLMs

---------

Co-authored-by: Rafael Silva <xfalcox@gmail.com>
2024-05-16 09:50:22 -03:00
Sam 255139056d
FEATURE: safeguard to avoid over triage (#626)
- a post can be triaged a maximum of twice a minute
- system can run a total of 60 triages a minute

Low defaults were picked to safeguard against any possible loops

This can be amended if required via hidden site settings.
2024-05-16 16:49:44 +10:00
Régis Hanol d64cff7692
DEV: use sinon for safer stubbing (#624)
Follow up to https://github.com/discourse/discourse-ai/pull/622#discussion_r1601199538
2024-05-15 11:54:19 +02:00
Régis Hanol 1e6d9ed634
FIX: respect "external_links_in_new_tab" user preference... (#622)
... for AI conversations since they look & feel "external".

Internal ref - /t/128182
2024-05-15 10:06:38 +02:00
Sam 3db89bfdc8
FIX: incorrect description for LLM field (#623) 2024-05-14 16:55:25 -07:00
Discourse Translator Bot 28647b81fe
Update translations (#620) 2024-05-14 16:19:53 +02:00
Bianca Nenciu d5e30592f3
FIX: Load categories from search response (#612)
When lazy load categories is enabled, the list of categories does not
have to fetched from the "site.json" endpoint because it is already
returned by "search.json".

This commit reverts commits 5056502 and 3e54697 because iterating over
all pages of categories is not really necessary.
2024-05-14 17:13:25 +03:00
Jarek Radosz fc73cce113
FIX: Invalid header button title (#621)
`[en.Start a PM with an AI bot]`
2024-05-14 15:30:03 +02:00
Sam cb23ae614f
UX: Remove multi llm selector from header and move to composer (#619)
LLM selector control had no memory and was awkward to click.

Instead we now:

- Clearly display which llm you are talking to
- Allow you to change llm direct from composer
2024-05-14 17:54:54 +10:00
Sam 8eee6893d6
FEATURE: GPT4o support and better auditing (#618)
- Introduce new support for GPT4o (automation / bot / summary / helper)
- Properly account for token counts on OpenAI models
- Track feature that was used when generating AI completions
- Remove custom llm support for summarization as we need better interfaces to control registration and de-registration
2024-05-14 13:28:46 +10:00
Roman Rizzi 8b00c47087
FIX: dialects var was not defined in prod (#617) 2024-05-13 17:28:27 -03:00
Roman Rizzi e22194f321
HACK: Llama3 support for summarization/AI helper. (#616)
There are still some limitations to which models we can support with the `LlmModel` class. This will enable support for Llama3 while we sort those out.
2024-05-13 15:54:42 -03:00
Roman Rizzi 62fc7d6ed0
FEATURE: Configurable LLMs. (#606)
This PR introduces the concept of "LlmModel" as a new way to quickly add new LLM models without making any code changes. We are releasing this first version and will add incremental improvements, so expect changes.

The AI Bot can't fully take advantage of this feature as users are hard-coded. We'll fix this in a separate PR.s
2024-05-13 12:46:42 -03:00
Rafael dos Santos Silva 5c02b885ea
FEATURE: Llama 3 tokenizer (#615) 2024-05-13 12:45:52 -03:00
Bianca Nenciu 5861418e9d
FIX: Load categories for AI search results (#614)
Categories should be preloaded when "lazy load categories" is enabled.
2024-05-13 16:47:37 +03:00
Sam 0069256efd
FIX: improve function call parsing (#613)
- support " / ' wrapped values
- coerce integer to integer
- enforce enum at boundary
2024-05-13 19:40:11 +10:00
Joffrey JAFFEUX 64f41454ad
FIX: uses getByIdentifier of d-menu (#611)
The menu service doesn’t implement an activeMenu property anymore as it can now support concurrent menus. The solution to this is to use `getByIdentifier`.
2024-05-10 12:01:02 +02:00
Sam 61890b667c
FEATURE: search command now support searching in context of user (#610)
This optional feature allows search to be performed in the context
of the user that executed it.

By default we do not allow this behavior cause it means llm gets
access to potentially secure data.
2024-05-10 11:32:34 +10:00
Sam 514823daca
FIX: streaming broken in bedrock when chunks are not aligned (#609)
Also

- Stop caching llm list - this cause llm list in persona to be incorrect
- Add more UI to debug screen so you can properly see raw response
2024-05-09 12:11:50 +10:00
Sam cf34838a09
FIX: context repairs for @mentioned bot (#608)
When the bot is @mentioned, we need to be a lot more careful
about constructing context otherwise bot gets ultra confused.

This changes multiple things:

1. We were omitting all thread first messages (fixed)
2. Include thread title (if available) in context
3. Construct context in a clearer way separating user request from data
2024-05-08 18:44:04 +10:00
Rafael dos Santos Silva ab4544d897
DEV: Mark hypothetical_post_from method public (#607) 2024-05-07 15:17:26 -03:00
Discourse Translator Bot 27827c0898
Update translations (#605) 2024-05-07 09:33:25 -04:00
Roman Rizzi 4f1a3effe0
REFACTOR: Migrate Vllm/TGI-served models to the OpenAI format. (#588)
Both endpoints provide OpenAI-compatible servers. The only difference is that Vllm doesn't support passing tools as a separate parameter. Even if the tool param is supported, it ultimately relies on the model's ability to handle native functions, which is not the case with the models we have today.

As a part of this change, we are dropping support for StableBeluga/Llama2 models. They don't have a chat_template, meaning the new API can translate them.

These changes let us remove some of our existing dialects and are a first step in our plan to support any LLM by defining them as data-driven concepts.

 I rewrote the "translate" method to use a template method and extracted the tool support strategies into its classes to simplify the code.

Finally, these changes bring support for Ollama when running in dev mode. It only works with Mistral for now, but it will change soon..
2024-05-07 10:02:16 -03:00
Joffrey JAFFEUX dacc1b9f28
DEV: updates spec following changes in chat (#604)
Also makes this spec to use the `update_message!` helper.
2024-05-07 15:01:06 +02:00
Sam ab78d9b597
REFACTOR: Simplify tool invocation by removing bot_user and llm parameters (#603)
* Well, it was quite a journey but now tools have "context" which
can be critical for the stuff they generate

This entire change was so Dall E and Artist generate images in the correct context

* FIX: improve error handling around image generation

- also corrects image markdown and clarifies code

* fix spec
2024-05-07 21:55:46 +10:00
Sam 88c7427fab
FEATURE: allow @mentioning an ai bot in a channel (#602)
if a persona is mentionable and allows chat allow it to be mentioned in a chat channel
2024-05-07 10:30:39 +10:00
Sam 37a2db5223
FIX: uploader not removing app event (#601)
FIX: restricted to mentionabled vs allowed_chat by mistake
2024-05-06 14:42:55 +10:00
Sam e4b326c711
FEATURE: support Chat with AI Persona via a DM (#488)
Add support for chat with AI personas

- Allow enabling chat for AI personas that have an associated user
- Add new setting `allow_chat` to AI persona to enable/disable chat
- When a message is created in a DM channel with an allowed AI persona user, schedule a reply job
- AI replies to chat messages using the persona's `max_context_posts` setting to determine context
- Store tool calls and custom prompts used to generate a chat reply on the `ChatMessageCustomPrompt` table
- Add tests for AI chat replies with tools and context

At the moment unlike posts we do not carry tool calls in the context.

No @mention support yet for ai personas in channels, this is future work
2024-05-06 09:49:02 +10:00
Keegan George 8875830f6a
FEATURE: Insert footnote from explained result (#591) 2024-05-03 11:53:17 -07:00
Martin Brennan b52d3c7d29
DEV: Moving around admin persona config routes again (#586)
The initial setup done in fb0d56324f
clashed with other plugins, I found this when trying to do the same
for Gamification. This uses a better routing setup and removes the
need to define the config nav link for Settings -- that is always inserted.

Relies on https://github.com/discourse/discourse/pull/26707
2024-05-02 12:42:30 +10:00
Sam 6623928b95
FIX: call after tool calls failing on OpenAI / Gemini (#599)
A recent change meant that llm instance got cached internally, repeat calls
to inference would cache data in Endpoint object leading model to
failures.

Both Gemini and Open AI expect a clean endpoint object cause they
set data.

This amends internals to make sure llm.generate will always operate
on clean objects
2024-05-01 17:50:58 +10:00
Discourse Translator Bot aab59b9327
Update translations (#598) 2024-04-30 21:57:37 +02:00
Kris 6860ee50be
UX: prevent social share content from overflowing container (#597) 2024-04-30 09:47:21 -04:00
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
Sam 85734fef52
FIX: properly cache user locale (#593)
This blob is localized according to user locale, so we can end up
bleeding incorrect data in the cache
2024-04-26 09:28:35 -03:00