Commit Graph

238 Commits

Author SHA1 Message Date
Sam Saffron 13fca098d1
tweaks to open llm implementation
testing mistral at the moment and did the minimum to get it going
2023-10-04 17:20:46 +11:00
Sam Saffron d76309fa17
tweaks to llama2 support in chat, fix message so it conforms to recommendation
by facebook (add <s> )
2023-10-04 16:27:00 +11:00
Sam Saffron facce51f98
FEATURE: add support for an open LLM implementation
This is very much a work in progress, testing at the moment on:

TheBloke/Llama-2-7B-chat-fp16
2023-10-04 16:25:44 +11:00
Rafael dos Santos Silva 4df258ce7d
FIX: Follow fix for missing claude tags in a7adce0 (#242) 2023-10-03 19:56:29 -03:00
Rafael dos Santos Silva a7adce0cf7
FIX: Fallback to whole response when Claude forgets tags (#240) 2023-10-03 15:39:30 -03:00
Sam 0cbf14e343
FEATURE: automation rule for triaging posts using LLM (#236)
The new automation rule can be used to perform llm based classification and categorization of topics. 

You specify a system prompt (which has %%POST%% as an input), if it returns a particular piece of text then we will apply rules such as tagging, hiding, replying or categorizing.

This can be used as a spam filter, a "oops you are in the wrong place" filter and so on. 

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2023-10-03 08:55:30 +11:00
Rafael dos Santos Silva 453928e7bb
FIX: Improvment to embeddings index task (#238) 2023-10-02 16:37:13 -03:00
Rafael dos Santos Silva 9d96c4d242
FIX: Suggest category/tag was broken since 2e5a393 (#237) 2023-10-02 16:36:56 -03:00
Rafael dos Santos Silva 102f47c1c4
FEATURE: Allow Anthropic inference via AWS Bedrock (#235)
If a module LLM model is set to claude-2 and the ai_bedrock variables are all present we will use AWS Bedrock instead of Antrhopic own APIs.

This is quite hacky, but will allow us to test the waters with AWS Bedrock early access with every module.

This situation of "same module, completely different API" is quite a bit far from what we had in the OpenAI/Azure separation, so it's more food for thought for when we start working on the LLM abstraction layer soon this year.
2023-10-02 12:58:36 -03:00
Sam ed7d1f06d1
FIX: improve token counting (#234)
We were running out of tokens under certain conditions (really long
chains)

Add more buffer.
2023-09-28 15:32:22 +10:00
Keegan George 237e9478df
UX: Use disable/enable state for custom prompt button (#233) 2023-09-27 14:27:16 -07:00
Keegan George 0c50d7d553
DEV: Improvements to context menu (#232) 2023-09-27 11:39:51 -07:00
Discourse Translator Bot 782600e64f
Update translations (#229) 2023-09-27 11:03:11 +02:00
Sam aa463d64f1
FEATURE: Add creative persona (#231)
This adds a new creative persona that has access to the underlying
model and no external integrations.

It allows people to use Claude/GPT models in a Discourse agnostic
way.
2023-09-27 10:48:38 +10:00
Rafael dos Santos Silva 525be42aa5
FIX: AIHelper custom prompts with OpenAI had wrong type (#230) 2023-09-25 17:26:00 -03:00
Keegan George 2e5a39360a
FEATURE: Create custom prompts with composer AI helper (#214)
* DEV: Add icon support

* DEV: Add basic setup for custom prompt menu

* FEATURE: custom prompt backend

* fix custom prompt param check

* fix custom prompt replace

* WIP

* fix custom prompt usage

* fixes

* DEV: Update front-end

* DEV: No more custom prompt state

* DEV: Add specs

* FIX: Title/Category/Tag suggestions

Suggestion dropdowns broke because it `messages_with_user_input(user_input)` expects a hash now.

* DEV: Apply syntax tree

* DEV: Restrict custom prompts to configured groups

* oops

* fix tests

* lint

* I love tests

* lint is cool tho

---------

Co-authored-by: Rafael dos Santos Silva <xfalcox@gmail.com>
2023-09-25 15:12:54 -03:00
Sam 316ea9624e
FIX: properly truncate !command prompts (#227)
* FIX: properly truncate !command prompts

### What is going on here?

Previous to this change where a command was issued by the LLM it
could hallucinate a continuation eg:

```
This is what tags are

!tags

some nonsense here
```

This change introduces safeguards so `some nonsense here` does not
creep in to the prompt history, poisoning the llm results

This in effect grounds the llm a lot better and results in the llm
forgetting less about results.

The change only impacts Claude at the moment, but will also improve
stuff for llama 2 in future.

Also, this makes it significantly easier to test the bot framework
without an llm cause we avoid a whole bunch of complex stubbing

* blank is not a valid bot response, do not inject into prompt
2023-09-15 07:02:37 +10:00
Roman Rizzi f57c1bb0f6
FEATURE: AI Helper endpoint to generate a thumbnail from text. (#224)
We pass the text to the current LLM and ask them to generate a StableDifussion prompt.
We'll use that to generate 4 samples, temporarily creating uploads and returning their short URLs.
2023-09-14 12:53:44 -03:00
Jarek Radosz 1eb70c4f0a
DEV: Fix rspec-expectations warnings (#228) 2023-09-14 17:50:13 +02:00
Sam 9e94457154
FIX: Made bot more robust (#226)
* FIX: Made bot more robust

This is a collection of small fixes

- Display "Searching for: ..." while searching instead of showing found 0 results.
- Only allow 5 commands in lang chain - 6 feels like too much
- On the 5th command stop informing the engine about functions, so it is forced to complete
- Add another 30 tokens of buffer and explain why
- Typo in command prompt


Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
2023-09-14 16:46:56 +10:00
Keegan George d35c8d5eca
FIX: Conditionally render AI suggestion buttons (#225) 2023-09-13 14:18:48 -07:00
Keegan George cf6a6ed9b8
FIX: AI Helper UX bugs (#223) 2023-09-13 09:53:19 -07:00
Sam cdd6faa648
FEATURE: add filter support to ai bot semantic search (#222)
Previously we would bypass semantic search if any filters were
present

Also shows progress now.
2023-09-13 14:59:45 +10:00
Rafael dos Santos Silva d1642533fb
FIX: Use "Related Topics" label consistently (#221) 2023-09-12 16:23:24 -03:00
Rafael dos Santos Silva 2c87bb0d99
FEATURE: Respect search filters in semantic search (#220)
* FEATURE: Respect search filters in semantic search

* lint
2023-09-12 16:16:33 -03:00
Roman Rizzi 50d7289623
FIX: Trigger initial semantic search. (#219)
I thought this wasn't neccessary and we could safely rely on the appEvent during the initial search.
It only fires if #searchEnabled is true, meaning the search term is valid.
2023-09-12 10:28:07 -03:00
Discourse Translator Bot 0d761f4305
Update translations (#218) 2023-09-12 15:27:58 +02:00
Sam d75e3ca82b
FEATURE: include tag and category context in search (#217)
Previous to this we just included title/body.. tags and category
structure can be very critical for decision making.
2023-09-12 16:09:28 +10:00
Sam b0310f90d3
FEATURE: add tags and categories to read context (#215)
Note, we perform permission checks on tag list against anon
to ensure we do not disclose information about private tags
to the llm which could get extracted.
2023-09-12 11:06:55 +10:00
Roman Rizzi 156931e1f4
FIX: Perform semantic search only when searchTerm is valid (#216) 2023-09-11 11:32:05 -03:00
Keegan George 6295b16678
FEATURE: Add cancel button to loading context menu (#213) 2023-09-07 13:50:56 -07:00
Keegan George 087be9f4da
UX: Prevent input text from covering suggestion button (#212) 2023-09-07 11:52:00 -07:00
Roman Rizzi 0828254d61
FIX: Generate embeddings job was broken (#211)
* FIX: Use correct methods to generate embeddings

* FIX: Generate embeddings job was broken
2023-09-07 11:54:43 -03:00
Sam 615eb8b440
FEATURE: add semantic search with hyde bot (#210)
In specific scenarios (no special filters or limits) we will also
always include 5 semantic results (at least) with every query.

This effectively means that all very wide queries will always return
20 results, regardless of how complex they are.

Also: 

FIX: embedding backfill rake task not working
We renamed internals, this corrects the implementation
2023-09-07 13:25:26 +10:00
Keegan George abe96d5533
DEV: Strip out old modal based AI helper (#209) 2023-09-06 13:28:47 -07:00
Keegan George 0733ff7e67
UX: Show suggestion buttons only if sufficient content is present (#204) 2023-09-06 12:20:08 -07:00
Keegan George 8d674c451a
FIX: Flaky spec in AI Helper modal (#208) 2023-09-06 10:15:11 -07:00
Keegan George aa08f2d2a0
FIX: Flaky Spec (#207) 2023-09-06 09:46:03 -07:00
Rafael dos Santos Silva 5c50d2aa09
FEATURE: Use stop_sequences for faster HyDE searches with Claude (#203) 2023-09-06 10:06:31 -03:00
Roman Rizzi 13d63f1f30
FIX: filter allowed categories from semantic search results (#206) 2023-09-06 10:00:20 -03:00
Alan Guo Xiang Tan 920d4d8c0c
DEV: Skip broken test on CI (#205) 2023-09-06 09:33:43 +08:00
Roman Rizzi 4d854e9232
FIX: Invalidate semantic search cache entries when hyde or embedding model changes (#202) 2023-09-05 18:39:39 -03:00
Keegan George 3a00c38fc5
UX: Change AI Helper toggle icon to sparkles (#201) 2023-09-05 13:21:05 -07:00
Rafael dos Santos Silva 4b42c09814
FEATURE: Tweak HyDE prompts for better grounding in forum subject and limit response size (#200)
* FEATURE: Tweak HyDE prompts for better grounding in forum subject and limit response size

* fix test

* lint
2023-09-05 16:11:07 -03:00
Roman Rizzi 175def1267
FIX: Update migrations with latest vector rep changes (#199) 2023-09-05 14:31:04 -03:00
Rafael dos Santos Silva ee734a340a
FIX: Tag/category suggestion broke in 2c0f535 (#198) 2023-09-05 14:15:01 -03:00
Keegan George ae0238c616
FIX: Flaky spec (#197) 2023-09-05 09:56:12 -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
Discourse Translator Bot 3d83d062a1
Update translations (#186) 2023-09-05 15:42:46 +02:00
Sam 38af2ca63e
FIX: cut completion short after function call is found (#182)
Previous to this change we would keep completing and throw away
result
2023-09-05 10:37:58 +10:00