Commit Graph

697 Commits

Author SHA1 Message Date
Kris f20ada00db
UX: adjust AI share styles for images and quotes (#567) 2024-04-09 15:36:45 -04:00
Keegan George 8444789974
UX: Update suggestion radii to accommodate for new default (#564) 2024-04-09 10:48:18 -07:00
Discourse Translator Bot 310238d38a
Update translations (#566) 2024-04-09 18:48:54 +02:00
Roman Rizzi aa8918911d
UX: Display the indexing progress for RAG uploads (#557) 2024-04-09 11:03:07 -03:00
Keegan George 35fbf5c836
FIX: Ask AI highlight fixes (#562) 2024-04-08 11:00:03 -07:00
Bianca Nenciu 505650205d
FIX: Fetch categories data using specific endpoint (#543)
It used to fetch it from /site.json, but /categories.json is the more
appropriate one. This one also implements pagination, so we have to do
one request per page.
2024-04-08 11:33:20 +03:00
Keegan George 55d6e1cdf8
UX: Update Ask AI highlight styling (#560) 2024-04-07 10:30:59 -07:00
Rafael dos Santos Silva 969fbae21e
DEV: Hide quick search setting since it's experimental (#559) 2024-04-05 12:12:37 -03:00
Keegan George cb4d438506
UX: Highlight AI post helper selection (#520) 2024-04-04 11:35:01 -07:00
Keegan George fc6b937df7
FIX: Revert length issue (#556) 2024-04-04 10:28:17 -07:00
Sam 830cc26075
FEATURE: Add metadata support for RAG (#553)
* FEATURE: Add metadata support for RAG

You may include non indexed metadata in the RAG document by using

[[metadata ....]]

This information is attached to all the text below and provided to
the retriever.

This allows for RAG to operate within a rich amount of contexts
without getting lost

Also:

- re-implemented chunking algorithm so it streams
- moved indexing to background low priority queue

* Baran gem no longer required.

* tokenizers is on 4.4 ... upgrade it ...
2024-04-04 11:02:16 -03:00
Régis Hanol bc561eb332
DEV: replace diffhtml with morphlex (#555)
morphlex is a lighter and faster morphing library 🚀
2024-04-04 16:00:16 +02:00
Sam 6f5f34184b
FEATURE: add Claude 3 Haiku bot support (#552)
it is close in performance to GPT 4 at a fraction of the cost,
nice to add it to the mix.

Also improves a test case to simulate streaming, I am hunting for
the "calls" word that is jumping into function calls and can't quite
find it.
2024-04-03 16:06:27 +11:00
Discourse Translator Bot 08b53e851c
Update translations (#551) 2024-04-02 18:19:55 +02:00
Roman Rizzi 1f1c94e5c6
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 13:43:34 -03:00
Kris a2018d4a04
UX: add general onebox styles (#550) 2024-03-29 09:50:28 -04:00
Sam fb81307c59
FEATURE: web browsing tool (#548)
This pull request makes several improvements and additions to the GitHub-related tools and personas in the `discourse-ai` repository:

1. It adds the `WebBrowser` tool to the  `Researcher` persona, allowing the AI to visit web pages, retrieve HTML content, extract the main content, and convert it to plain text.

2. It updates the `GithubFileContent`, `GithubPullRequestDiff`, and `GithubSearchCode` tools to handle HTTP responses more robustly (introducing size limits). 

3. It refactors the `send_http_request` method in the `Tool` class to follow redirects when specified, and to read the response body in chunks to avoid memory issues with large responses. (only for WebBrowser)

4. It updates the system prompt for the `Researcher` persona to provide more detailed guidance on when to use Google search vs web browsing, and how to optimize tool usage and reduce redundant requests.

5. It adds a new `web_browser_spec.rb` file with tests for the `WebBrowser` tool, covering various scenarios like handling different HTML structures and following redirects.
2024-03-28 16:01:58 +11:00
Sam 74c6725c75
FIX: avoid error when attempting to show ai helper to anon (#549)
Also adds an extra guard around ai helper context positioning.
2024-03-28 12:24:00 +11:00
Sam 61e4c56e1a
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-27 14:30:11 +11:00
Discourse Translator Bot 82387cc51d
Update translations (#547) 2024-03-26 10:21:23 -03:00
Martin Brennan c3b26ccb10
DEV: Move admin routes + templates to admin/assets/javascripts/ path (#545)
This ensures these routes and templates are not loaded if the user isn't
admin. Only affects Persona routes at this point in time.
2024-03-25 09:58:53 +10:00
Natalie Tay f3b3312ce0
FIX: Avoid replying to the reply user for llm_triage automation (#544)
Avoid replying to the reply user. This causes an infinite conversation from the reply_user to the reply_user
2024-03-22 12:34:18 +08:00
Jarek Radosz 1d476e3b68
DEV: Remove an unused template (#541) 2024-03-21 15:24:29 +01: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 5cac47a30a
FIX: unify automation model translation (#540)
report runner and llm triage used different paths to figure out
underlying model name, unify so we use the same path.

fixes claude 3 based models on llm triage
2024-03-21 11:32:35 +11:00
Sam e8b2a200c1
FIX: prompt engineering for summary prompt (#539)
Prompt was steering incorrectly into the wrong language.

New prompt attempts to be more concise and clear and provides
better guidance about size of summary and how to format it.
2024-03-20 16:33:05 +11:00
Sam 41f1530078
FIX: mention suppression was not working right (#538)
We were only suppressing non mentions, ones that become spans.

@sam in the test was not resolving to a mention cause the user
did not exist.

depends on: https://github.com/discourse/discourse/pull/26253 for tests to pass.
2024-03-20 13:00:39 +11:00
Discourse Translator Bot 1a55d7f6e7
Update translations (#536) 2024-03-19 16:00:17 +01:00
Sam cc0369dd39
FEATURE: friendlier reply behavior in bot PMs (#535)
- Stop replying as bot, when human replies to another human
- Reply as correct persona when replying directly to a persona
- Fix paper cut where suppressing notifications was not doing so
2024-03-19 20:15:12 +11:00
Sam f62703760f
FEATURE: add Claude 3 sonnet/haiku support for Amazon Bedrock (#534)
This PR consolidates the  implements new Anthropic Messages interface for Bedrock Claude endpoints and adds support for the new Claude 3 models (haiku, opus, sonnet).

Key changes:
- Renamed `AnthropicMessages` and `Anthropic` endpoint classes into a single `Anthropic` class (ditto for ClaudeMessages -> Claude)
- Updated `AwsBedrock` endpoints to use the new `/messages` API format for all Claude models
- Added `claude-3-haiku`, `claude-3-opus` and `claude-3-sonnet` model support in both Anthropic and AWS Bedrock endpoints
- Updated specs for the new consolidated endpoints and Claude 3 model support

This refactor removes support for old non messages API which has been deprecated by anthropic
2024-03-19 06:48:46 +11:00
Sam d7ed8180af
FEATURE: allow suppression of notifications from report generation (#533)
* FEATURE: allow suppression of notifications from report generation

Previously we needed to do this by hand, unfortunately this uses up
too many tokens and is very hard to discover.

New option means that we can trivially disable notifications without
needing any prompt engineering.

* URI.parse is safer, use it
2024-03-16 08:05:03 +11:00
David Taylor dfc13fc631
UX: Add title suffix to shared AI pages (#531) 2024-03-15 10:31:58 +00:00
David Taylor 8b0e9984cf
FIX: Syntax highlighting for shared-ai conversions with CSP enabled (#532)
- Adds a nonce to both script tags
- Removes the `onload=` inline script, and moves the tags to the end of the `<body>` instead. This provides the same UX (page will load and render, then hljs will be applied when ready)
2024-03-15 13:48:24 +11:00
Rafael dos Santos Silva 3b8f900486
FIX: Handle unicode on tokenizer (#515)
* FIX: Handle unicode on tokenizer

Our fast track code broke when strings had characters who are longer in tokens than
in UTF-8.

Admins can set `DISCOURSE_AI_STRICT_TOKEN_COUNTING: true` in app.yml to ensure token counting is strict, even if slower.


Co-authored-by: wozulong <sidle.pax_0e@icloud.com>
2024-03-14 17:33:30 -03:00
Rafael dos Santos Silva b327313115
DEV: Fix module namespace breaking reloads (#530) 2024-03-14 15:19:28 -03:00
Kris fc6c3c81e7
UX: add support for dark mode (#529) 2024-03-13 13:16:07 -04:00
Sam ea5c38686e
FIX: expire assets when CSS changes FIX: missing translation on share page (#528)
* FIX: expire assets when CSS changes
FIX: missing translation on share page

Also add trivial image styling

* oops not needed
2024-03-13 20:52:33 +11: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
Roman Rizzi c4ead89c6b
FIX: Filter soft-deleted topics when backfilling sentiment (#527) 2024-03-12 21:01:24 -03:00
Kris 1c90ad81c2
UX: update styles and markup for share feature (#525) 2024-03-12 18:25:33 -04:00
Discourse Translator Bot 25d283b527
Update translations (#524) 2024-03-12 15:40:21 +01: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
Sam 79638c2f50
FIX: Tune function calling (#519)
Adds support for "name" on functions which can be used for tool calls

For function calls we need to keep track of id/name and previously
we only supported either

Also attempts to improve sql helper
2024-03-09 08:46:40 +11:00
Keegan George b515b4f66d
FEATURE: AI Quick Semantic Search (#501)
This PR adds AI semantic search to the search pop available on every page.

It depends on several new and optional settings, like per post embeddings and a reranker model, so this is an experimental endeavour.


---------

Co-authored-by: Rafael Silva <xfalcox@gmail.com>
2024-03-08 13:02:50 -03:00
David Taylor 114b96f2b4
DEV: Update to new header API and FloatKit (#516) 2024-03-08 10:07:48 +00:00
Sam 936d246b7d
FIX: Improve AI persona editor inputs and optional GitHub auth (#518)
1. Fix input fields in AI persona editor and make GitHub tool authentication optional

2. AI persona editor improvements and tool GitHub access token check

This pull request makes a few improvements:

- Adds `lang="en"` to number input fields in the AI persona editor to prevent localization issues 
- Adds `step="any"` to allow fractional values for temperature and top_p settings
- Makes GitHub tool authentication contingent on `ai_bot_github_access_token` site setting being present

see: https://meta.discourse.org/t/ai-bot-personas-don-t-accept-decimals-for-temperature-top-p/298243/7
2024-03-08 09:54:05 +11:00
Sam 2ad743d246
FEATURE: Add GitHub Helper AI Bot persona and tools (#513)
Introduces a new AI Bot persona called 'GitHub Helper' which is specialized in assisting with GitHub-related tasks and questions. It includes the following key changes:

- Implements the GitHub Helper persona class with its system prompt and available tools
   
- Adds three new AI Bot tools for GitHub interactions:
  - github_file_content: Retrieves content of files from a GitHub repository
  - github_pull_request_diff: Retrieves the diff for a GitHub pull request
  - github_search_code: Searches for code in a GitHub repository
    
- Updates the AI Bot dialects to support the new GitHub tools

- Implements multiple function calls for standard tool dialect
2024-03-08 06:37:23 +11:00
Rafael dos Santos Silva 176a4458f2
FIX: Prevent AI chat thread titles from being created before replies are posted (#517)
Chat thread replies draft trigger the thread_created event, which we relied on
to trigger the AI generated title. Because of that we now will use the noisier
chat_message_created event, and manually check for thread and replies existence.

See https://github.com/discourse/discourse/pull/26033
2024-03-07 16:14:17 -03:00