Commit Graph
94 Commits
Author SHA1 Message Date
Sam Saffron d544f2101b more tweaks... 2023-05-31 17:15:32 +10:00
Sam Saffron 2d299900b9 we certainly do not need search through pinned topics for now...
This just causes bots to get confused.
2023-05-29 14:15:12 +10:00
Sam Saffron c7781c57fc Fix all specs
Also ensure triage is more consistent by reducing temp
2023-05-29 14:11:32 +10:00
Sam Saffron db11fe391d FEATURE: use triage command to attempt to ground models on GPT 3.5
Previous to this change our results were ungrounded and simpler models like
GPT 3.5 and claude had a real tough time figuring out how to run commands

This splits responses into 2 phases:

Phase 1: figure out if you need to run a command
Phase 2: respond to user

This seems to produce better results on both Claude and GPT 3.5 but still
needs a fair bit of tuning.
2023-05-26 17:07:52 +10:00
SamandKrzysztof Kotlarek 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 <[email protected]>
2023-05-25 11:05:02 +10:00
Rafael dos Santos SilvaandDavid Taylor cfc6e388df FIX: Ensure embeddings database outages are handled gracefully (#80)
The rails_failover middleware will intercept all `PG::ConnectionBad` errors and put the cluster into readonly mode. It does not have any handling for multiple databases. Therefore, an issue with the embeddings database was taking the whole cluster into readonly.

This commit fixes the issue by rescuing `PG::Error` from all AI database accesses, and re-raises errors with a different class. It also adds a spec to ensure that an embeddings database outage does not affect the functionality of the topics/show route.

Co-authored-by: David Taylor <[email protected]>
2023-05-23 22:57:52 +01:00
Rafael dos Santos Silva b213fe7f94 FIX: Give up trying to reuse the DB connection and rely on pgbouncer (#79) 2023-05-23 15:12:59 -03:00
Roman Rizzi c582e3b848 DEV: Fix toxicity test (#78) 2023-05-23 11:02:11 -03:00
Sam d85b503ed4 FIX: guide GPT 3.5 better (#77)
* FIX: guide GPT 3.5 better

This limits search results to 10 cause we were blowing the whole token
budget on search results, additionally it includes a quick exchange at
the start of a session to try and guide GPT 3.5 to follow instructions

Sadly GPT 3.5 drifts off very quickly but this does improve stuff a bit.

It also attempts to correct some issues with anthropic, though it still is
surprisingly hard to ground

* add status:public, this is a bit of a hack but ensures that we can search
for any filter provided

* fix specs
2023-05-23 23:08:17 +10:00
Sam b82fc1e692 FIX: ensure we only attempt embedding once every 15 minutes (#76)
This also heavily reduced log noise and ensures our exception handling is
more surgical.
2023-05-23 10:43:24 +10:00
Sam 074d00ca32 FEATURE: improve search prompt (#75)
- We only support searching public topics - make it clear
- Stop using bug/feature, cause is poisons system - these may not exist
- Add after: and before: which are very handy for bounding search results
2023-05-23 07:52:14 +10:00
Sam e0cf7b7d70 FIX: results will be nil for invalid queries (#74)
Previous to this change invalid searches would break the command.
2023-05-22 15:14:26 +10:00
Sam 92fb84e24d iterate commands (#73)
* FEATURE: introduce a more efficient formatter

Previous formatting style was space inefficient given JSON consumes lots
of tokens, the new format is now used consistently across commands

Also fixes

- search limited to 10
- search breaking on limit: non existent directive

* Slight improvement to summarizer
Stop blowing up context with custom prompts

* ensure we include the guiding message

* correct spec

* langchain style summarizer ...

much more accurate (albeit more expensive)

* lint
2023-05-22 12:09:14 +10:00
SamandRoman Rizzi d59ed1091b FEATURE: add support for GPT <-> Forum integration
This change-set connects GPT based chat with the forum it runs on. Allowing it to perform search, lookup tags and categories and summarize topics. 

The integration is currently restricted to public portions of the forum. 

Changes made:

- Do not run ai reply job for small actions
- Improved composable system prompt
- Trivial summarizer for topics
- Image generator 
- Google command for searching via Google
- Corrected trimming of posts raw (was replacing with numbers) 
- Bypass of problem specs

The feature works best with GPT-4


---------

Co-authored-by: Roman Rizzi <[email protected]>
2023-05-20 17:45:54 +10:00
Rafael dos Santos Silva 262ed4753e FEATURE: Basic StableDiffusion text2img support (#72) 2023-05-20 09:38:08 +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
Rafael dos Santos Silva 739b314312 Fixes for embeddings and truncate (#67) 2023-05-18 09:21:28 +10:00
Roman Rizzi 9ae8f86850 UX: Improvements to the AI Bot header shortcut (#66)
- Humanize model names
- Focus composer editor when starting a PM with a bot
- Correctly close the models dropdown when clicking outside
2023-05-17 15:59:48 -03:00
Rafael dos Santos Silva e9ae28f773 FIX: Non instructor OSS embeddings was broken (#65) 2023-05-17 12:10:10 -03:00
Roman Rizzi 5ade5d7404 UX: Add missing label translation (#64) 2023-05-16 16:56:30 -03:00
Roman RizziandRafael dos Santos Silva 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 <[email protected]>

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

Co-authored-by: Rafael dos Santos Silva <[email protected]>

---------

Co-authored-by: Rafael dos Santos Silva <[email protected]>
2023-05-16 14:38:21 -03:00
Rafael dos Santos Silva 2ed1f874c2 Use correct API signature for instructor embeddings (#62) 2023-05-15 17:18:11 -03:00
Rafael dos Santos Silva 3c9513e754 Refinements to embeddings and tokenizers (#61)
* Refinements to embeddings and tokenizers

* lint

* Truncate with tokenizers for summary

* fix
2023-05-15 15:10:42 -03:00
Sam 93d9d9ea91 FEATURE: hide various api keys in site settings (#59)
Also... ensures that plugin has a link to more info and proper description
2023-05-12 12:54:25 +10:00
Rafael dos Santos Silva 97124b30de FEATURE: Update summarization token count and add Claude 100k (#58) 2023-05-11 15:35:58 -03:00
Rafael dos Santos Silva 66bf4c74c6 FEATURE: Handle invalid media in NSFW module (#57)
* FEATURE: Handle invalid media in NSFW module

* fix lint
2023-05-11 15:35:39 -03:00
Roman Rizzi 7e3cb0ea16 FEATURE: Multi-model support for the AI Bot module. (#56)
We'll create one bot user for each available model. When listed in the `ai_bot_enabled_chat_bots` setting, they will reply.

This PR lets us use Claude-v1 in stream mode.
2023-05-11 10:03:03 -03:00
Rafael dos Santos Silva e5537d4c77 FEATURE: Allow excluding closed topics from semantic related (#55) 2023-05-09 15:30:50 -03:00
Rafael dos Santos Silva f1133f66a6 Updates to embedding rake tasks (#54)
- Creates embeddings in topic ID order, so it's easier to stop and
restart from where we stopped

- Update index parameters with current best practices
2023-05-09 13:45:16 -03:00
Sam e76fc77189 fixes (#53)
* Minor... use username suggester in case username already exists

* FIX: ensure we truncate long prompts

Previously we

1. Used raw length instead of token counts for counting length
2. We totally dropped a prompt if it was too long

New implementation will truncate "raw" if it gets too long maintaining
meaning.
2023-05-06 07:31:53 -03:00
Roman Rizzi 71b105a1bb FEATURE: Introduce the ai-bot module (#52)
This module lets you chat with our GPT bot inside a PM. The bot only replies to members of the groups listed on the ai_bot_allowed_groups setting and only if you invite it to participate in the PM.
2023-05-05 15:28:31 -03:00
Rafael dos Santos Silva 29b22243de FIX: Toxicity automatic flagging should be disabled by default (#51) 2023-05-03 16:44:33 -03:00
Rafael dos Santos Silva c96edc8a72 FIX: Pass correct API Key to summarization service (#50) 2023-05-02 21:41:11 -03:00
Rafael dos Santos Silva 89ac5d720a FIX: Only send supported image types for classification (#49)
* FIX: Only send supported image types for classification
2023-04-27 17:52:20 -03:00
Sam 2cd60a4b3b FEATURE: add a table to audit OpenAI usage (#45)
Still need to build a job to purge logs
2023-04-26 11:44:29 +10:00
Jarek Radosz f6c30e8df9 DEV: Fix minor js issues (#48)
1. Add missing `pluginId` to `modifyClass` calls
2. Replace deprecated `site-settings:main` lookups with `service:site-settings`
3. Use "kebab-case" for initializer names
2023-04-25 13:19:57 +02:00
Joffrey JAFFEUX daacd2ffe3 FIX: chat-composer is now using glimmer (#47)
As a result of this change the channel is now accessible through `this.args.channel` and not `this.chatChannel`.

Longer term we want a better solution here, but this should fix the issue for now.
2023-04-25 11:25:07 +02:00
David Taylor a0542d1859 DEV: Resolve add_to_serializer deprecations (#46)
https://github.com/discourse/discourse/commit/26b7f8a63bfdb6505b605077a4beb962a9be7b97
2023-04-24 16:07:17 +01:00
Sam 057fbe1ce6 FEATURE: add internal support for streaming mode (#42)
Also adds some tests around completions and supports additional params
such as top_p, temperature and max_tokens

This also migrates off Faraday to using Net::HTTP directly
2023-04-21 16:54:25 +10:00
Meghna 14b21b4f4d UX: add a custom sparkles icon for AI action buttons (#44) 2023-04-20 20:41:24 +05:30
Roman RizziandRafael dos Santos Silva 38e007a3a5 FEATURE: Topic summarization (#41)
* FEATURE: Topic summarization

Summarize topics using the TopicView's "summary" filter. The UI is similar to what we do for chat, but we don't allow the user to select a timeframe.


Co-authored-by: Rafael dos Santos Silva <[email protected]>
2023-04-19 17:57:31 -03:00
Rafael dos Santos Silva 9783e3b025 FEATURE: Add a basic tokenizer API (#37)
* FEATURE: Add a basic tokenizer API

* Add tests

* lint
2023-04-19 11:55:59 -03:00
Rafael dos Santos Silva 5a78b6a953 DEV: Fix test (#43)
* DEV: Fix test

* lint
2023-04-18 15:43:10 -03:00
Rafael dos Santos Silva 4368ef29d8 FIX: Sometimes Claude sends all titles suggestions in a single ai tag (#40) 2023-04-10 16:02:44 -03:00
Rafael dos Santos Silva bb0b829634 FEATURE: Anthropic Claude for AIHelper and Summarization modules (#39) 2023-04-10 11:04:42 -03:00
Roman Rizzi f2e52f7f24 FIX: Check for chat channel permissions (#38) 2023-04-06 09:07:31 -03:00
Rafael dos Santos SilvaandRoman Rizzi 5549e4d5b3 FEATURE: Chat channel summarization. (#32)
* start summary module

* chat channel summarization

* FEATURE: modal for channel summarization

---------

Co-authored-by: Roman Rizzi <[email protected]>
2023-04-04 11:24:09 -03:00
Roman Rizzi 333cb8f212 FIX: Don't try to use pg headlines for semantic search. (#36)
Depends on discourse/discourse#20939.
2023-04-03 11:48:38 -03:00