fix: captain liquid render file system (#13647)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 -%}
|
||||
|
||||
@@ -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 -%}
|
||||
|
||||
Reference in New Issue
Block a user