AshAi.Actions.Prompt.Adapter.Helpers (ash_ai v0.2.6)
View SourceHelpers for processing LangChain.PromptTemplate
s in messages.
This module resolves templates with runtime data from the action's input and context before the prompt is sent to an LLM.
Example
Given a prompt with a template:
messages = [
Message.new_user!([
PromptTemplate.from_template!("Context: <%= @input.arguments.extra_info %>"),
ContentPart.text!("Analyze the following text.")
])
]
Adapters use add_messages_with_templates/3
to resolve such templates,
injecting variables from the action input and context.
Summary
Functions
Adds messages to a chain, applying prompt templates if any are present.
Builds template variables from adapter data, including input, context, and action arguments.
Checks if any messages contain PromptTemplate structs in their content.
Functions
Adds messages to a chain, applying prompt templates if any are present.
This function checks if any messages contain PromptTemplate structs and if so, uses LLMChain.apply_prompt_templates to resolve them with the provided template variables. Otherwise, it adds messages directly to the chain.
Builds template variables from adapter data, including input, context, and action arguments.
Checks if any messages contain PromptTemplate structs in their content.