Commit Graph

188 Commits

Author SHA1 Message Date
Rafael dos Santos Silva 86591cf1d2
CHORE: Update Readme (#185) 2023-09-04 15:46:35 -03:00
Rafael dos Santos Silva 4864978495
FEATURE: Return only applicable suggestions in AiHelper category/tags suggestions (#184) 2023-09-04 14:30:33 -03:00
Rafael dos Santos Silva 3c4a53b2cb
FEATURE: Better link in Claude summaries (#183)
* FEATURE: Better link in Claude summaries

* lint
2023-09-04 12:04:47 -03:00
Sam e3abbd9f46
FEATURE: add researcher persona (#181)
The researcher persona has access to Google and can perform
various internet research tasks. At the moment it can not read
web pages, but that is under consideration
2023-09-04 12:05:27 +10: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
Rafael dos Santos Silva 43e485cbd9
FEATURE: Additional AI suggestion options (#176) 2023-09-01 17:10:58 -07:00
Sam 181113159b
FIX: setting explorer was exceeding token budget
This refactor changes it so we only include minimal data in the
system prompt which leaves us lots of tokens for specific searches

The new search command allows us to pull in settings on demand

Descriptions are include in short search results, and names only
in longer results

Also: 

* In dev it is important to tell when calls are made to open ai
this adds a console log to increase awareness around token usage

* PERF: stop counting tokens so often

This changes it so we only count tokens once per response

Previously each time we heard back from open ai we would count
tokens, leading to uneeded delays

* bug fix, commands may reach in for tokenizer

* add logging to console for anthropic calls as well

* Update lib/shared/inference/openai_completions.rb

Co-authored-by: Martin Brennan <mjrbrennan@gmail.com>
2023-09-01 11:48:51 +10:00
Loïc Guitaut 65091690eb DEV: Don’t use `Chat::MessageCreator` in specs
As message creation is being rewritten in
https://github.com/discourse/discourse/pull/22390, a new way of using
the underlying service to create chat messages has been implemented in
https://github.com/discourse/discourse/pull/23222.

This patch uses the new fabricator option which will prevent breaking
specs from this plugin when the main PR will be merged.
2023-08-31 11:30:07 +02:00
Sam 00d69b463e
FEATURE: new site setting explorer persona (#178)
Also adds ai_bot_enabled_personas so admins can tweak which stock
personas are enabled.

The new persona has a full listing of all site settings and is
able to get context for each setting.

This means you can ask it to search through settings for something
relevant.

Security wise there is no access to actual configuration of settings
just to the names / description and implementation.

Previously this was part of the forum helper persona however it
just clashes too much with other behaviors, isolating it makes
it far more powerful.

* sneaking this one in, user_emails is a non obvious table in our
structure.

usually one would assume users has emails so the clarifies a bit
better. plus it is a very common table to hit.
2023-08-31 17:02:03 +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
Rafael dos Santos Silva 6d69fb479e
DEV: Hide old embeddings pg setting (#169)
* DEV: Hide old embeddings pg setting

* fix yaml
2023-08-29 17:39:21 -03:00
Keegan George 4da4b5609f
FIX: Show warning when trying to generate suggestions without content (#175) 2023-08-29 11:58:45 -07:00
Keegan George 494964c51d
DEV: Dynamically set popper placement (#174) 2023-08-29 11:19:25 -07:00
Keegan George 7457feced8
FEATURE: Show suggested title prompt in new location (#171) 2023-08-29 09:45:53 -07:00
Discourse Translator Bot 345bfed19f
Update translations (#173) 2023-08-29 15:51:02 +02:00
Sam 8fdb88604f
FIX: trim first space when getting a reply from anthropic (#164)
Anthropic loves sending a pointless leading space with completions
this throws off the command framework.
2023-08-29 10:57:36 +10:00
Sam b14cb864dc
FEATURE: add setting_context experimental command (#160)
This command can be used to extract information about a discourse
site setting directly from source.

To operate it needs the rg binary in the container.
2023-08-29 10:43:58 +10:00
Keegan George fba419f864
UX: Clicking outside editor should close context menu (#170) 2023-08-28 15:08:51 -07:00
Keegan George 2c50791f26
UX: Prevent context menu overflow outside of container (#168) 2023-08-28 13:31:21 -07:00
Keegan George b470692409
DEV: Preload prompt list on component initialization (#165) 2023-08-28 12:22:44 -07:00
Keegan George 6e01b2c334
UX: Improve styling and make button full width of context menu (#167) 2023-08-28 12:22:32 -07:00
Keegan George 657b2d681a
DEV: Update ESLint config version (#166) 2023-08-28 12:21:52 -07:00
Rafael dos Santos Silva 513c51dcb2
FIX: Renumber StableBeluga2 AiHelper prompts to fix conflict (#163) 2023-08-25 17:19:50 -03:00
Rafael dos Santos Silva e673b568d9
FEATURE: StableBeluga2 support for AiHelper (#162)
* FEATURE: StableBeluga2 support for AiHelper

* lint
2023-08-25 15:54:51 -03:00
Keegan George 7790313b1b
DEV: Add review menu state (#159) 2023-08-24 17:49:24 -07:00
Keegan George 65c6b5e16c
DEV: Add keybindings (#157)
- Ability to Esc to close context menu
- Ability to Ctrl/Cmd + Z to undo results
2023-08-24 08:35:53 +10:00
Keegan George 78558b9cf5
DEV: Remove context menu timeout (#156) 2023-08-23 15:12:07 -07:00
Keegan George 3cf316fb62
FIX: Context menu not appearing in Firefox (#154) 2023-08-23 14:20:31 -07:00
Sam 7d943be7b2
FIX: automatic bot titles missing sometime (#151)
This fixes 2 big issues:

1. No matter how hard you try, grounding anthropic title prompt
is just too hard. This works around by only looking at the last
sentence it returns and treating as title

2. Non English locales would be stuck with "generic" title, this
ensures every bot message gets a title, using a custom field to
track

Also, slightly tunes some anthropic prompts.
2023-08-24 07:20:24 +10:00
Keegan George 45b7b57726
FIX: Pages with small composers breaking (#155) 2023-08-23 14:20:14 -07:00
Keegan George 1289ae1c57
FIX: Add check for PMs before showing AI helper context menu (#153) 2023-08-23 11:24:51 -07:00
Keegan George 4a00b7eb0e
FIX: Show AI helper only if in allowed groups (#152) 2023-08-23 11:06:04 -07:00
Keegan George 6df850d473
FEATURE: AI Helper Context Menu (#148) 2023-08-23 10:35:40 -07:00
Sam f0e1c72aa7
FEATURE: implement command framework for non Open AI (#147)
Open AI support function calling, this has a very specific shape
that other LLMs have not quite adopted.

This simulates a command framework using system prompts on LLMs
that are not open AI.

Features include:

- Smart system prompt to steer the LLM
- Parameter validation (we ensure all the params are specified correctly)

This is being tested on Anthropic at the moment and intial results
are promising.
2023-08-23 07:49:36 +10:00
Discourse Translator Bot 95881fce74
Update translations (#149) 2023-08-22 14:34:48 -03:00
Roman Rizzi f111bcb35b
FIX: Display related topics when scrolling to the bottom of a topic. (#150)
Besides updating the connector using the new tracking preference service interface, this PR fixes a bug where due to `ai_embeddings_semantic_related_topics_enabled` not having `client: true` the initializer never ran, and we didn't show the related topics list when scrolling to the bottom of a long topic.
2023-08-22 14:10:21 -03:00
Sam 78f61914c8
FIX: improve token counting (#145)
Previously we were not counting functions correctly and not
accounting for minimum token count per message

This corrects both issues and improves documentation internally
2023-08-22 08:36:41 +10:00
Rafael dos Santos Silva ea5a443588
FEATURE: Try to generate OpenAI Summaries in current language (#146)
* FEATURE: Try to generate OpenAI Summaries in current language

* lint
2023-08-21 15:40:32 -03:00
Penar Musaraj f9105343a6
DEV: Pin plugin for Discourse 3.1 stable (#143) 2023-08-21 14:46:54 -03:00
Martin Brennan 486a130c25
DEV: Categorize plugin settings into discourse_ai (#144)
Moving the plugin settings into a more specific category
makes them easier to find in the plugin UI and removes
them from the generic "Plugins" tab.
2023-08-21 14:46:34 -03:00
Roman Rizzi c0415bb7eb
UX: Pill design is the default on both mobile and desktop (#142) 2023-08-17 14:37:14 -03:00
Sam 3e46250f3f
UX: Adjust bot warning so it looks better (#141)
This moves the bot warning from `composer-after-composer-editor` to
`after-d-editor` (with a minor adjustment for outlet args to match new name)
2023-08-17 14:43:14 +10:00
Sam b4477ecdcd
FEATURE: support 16k and 32k variants for Azure GPT (#140)
Azure requires a single HTTP endpoint per type of completion.

The settings: `ai_openai_gpt35_16k_url` and `ai_openai_gpt4_32k_url` can be
used now to configure the extra endpoints

This amends token limit which was off a bit due to function calls and fixes
a minor JS issue where we were not testing for a property
2023-08-17 11:00:11 +10:00
Sam 01f833f86e
FEATURE: optional warning attached to all AI bot conversations (#137)
* FEATURE: optional warning attached to all AI bot conversations

This commit introduces `ai_bot_enable_chat_warning` which can be used
to warn people prior to starting a chat with the bot.

In particular this is useful if moderators are regularly reading chat
transcripts as it sets expectations early.

By default this is disabled.

Also:

- Stops making ajax call prior to opening composer
- Hides PM title when starting a bot PM

Co-authored-by: Rafael dos Santos Silva <xfalcox@gmail.com>
2023-08-17 06:29:58 +10:00
Rafael dos Santos Silva 49f2453c2d
FEATURE: Tweaks to Anthropic Summarization (#138)
* FEATURE: Tweaks to Anthropic Summarization

* fix specs
2023-08-16 15:09:52 -03:00
Rafael dos Santos Silva 0738f67fa4
FIX: Fix embeddings truncation strategy (#139) 2023-08-16 15:09:41 -03:00
Discourse Translator Bot 525c8b0913
Update translations (#135) 2023-08-15 21:25:07 +02:00
Sam 20c1f2d788
FEATURE: basic progress for image generation (#133)
previously you would have to wait quite a while to see the prompt this implements
a very basic implementation of progress so you can see the API is working.

Also: 

- Fix google progress.
- Handle the incredibly rare, zero results from google.
- Simplify command so it is less error prone
- replace invoke and attache results with a invoke
- ensure invoke can only ever be run once
- pass in all the information a command needs in constructor
- use new pattern throughout
- test invocation in isolation
2023-08-14 16:30:12 +10:00
Roman Rizzi b076e43d67
FEATURE: streaming mode for the FoldContent strategy. (#134) 2023-08-11 15:08:54 -03:00