Commit Graph

15 Commits

Author SHA1 Message Date
Roman Rizzi e0bf6adb5b
DEV: Tool support for the LLM service. (#366)
This PR adds tool support to available LLMs. We'll buffer tool invocations and return them instead of making users of this service parse the response.

It also adds support for conversation context in the generic prompt. It includes bot messages, user messages, and tool invocations, which we'll trim to make sure it doesn't exceed the prompt limit, then translate them to the correct dialect.

Finally, It adds some buffering when reading chunks to handle cases when streaming is extremely slow.:M
2023-12-18 18:06:01 -03:00
Roman Rizzi 203906be65
FIX: Bedrock was complaining input was too long (#365) 2023-12-18 16:06:06 -03:00
Rafael dos Santos Silva 83744bf192
FEATURE: Support for Gemini in AiHelper / Search / Summarization (#358) 2023-12-15 14:32:01 -03:00
Roman Rizzi 031c2a6b46
Revert "FIX: Recover from Bedrock returning invalid base64 payloads during streaming (#352)" (#353)
This reverts commit ef7d4cc509.
2023-12-12 17:22:44 -03:00
Roman Rizzi ef7d4cc509
FIX: Recover from Bedrock returning invalid base64 payloads during streaming (#352) 2023-12-12 17:06:53 -03:00
Roman Rizzi 2798e4c86d
FIX: Custom instructions where missing when generating custom prompt input (#348) 2023-12-11 19:26:56 -03:00
Rafael dos Santos Silva 252efdf142
FIX: Don't echo prompt back on HF/TGI (#338)
* FIX: Don't echo prompt back on HF/TGI

* teeeeests
2023-12-06 16:06:26 -03:00
Rafael dos Santos Silva d8267d8da0
FIX: Many fixes for huggingface and llama2 inference (#335) 2023-12-06 11:22:42 -03:00
Sam 6ddc17fd61
DEV: port directory structure to Zeitwerk (#319)
Previous to this change we relied on explicit loading for a files in Discourse AI.

This had a few downsides:

- Busywork whenever you add a file (an extra require relative)
- We were not keeping to conventions internally ... some places were OpenAI others are OpenAi
- Autoloader did not work which lead to lots of full application broken reloads when developing.

This moves all of DiscourseAI into a Zeitwerk compatible structure.

It also leaves some minimal amount of manual loading (automation - which is loading into an existing namespace that may or may not be there)

To avoid needing /lib/discourse_ai/... we mount a namespace thus we are able to keep /lib pointed at ::DiscourseAi

Various files were renamed to get around zeitwerk rules and minimize usage of custom inflections

Though we can get custom inflections to work it is not worth it, will require a Discourse core patch which means we create a hard dependency.
2023-11-29 15:17:46 +11:00
Roman Rizzi f26adf2cf6
FIX: Use XML tags in generate_titles prompt. (#322)
We must ensure we can isolate titles, and the models sometimes ignore the example we give them.

Additionally, anons can generate HyDE posts, so we need to check if user is nil when attempting to log requests.
2023-11-28 12:52:22 -03:00
Roman Rizzi 2e7c5f047d
DEV: Don't attempt to update log if completion request fails. (#321)
We already log the request failure when we raise the exception.
2023-11-28 11:15:12 -03:00
Roman Rizzi 419c43592a
FIX: Make summaries more cohesive by tweaking prompt. (#310)
Other changes:

- Don't use Bedrock for non claude models if credentials are set.
- Remove extra sentence from HyDE prompt.
2023-11-23 16:33:37 -03:00
Roman Rizzi 02efca162e
FIX: Bedrock uses slightly different model names
* Revert "FIX: We don't need to prepend anthropic. to bedrock models (#308)"

This reverts commit 8a01751991.

* FIX: Bedrock uses slightly different model names
2023-11-23 15:49:24 -03:00
Roman Rizzi 8a01751991
FIX: We don't need to prepend anthropic. to bedrock models (#308) 2023-11-23 14:39:21 -03:00
Roman Rizzi 3064d4c288
REFACTOR: Summarization and HyDE now use an LLM abstraction. (#297)
* DEV: One LLM abstraction to rule them all

* REFACTOR: HyDE search uses new LLM abstraction

* REFACTOR: Summarization uses the LLM abstraction

* Updated documentation and made small fixes. Remove Bedrock claude-2 restriction
2023-11-23 12:58:54 -03:00