Module: RubyLLM::Evals::ApplicationHelper
- Defined in:
- app/helpers/ruby_llm/evals/application_helper.rb
Instance Method Summary collapse
- #accuracy(obj) ⇒ Object
- #duration(obj) ⇒ Object
- #expected_output(obj) ⇒ Object
- #json(hash) ⇒ Object
- #status_indicator(prompt_execution) ⇒ Object
Instance Method Details
#accuracy(obj) ⇒ Object
4 5 6 |
# File 'app/helpers/ruby_llm/evals/application_helper.rb', line 4 def accuracy(obj) obj.finished? ? "#{obj.accuracy}%" : "N/A" end |
#duration(obj) ⇒ Object
8 9 10 11 12 |
# File 'app/helpers/ruby_llm/evals/application_helper.rb', line 8 def duration(obj) return "N/A" unless obj.finished? distance_of_time_in_words obj.started_at, obj.ended_at, include_seconds: true end |
#expected_output(obj) ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/helpers/ruby_llm/evals/application_helper.rb', line 14 def expected_output(obj) if obj.regex? content_tag :code, "/#{obj.expected_output}/i" else obj.expected_output end end |
#json(hash) ⇒ Object
22 23 24 25 26 |
# File 'app/helpers/ruby_llm/evals/application_helper.rb', line 22 def json(hash) if hash.present? content_tag :pre, JSON.pretty_generate(hash) end end |
#status_indicator(prompt_execution) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/ruby_llm/evals/application_helper.rb', line 28 def status_indicator(prompt_execution) if prompt_execution.passed.nil? content_tag :span, "⏳", title: "Pending or in progress" elsif prompt_execution.passed? content_tag :span, "🟢", title: "Passed" else content_tag :span, "🔴", title: "Failed" end end |