26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/models/ruby_llm/evals/prompt.rb', line 26
def execute(variables: {}, files: [])
chat = RubyLLM.chat(model: model, provider: provider)
chat.with_instructions Liquid::Template.parse(instructions).render(variables) if instructions.present?
chat.with_temperature(temperature) if temperature.present?
chat.with_params(**params) if params.present?
if tools.present?
tool_classes = tools.map { _1.constantize rescue nil }.compact
chat.with_tools(*tool_classes)
end
if schema_other.present?
chat.with_schema(**schema_other)
elsif schema.present?
chat.with_schema schema.constantize
end
chat.ask Liquid::Template.parse(message).render(variables), with: files
end
|