pub struct Loom<T: Config> {
pub chest: T::Chest,
/* private fields */
}
Expand description
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.
This is implemented over the Config
trait.
Fields§
§chest: T::Chest
Implementations§
Source§impl<T: Config> Loom<T>
impl<T: Config> Loom<T>
Sourcepub async fn weave<TID: TapestryId>(
&self,
prompt_llm_config: LlmConfig<T, T::PromptModel>,
summary_llm_config: LlmConfig<T, T::SummaryModel>,
tapestry_id: TID,
instructions: String,
msgs: Vec<ContextMessage<T>>,
) -> Result<(<<T as Config>::PromptModel as Llm<T>>::Response, u64, bool), Box<dyn Error + Send + Sync>>
pub async fn weave<TID: TapestryId>( &self, prompt_llm_config: LlmConfig<T, T::PromptModel>, summary_llm_config: LlmConfig<T, T::SummaryModel>, tapestry_id: TID, instructions: String, msgs: Vec<ContextMessage<T>>, ) -> Result<(<<T as Config>::PromptModel as Llm<T>>::Response, u64, bool), Box<dyn Error + Send + Sync>>
Prompt LLM Weaver for a response for TapestryId
.
Prompts LLM with the current TapestryFragment
instance and the new msgs
.
A summary will be generated of the current TapestryFragment
instance if the total number
of tokens in the context_messages
exceeds the maximum number of tokens allowed for the
current Config::PromptModel
or custom max tokens. This threshold is affected by the
Config::TOKEN_THRESHOLD_PERCENTILE
.
§Parameters
prompt_llm_config
: TheConfig::PromptModel
to use for prompting LLM.summary_llm_config
: TheConfig::SummaryModel
to use for generating summaries.tapestry_id
: TheTapestryId
to use for storing theTapestryFragment
instance.instructions
: The instruction message to be used for the currentTapestryFragment
instance.msgs
: The messages to prompt the LLM with.
Sourcepub fn build_context_message(
role: WrapperRole,
content: String,
account_id: Option<String>,
) -> ContextMessage<T>
pub fn build_context_message( role: WrapperRole, content: String, account_id: Option<String>, ) -> ContextMessage<T>
Helper method to build a ContextMessage
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Loom<T>
impl<T> RefUnwindSafe for Loom<T>
impl<T> Send for Loom<T>
impl<T> Sync for Loom<T>
impl<T> Unpin for Loom<T>
impl<T> UnwindSafe for Loom<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more