Commit Graph

62 Commits

Author SHA1 Message Date
Keegan George 943504049c
FIX: Prevent proofreading when there is no content (#779) 2024-08-28 12:21:34 -07:00
Sam f148452f4c
FEATURE: single click proofreading (#769)
Previously there was too much work proofreading text, new implementation
provides a single shortcut and easy way of proofreading text.


Co-authored-by: Martin Brennan <martin@discourse.org>
2024-08-26 15:43:40 +10:00
Keegan George c0328267be
FIX: Add original upload markdown on caption failure (#762) 2024-08-20 12:53:51 -07:00
Keegan George 867cd54556
DEV: Reduce megapixel requirement for auto image captioning (#754) 2024-08-14 11:26:56 -07:00
Sam 1320eed9b2
FEATURE: move summary to use llm_model (#699)
This allows summary to use the new LLM models and migrates of API key based model selection

Claude 3.5 etc... all work now. 

---------

Co-authored-by: Roman Rizzi <rizziromanalejandro@gmail.com>
2024-07-04 10:48:18 +10:00
Keegan George ef4b3559cd
FIX: Disabled chat breaks `ai-chat-summarization` (#697) 2024-07-02 11:10:31 -07:00
Keegan George 1b0ba9197c
DEV: Add summarization logic from core (#658) 2024-07-02 08:51:59 -07:00
Sam b863ddc94b
FEATURE: custom user defined tools (#677)
Introduces custom AI tools functionality. 

1. Why it was added:
   The PR adds the ability to create, manage, and use custom AI tools within the Discourse AI system. This feature allows for more flexibility and extensibility in the AI capabilities of the platform.

2. What it does:
   - Introduces a new `AiTool` model for storing custom AI tools
   - Adds CRUD (Create, Read, Update, Delete) operations for AI tools
   - Implements a tool runner system for executing custom tool scripts
   - Integrates custom tools with existing AI personas
   - Provides a user interface for managing custom tools in the admin panel

3. Possible use cases:
   - Creating custom tools for specific tasks or integrations (stock quotes, currency conversion etc...)
   - Allowing administrators to add new functionalities to AI assistants without modifying core code
   - Implementing domain-specific tools for particular communities or industries

4. Code structure:
   The PR introduces several new files and modifies existing ones:

   a. Models:
      - `app/models/ai_tool.rb`: Defines the AiTool model
      - `app/serializers/ai_custom_tool_serializer.rb`: Serializer for AI tools

   b. Controllers:
      - `app/controllers/discourse_ai/admin/ai_tools_controller.rb`: Handles CRUD operations for AI tools

   c. Views and Components:
      - New Ember.js components for tool management in the admin interface
      - Updates to existing AI persona management components to support custom tools 

   d. Core functionality:
      - `lib/ai_bot/tool_runner.rb`: Implements the custom tool execution system
      - `lib/ai_bot/tools/custom.rb`: Defines the custom tool class

   e. Routes and configurations:
      - Updates to route configurations to include new AI tool management pages

   f. Migrations:
      - `db/migrate/20240618080148_create_ai_tools.rb`: Creates the ai_tools table

   g. Tests:
      - New test files for AI tool functionality and integration

The PR integrates the custom tools system with the existing AI persona framework, allowing personas to use both built-in and custom tools. It also includes safety measures such as timeouts and HTTP request limits to prevent misuse of custom tools.

Overall, this PR significantly enhances the flexibility and extensibility of the Discourse AI system by allowing administrators to create and manage custom AI tools tailored to their specific needs.

Co-authored-by: Martin Brennan <martin@discourse.org>
2024-06-27 17:27:40 +10:00
Keegan George 90c5e4bb0e
FIX: Reply broken when auto caption is enabled (#642) 2024-05-27 12:17:35 -07:00
Keegan George a1c649965f
FEATURE: Auto image captions (#637) 2024-05-27 10:49:24 -07: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
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 4a29f8ed1c
FEATURE: Enhance AI debugging capabilities and improve interface adjustments (#577)
* FIX: various RAG edge cases

- Nicer text to describe RAG, avoids the word RAG
- Do not attempt to save persona when removing uploads and it is not created
- Remove old code that avoided touching rag params on create

* FIX: Missing pause button for persona users

* Feature: allow specific users to debug ai request / response chains

This can help users easily tune RAG and figure out what is going
on with requests.

* discourse helper so it does not explode

* fix test

* simplify implementation
2024-04-15 23:22:06 +10:00
Martin Brennan fb0d56324f
FEATURE: Improve admin plugin UI and use new plugins show route (#512)
This commit changes Discourse AI's admin plugin page to use the new plugin
show route. The UI for persona editing has also been improved for consistency,
and other plugin UIs will follow suit:

Settings for the plugin are now listed in the plugin UI and can be changed
from there directly after core PR discourse/discourse#26154 is merged.

See also:

* https://github.com/discourse/discourse/pull/26024
* https://github.com/discourse/discourse/pull/26154
* https://github.com/discourse/discourse/pull/26254
2024-03-21 14:29:56 +10:00
Sam 9d92dd76fb
FIX: don't show share conversation incorrectly (#526)
* FIX: don't show share conversation incorrectly

- ai_persona_name can be null vs undefined leading to button showing up where it should not
- do not allow sharing of conversations where user is sending PMs to self

* remove erroneous code

* avoid query
2024-03-13 11:24:22 +11:00
Kelv d57212475c
FIX: ai-image-caption should not crash on checking currentUser can_use_assistant (#523) 2024-03-12 16:40:30 +08:00
Sam a03bc6ddec
FEATURE: Share conversations with AI via a URL (#521)
This allows users to share a static page of an AI conversation with
the rest of the world.

By default this feature is disabled, it is enabled by turning on
ai_bot_allow_public_sharing via site settings

Precautions are taken when sharing

1. We make a carbonite copy
2. We minimize work generating page
3. We limit to 100 interactions
4. Many security checks - including disallowing if there is a mix
of users in the PM.

* Bonus commit, large PRs like this PR did not work with github tool
large objects would destroy context


Co-authored-by: Martin Brennan <martin@discourse.org>
2024-03-12 16:51:41 +11:00
Keegan George 740731ab53
FIX: Image caption feature should respect composer AI helper groups (#522) 2024-03-11 15:35:20 -07:00
David Taylor 114b96f2b4
DEV: Update to new header API and FloatKit (#516) 2024-03-08 10:07:48 +00:00
Sam 59bab2bba3
FIX: stream messages when directly PMing a persona (#500)
previous to this fix we did not consider personas a bot in the
front end
2024-03-01 07:53:42 +11:00
Keegan George 6a30b06a55
DEV: Cancel popup should abort request (#497) 2024-02-28 13:32:45 -08:00
Keegan George a1b607db80
FIX: Composer service call breaking shared edits (#494) 2024-02-28 10:13:46 +11:00
Keegan George 0596ce41fe
DEV: Auto save caption on mobile view (#486) 2024-02-23 10:06:39 -08:00
Kris 0f761234f9
UX: minor adjustments for image caption size, behavior (#484) 2024-02-22 12:31:25 -05:00
Sam becbe01f68
FIX: unable to share conversations with persona user (#479)
Persona users are still bots, but we were not properly accounting
for it and share icon was not showing up.

This depends on a core change that adds .topic to transformed posts
2024-02-20 16:16:23 +11:00
Rafael dos Santos Silva cf19ce0d72
FEATURE: Handle secure uploads in image caption (#476) 2024-02-19 18:08:19 -03:00
Keegan George a9b2d6a30a
FEATURE: AI image caption (#470)
This PR adds a new feature where you can generate captions for images in the composer using AI.

---------

Co-authored-by: Rafael Silva <xfalcox@gmail.com>
2024-02-19 14:56:28 -03:00
Roman Rizzi 8bd8280427
FIX: Hide related topics when module is disabled (#461) 2024-02-05 11:45:24 -03:00
Sam 8df966e9c5
FEATURE: smooth streaming of AI responses on the client (#413)
This PR introduces 3 things:

1. Fake bot that can be used on local so you can test LLMs, to enable on dev use:

SiteSetting.ai_bot_enabled_chat_bots = "fake"

2. More elegant smooth streaming of progress on LLM completion

This leans on JavaScript to buffer and trickle llm results through. It also amends it so the progress dot is much 
more consistently rendered

3. It fixes the Claude dialect 

Claude needs newlines **exactly** at the right spot, amended so it is happy 

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
2024-01-11 15:56:40 +11:00
Sam 05f7808057
FEATURE: more elegant progress (#409)
Previous to this change it was very hard to tell if completion was
stuck or not.

This introduces a "dot" that follows the completion and starts
flashing after 5 seconds.
2024-01-09 09:20:28 -03:00
Roman Rizzi 971e03bdf2
FEATURE: AI Bot Gemini support. (#402)
It also corrects the syntax around tool support, which was wrong.

Gemini doesn't want us to include messages about previous tool invocations, so I had to shuffle around some code to send the response it generated from those invocations instead. For this, I created the "multi_turn" context, which bundles all the context involved in the interaction.
2024-01-04 18:15:34 -03:00
Roman Rizzi aa56baad37
FEATURE: Add Mixtral support for AI Bot (#396) 2024-01-04 12:22:43 -03:00
Sam 933784a873
FEATURE: allow easy sharing of bot conversations (#385)
* FEATURE: allow easy sharing of bot conversations

* Lean on new core API i

* Added system spec for copy functionality


* Update assets/javascripts/initializers/ai-bot-replies.js

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>

* discourse later insted of setTimeout

* Update spec/system/ai_bot/share_spec.rb

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>

* feedback from review

just check the whole payload

* remove uneeded code

* fix spec

---------

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
2023-12-29 19:47:47 +11:00
Sam a66b1042cc
FEATURE: scale up result count for search depending on model (#346)
We were limiting to 20 results unconditionally cause we had to make
sure search always fit in an 8k context window.

Models such as GPT 3.5 Turbo (16k) and GPT 4 Turbo / Claude 2.1 (over 150k)
allow us to return a lot more results.

This means we have a much richer understanding cause context is far
larger.

This also allows a persona to tweak this number, in some cases admin
may want to be conservative and save on tokens by limiting results

This also tweaks the `limit` param which GPT-4 liked to set to tell
model only to use it when it needs to (and describes default behavior)
2023-12-11 16:54:16 +11:00
Keegan George f7277d244e
DEV: Mix semantic search results with normal results (#278) 2023-11-17 12:46:59 -08:00
David Taylor 0902f74af5
DEV: Update linting configs (#280) 2023-11-03 11:30:09 +00:00
Andrei Prigorshnev 4877394081
DEV: stop using the deprecated cookAsync function (#247)
The cookAsync functions is deprecated since discourse/discourse@fcc9d99.
2023-10-11 20:48:37 +04:00
Keegan George abe96d5533
DEV: Strip out old modal based AI helper (#209) 2023-09-06 13:28:47 -07:00
Rafael dos Santos Silva 2c0f535bab
FEATURE: HyDE-powered semantic search. (#136)
* FEATURE: HyDE-powered semantic search.

It relies on the new outlet added on discourse/discourse#23390 to display semantic search results in an unobtrusive way.

We'll use a HyDE-backed approach for semantic search, which consists on generating an hypothetical document from a given keywords, which gets transformed into a vector and used in a asymmetric similarity topic search.

This PR also reorganizes the internals to have less moving parts, maintaining one hierarchy of DAOish classes for vector-related operations like transformations and querying.

Completions and vectors created by HyDE will remain cached on Redis for now, but we could later use Postgres instead.

* Missing translation and rate limiting

---------

Co-authored-by: Roman Rizzi <rizziromanalejandro@gmail.com>
2023-09-05 11:08:23 -03:00
Sam 3f9973586e
FIX: ai_bot_allowed_groups now works with restricted visibility (#180)
Previous to this change we relied on client side settings to
determine if an end user has access to the ai bot.

This meant that if a user was not aware they are a member of a
group (as it is with restricted visibility ones) they would not
see the bot button.

All checking has now moved to the server side, and tests were
added to cover.
2023-09-04 11:52:44 +10:00
Sam 8e4347acba
DEV: rename ai_helper_add_ai_pm_to_header -> ai_bot_add_to_header (#177)
Old name was very unclear, this setting is only used for the bot
so now it follows the same convention others do
2023-08-31 14:42:28 +10:00
Sam db19e37748
FEATURE: add initial support for personas (#172)
This splits out a bunch of code that used to live inside bots
into a dedicated concept called a Persona.

This allows us to start playing with multiple personas for the bot

Ships with:

artist - for making images
sql helper - for helping with data explorer
general - for everything and anything
 
Also includes a few fixes that make the generic LLM function implementation  more robust
2023-08-30 16:15:03 +10:00
Roman Rizzi 79289ba231
FIX: Use base 10 when gettings allowed group IDs from settings. (#113)
A missing parameter on the `parseInt` function was causing unexpected UI behavior for the AI helper since it turned an allowed group ID into NaN. We should always use base10 when parsing these IDs.
2023-07-24 11:29:49 -03:00
Rafael dos Santos Silva f34094f6cc
FIX: Show related topics when scrolling long topics (#111)
* FIX: Show related topics when scrolling long topics

* Update assets/javascripts/initializers/related-topics.js

Co-authored-by: Roman Rizzi <roman@discourse.org>

---------

Co-authored-by: Roman Rizzi <roman@discourse.org>
2023-07-19 19:19:38 -03:00
Roman Rizzi 3364fec425
DEV: Remove the summarization feature (#83)
* DEV: Remove the summarization feature

Instead, we'll register summarization implementations for OpenAI, Anthropic, and Discourse AI using the API defined in discourse/discourse#21813.

Core and chat will implement features on top of these implementations instead of this plugin extending them.

* Register instances that contain the model, requiring less site settings
2023-06-13 14:32:26 -03:00
Sam 96d521198b
FIX: missing localization (#81)
blog.start_gpt_chat -> was on my blog

This also slightly tunes the search prompt to support filtering by oldest
and try a tiny bit harder to guide GPT 3.5 which is a bit of a losing battle

Co-authored-by: Krzysztof Kotlarek <kotlarek.krzysztof@gmail.com>
2023-05-25 11:05:02 +10:00
Roman Rizzi ba65d42940
FIX: Hide summarization button from anons (#70) 2023-05-18 12:34:49 -03:00
David Taylor 261fe13599
DEV: Tweaks for drop-down implementation (#69)
- Remove unused 'toggleAiBotPanel' widget action

- Switch from appEvents to closure actions

- Convert widget definition to native class syntax, so that we can use `@action` decorator. (alternatively, we could have done `{ closePanel: this.hideAiBotPanel.bind(this) }` in `RenderGlimmer`
2023-05-18 09:28:43 +01:00
Sam deb34bb52f
UX: improve drop down menu for enabled bots (#68)
Previously we were not using using HeaderPanel for drop down, which caused
it not to properly act like a header panel.

- Not styled right
- Not hidden when other buttons clicked

Etc...

Header is sadly full of legacy so this is somewhat hacky weaving widgets.
2023-05-18 16:10:08 +10:00
Roman Rizzi 362f6167d1
FEATURE: Less friction for starting a conversation with an AI bot. (#63)
* FEATURE: Less friction for starting a conversation with an AI bot.

This PR adds a new header icon as a shortcut to start a conversation with one of our AI Bots. After clicking and selecting one from the dropdown menu, we'll open the composer with some fields already filled (recipients and title).

If you leave the title as is, we'll queue a job after five minutes to update it using a bot suggestion.

* Update assets/javascripts/initializers/ai-bot-replies.js

Co-authored-by: Rafael dos Santos Silva <xfalcox@gmail.com>

* Update assets/javascripts/initializers/ai-bot-replies.js

Co-authored-by: Rafael dos Santos Silva <xfalcox@gmail.com>

---------

Co-authored-by: Rafael dos Santos Silva <xfalcox@gmail.com>
2023-05-16 14:38:21 -03:00