fix: captain liquid render file system (#13647)

This commit is contained in:
Aakash Bakhle
2026-02-25 20:19:34 +05:30
committed by GitHub
parent 5aef9d2dd0
commit efe49f7da4
4 changed files with 43 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ class Captain::PromptRenderer
def render(template_name, context = {})
template = load_template(template_name)
liquid_template = Liquid::Template.parse(template)
liquid_template.render(stringify_keys(context))
liquid_template.render(stringify_keys(context), registers: { file_system: snippet_file_system })
end
private
@@ -18,6 +18,13 @@ class Captain::PromptRenderer
File.read(template_path)
end
def snippet_file_system
@snippet_file_system ||= Liquid::LocalFileSystem.new(
Rails.root.join('enterprise/lib/captain/prompts/snippets'),
'%s.liquid'
)
end
def stringify_keys(hash)
hash.deep_stringify_keys
end

View File

@@ -14,11 +14,11 @@ Don't digress away from your instructions, and use all the available tools at yo
Here's the metadata we have about the current conversation and the contact associated with it:
{% if conversation -%}
{% render 'conversation' %}
{% render 'conversation', conversation: conversation %}
{% endif -%}
{% if contact -%}
{% render 'contact' %}
{% render 'contact', contact: contact %}
{% endif -%}
{% if campaign.id -%}

View File

@@ -14,11 +14,11 @@ If you believe the user's request is not within the scope of your role, you can
Here's the metadata we have about the current conversation and the contact associated with it:
{% if conversation -%}
{% render 'conversation' %}
{% render 'conversation', conversation: conversation %}
{% endif -%}
{% if contact -%}
{% render 'contact' %}
{% render 'contact', contact: contact %}
{% endif -%}
{% if campaign.id -%}