Expand description
Flexible library developed for creating and managing coherent narratives which leverage LLMs (Large Language Models) to generate dynamic responses.
Built based on OpenAI’s recommended tactics, LLM Weaver facilitates extended interactions with any LLM, seamlessly handling conversations that exceed a model’s maximum context token limitation.
[Loom] is the core of this library. It prompts the configured LLM and stores the message
history as TapestryFragment instances. This trait is highly configurable through the
Config trait to support a wide range of use cases.
§Nomenclature
- Tapestry: A collection of
TapestryFragmentinstances. - TapestryFragment: A single part of a conversation containing a list of messages along with other metadata.
- ContextMessage: Represents a single message in a
TapestryFragmentinstance. - Loom: The machine that drives all of the core methods that should be used across any service that needs to prompt LLM and receive a response.
- LLM: Language Model.
§Architecture
Please refer to the architecture::Diagram for a visual representation of the core
components of this library.
§Usage
You must implement the Config trait, which defines the necessary types and methods needed by
[Loom].
This library uses Redis as the default storage backend for storing TapestryFragment. It is
expected that a Redis instance is running and that the following environment variables are set:
REDIS_PROTOCOLREDIS_HOSTREDIS_PORTREDIS_PASSWORD
Should there be a need to integrate a distinct storage backend, you have the flexibility to
create a custom handler by implementing the TapestryChestHandler trait and injecting it
into the Config::Chest associated type.
Re-exports§
pub use storage::TapestryChestHandler;
Modules§
Structs§
- Bounded
U8 - An
u8constrained to be in the rangeMIN..=MAX. - Context
Message - Context message that represent a single message in a
TapestryFragmentinstance. - LlmConfig
- Tapestry
Fragment - Represents a single part of a conversation containing a list of messages along with other metadata.
Traits§
- Config
- A trait consisting of the main configuration needed to implement [
Loom]. - Llm
- Tapestry
Id - Represents a unique identifier for any arbitrary entity.