raif 1.2.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -5
- data/app/assets/builds/raif.css +4 -1
- data/app/assets/builds/raif_admin.css +13 -1
- data/app/assets/javascript/raif/controllers/conversations_controller.js +1 -1
- data/app/assets/stylesheets/raif/admin/conversation.scss +16 -0
- data/app/assets/stylesheets/raif/conversations.scss +3 -0
- data/app/assets/stylesheets/raif.scss +2 -1
- data/app/controllers/raif/admin/application_controller.rb +16 -0
- data/app/controllers/raif/admin/configs_controller.rb +94 -0
- data/app/controllers/raif/admin/model_completions_controller.rb +18 -1
- data/app/controllers/raif/admin/model_tool_invocations_controller.rb +7 -1
- data/app/controllers/raif/admin/stats/model_tool_invocations_controller.rb +21 -0
- data/app/controllers/raif/admin/stats/tasks_controller.rb +15 -6
- data/app/controllers/raif/admin/stats_controller.rb +32 -3
- data/app/controllers/raif/conversation_entries_controller.rb +1 -0
- data/app/controllers/raif/conversations_controller.rb +10 -2
- data/app/jobs/raif/conversation_entry_job.rb +8 -6
- data/app/models/raif/admin/task_stat.rb +7 -0
- data/app/models/raif/agent.rb +63 -2
- data/app/models/raif/agents/native_tool_calling_agent.rb +101 -56
- data/app/models/raif/application_record.rb +18 -0
- data/app/models/raif/concerns/agent_inference_stats.rb +35 -0
- data/app/models/raif/concerns/has_llm.rb +1 -1
- data/app/models/raif/concerns/json_schema_definition.rb +40 -5
- data/app/models/raif/concerns/llms/anthropic/message_formatting.rb +28 -0
- data/app/models/raif/concerns/llms/anthropic/response_tool_calls.rb +24 -0
- data/app/models/raif/concerns/llms/anthropic/tool_formatting.rb +4 -0
- data/app/models/raif/concerns/llms/bedrock/message_formatting.rb +36 -0
- data/app/models/raif/concerns/llms/bedrock/response_tool_calls.rb +26 -0
- data/app/models/raif/concerns/llms/bedrock/tool_formatting.rb +4 -0
- data/app/models/raif/concerns/llms/google/message_formatting.rb +109 -0
- data/app/models/raif/concerns/llms/google/response_tool_calls.rb +32 -0
- data/app/models/raif/concerns/llms/google/tool_formatting.rb +72 -0
- data/app/models/raif/concerns/llms/message_formatting.rb +11 -5
- data/app/models/raif/concerns/llms/open_ai/json_schema_validation.rb +3 -3
- data/app/models/raif/concerns/llms/open_ai_completions/message_formatting.rb +22 -0
- data/app/models/raif/concerns/llms/open_ai_completions/response_tool_calls.rb +22 -0
- data/app/models/raif/concerns/llms/open_ai_completions/tool_formatting.rb +4 -0
- data/app/models/raif/concerns/llms/open_ai_responses/message_formatting.rb +17 -0
- data/app/models/raif/concerns/llms/open_ai_responses/response_tool_calls.rb +26 -0
- data/app/models/raif/concerns/llms/open_ai_responses/tool_formatting.rb +4 -0
- data/app/models/raif/concerns/run_with.rb +127 -0
- data/app/models/raif/conversation.rb +96 -9
- data/app/models/raif/conversation_entry.rb +37 -8
- data/app/models/raif/embedding_model.rb +2 -1
- data/app/models/raif/embedding_models/open_ai.rb +1 -1
- data/app/models/raif/llm.rb +28 -3
- data/app/models/raif/llms/anthropic.rb +7 -19
- data/app/models/raif/llms/bedrock.rb +6 -20
- data/app/models/raif/llms/google.rb +140 -0
- data/app/models/raif/llms/open_ai_base.rb +19 -5
- data/app/models/raif/llms/open_ai_completions.rb +6 -11
- data/app/models/raif/llms/open_ai_responses.rb +6 -16
- data/app/models/raif/llms/open_router.rb +10 -14
- data/app/models/raif/model_completion.rb +61 -0
- data/app/models/raif/model_tool.rb +10 -2
- data/app/models/raif/model_tool_invocation.rb +38 -6
- data/app/models/raif/model_tools/agent_final_answer.rb +2 -7
- data/app/models/raif/model_tools/provider_managed/code_execution.rb +4 -0
- data/app/models/raif/model_tools/provider_managed/image_generation.rb +4 -0
- data/app/models/raif/model_tools/provider_managed/web_search.rb +4 -0
- data/app/models/raif/streaming_responses/google.rb +71 -0
- data/app/models/raif/task.rb +74 -18
- data/app/models/raif/user_tool_invocation.rb +19 -0
- data/app/views/layouts/raif/admin.html.erb +12 -1
- data/app/views/raif/admin/agents/_agent.html.erb +8 -0
- data/app/views/raif/admin/agents/_conversation_message.html.erb +28 -6
- data/app/views/raif/admin/agents/index.html.erb +2 -0
- data/app/views/raif/admin/agents/show.html.erb +46 -1
- data/app/views/raif/admin/configs/show.html.erb +117 -0
- data/app/views/raif/admin/conversations/_conversation_entry.html.erb +29 -34
- data/app/views/raif/admin/conversations/show.html.erb +2 -0
- data/app/views/raif/admin/model_completions/_model_completion.html.erb +9 -0
- data/app/views/raif/admin/model_completions/index.html.erb +26 -0
- data/app/views/raif/admin/model_completions/show.html.erb +124 -61
- data/app/views/raif/admin/model_tool_invocations/index.html.erb +22 -1
- data/app/views/raif/admin/model_tools/_list.html.erb +16 -0
- data/app/views/raif/admin/model_tools/_model_tool.html.erb +36 -0
- data/app/views/raif/admin/stats/_stats_tile.html.erb +34 -0
- data/app/views/raif/admin/stats/index.html.erb +71 -88
- data/app/views/raif/admin/stats/model_tool_invocations/index.html.erb +43 -0
- data/app/views/raif/admin/stats/tasks/index.html.erb +20 -6
- data/app/views/raif/admin/tasks/index.html.erb +6 -1
- data/app/views/raif/admin/tasks/show.html.erb +36 -3
- data/app/views/raif/conversation_entries/_form.html.erb +4 -1
- data/app/views/raif/conversations/_conversation.html.erb +10 -0
- data/app/views/raif/conversations/_entry_processed.turbo_stream.erb +12 -0
- data/app/views/raif/conversations/_full_conversation.html.erb +3 -6
- data/app/views/raif/conversations/_initial_chat_message.html.erb +5 -0
- data/app/views/raif/conversations/index.html.erb +23 -0
- data/config/locales/admin.en.yml +33 -1
- data/config/locales/en.yml +41 -4
- data/config/routes.rb +2 -0
- data/db/migrate/20250804013843_add_task_run_args_to_raif_tasks.rb +13 -0
- data/db/migrate/20250811171150_make_raif_task_creator_optional.rb +8 -0
- data/db/migrate/20250904194456_add_generating_entry_response_to_raif_conversations.rb +7 -0
- data/db/migrate/20250911125234_add_source_to_raif_tasks.rb +7 -0
- data/db/migrate/20251020005853_add_source_to_raif_agents.rb +7 -0
- data/db/migrate/20251020011346_rename_task_run_args_to_run_with.rb +7 -0
- data/db/migrate/20251020011405_add_run_with_to_raif_agents.rb +13 -0
- data/db/migrate/20251024160119_add_llm_messages_max_length_to_raif_conversations.rb +14 -0
- data/db/migrate/20251124185033_add_provider_tool_call_id_to_raif_model_tool_invocations.rb +7 -0
- data/db/migrate/20251128202941_add_tool_choice_to_raif_model_completions.rb +7 -0
- data/db/migrate/20260118144846_add_source_to_raif_conversations.rb +7 -0
- data/db/migrate/20260119000000_add_failure_tracking_to_raif_model_completions.rb +10 -0
- data/db/migrate/20260119000001_add_completed_at_to_raif_model_completions.rb +8 -0
- data/db/migrate/20260119000002_add_started_at_to_raif_model_completions.rb +8 -0
- data/exe/raif +7 -0
- data/lib/generators/raif/agent/agent_generator.rb +22 -7
- data/lib/generators/raif/agent/templates/agent.rb.tt +20 -24
- data/lib/generators/raif/agent/templates/agent_eval_set.rb.tt +48 -0
- data/lib/generators/raif/agent/templates/application_agent.rb.tt +1 -3
- data/lib/generators/raif/base_generator.rb +19 -0
- data/lib/generators/raif/conversation/conversation_generator.rb +21 -2
- data/lib/generators/raif/conversation/templates/application_conversation.rb.tt +0 -2
- data/lib/generators/raif/conversation/templates/conversation.rb.tt +34 -32
- data/lib/generators/raif/conversation/templates/conversation_eval_set.rb.tt +70 -0
- data/lib/generators/raif/eval_set/eval_set_generator.rb +28 -0
- data/lib/generators/raif/eval_set/templates/eval_set.rb.tt +21 -0
- data/lib/generators/raif/evals/setup/setup_generator.rb +47 -0
- data/lib/generators/raif/install/install_generator.rb +15 -0
- data/lib/generators/raif/install/templates/initializer.rb +89 -10
- data/lib/generators/raif/model_tool/model_tool_generator.rb +5 -5
- data/lib/generators/raif/model_tool/templates/model_tool.rb.tt +78 -78
- data/lib/generators/raif/model_tool/templates/model_tool_invocation_partial.html.erb.tt +1 -1
- data/lib/generators/raif/task/task_generator.rb +22 -3
- data/lib/generators/raif/task/templates/application_task.rb.tt +0 -2
- data/lib/generators/raif/task/templates/task.rb.tt +55 -59
- data/lib/generators/raif/task/templates/task_eval_set.rb.tt +54 -0
- data/lib/raif/cli/base.rb +39 -0
- data/lib/raif/cli/evals.rb +47 -0
- data/lib/raif/cli/evals_setup.rb +27 -0
- data/lib/raif/cli.rb +67 -0
- data/lib/raif/configuration.rb +57 -8
- data/lib/raif/engine.rb +8 -0
- data/lib/raif/errors/instance_dependent_schema_error.rb +8 -0
- data/lib/raif/errors/streaming_error.rb +6 -3
- data/lib/raif/errors.rb +1 -0
- data/lib/raif/evals/eval.rb +30 -0
- data/lib/raif/evals/eval_set.rb +111 -0
- data/lib/raif/evals/eval_sets/expectations.rb +53 -0
- data/lib/raif/evals/eval_sets/llm_judge_expectations.rb +255 -0
- data/lib/raif/evals/expectation_result.rb +39 -0
- data/lib/raif/evals/llm_judge.rb +32 -0
- data/lib/raif/evals/llm_judges/binary.rb +94 -0
- data/lib/raif/evals/llm_judges/comparative.rb +89 -0
- data/lib/raif/evals/llm_judges/scored.rb +63 -0
- data/lib/raif/evals/llm_judges/summarization.rb +166 -0
- data/lib/raif/evals/run.rb +202 -0
- data/lib/raif/evals/scoring_rubric.rb +174 -0
- data/lib/raif/evals.rb +26 -0
- data/lib/raif/json_schema_builder.rb +14 -0
- data/lib/raif/llm_registry.rb +218 -15
- data/lib/raif/messages.rb +180 -0
- data/lib/raif/migration_checker.rb +3 -3
- data/lib/raif/utils/colors.rb +23 -0
- data/lib/raif/utils.rb +1 -0
- data/lib/raif/version.rb +1 -1
- data/lib/raif.rb +13 -0
- data/lib/tasks/annotate_rb.rake +10 -0
- data/spec/support/current_temperature_test_tool.rb +34 -0
- data/spec/support/rspec_helpers.rb +8 -8
- data/spec/support/test_conversation.rb +1 -1
- metadata +77 -10
- data/app/models/raif/agents/re_act_agent.rb +0 -127
- data/app/models/raif/agents/re_act_step.rb +0 -33
|
@@ -25,102 +25,85 @@
|
|
|
25
25
|
<div class="card-body">
|
|
26
26
|
<div class="row g-4">
|
|
27
27
|
<!-- Model Completions -->
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<div class="d-flex justify-content-between align-items-center">
|
|
42
|
-
<h3 class="fw-bold mb-0"><%= number_with_delimiter(@model_completion_count) %></h3>
|
|
43
|
-
<p class="text-muted mt-2 mb-0"><small><%= t("raif.admin.common.est_cost") %>: <%= number_to_currency(@model_completion_total_cost, precision: 6) %></small></p>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
28
|
+
<%= render "stats_tile",
|
|
29
|
+
icon_color: "primary",
|
|
30
|
+
title: t("raif.admin.common.model_completions"),
|
|
31
|
+
count: @model_completion_count,
|
|
32
|
+
show_costs: true,
|
|
33
|
+
input_cost: @model_completion_input_token_cost,
|
|
34
|
+
output_cost: @model_completion_output_token_cost,
|
|
35
|
+
total_cost: @model_completion_total_cost do %>
|
|
36
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-robot" viewBox="0 0 16 16">
|
|
37
|
+
<path d="M6 12.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5ZM3 8.062C3 6.76 4.235 5.765 5.53 5.886a26.58 26.58 0 0 0 4.94 0C11.765 5.765 13 6.76 13 8.062v1.157a.933.933 0 0 1-.765.935c-.845.147-2.34.346-4.235.346-1.895 0-3.39-.2-4.235-.346A.933.933 0 0 1 3 9.219V8.062Zm4.542-.827a.25.25 0 0 0-.217.068l-.92.9a24.767 24.767 0 0 1-1.871-.183.25.25 0 0 0-.068.495c.55.076 1.232.149 2.02.193a.25.25 0 0 0 .189-.071l.754-.736.847 1.71a.25.25 0 0 0 .404.062l.932-.97a25.286 25.286 0 0 0 1.922-.188.25.25 0 0 0-.068-.495c-.538.074-1.207.145-1.98.189a.25.25 0 0 0-.166.076l-.754.785-.842-1.7a.25.25 0 0 0-.182-.135Z" />
|
|
38
|
+
<path d="M8.5 1.866a1 1 0 1 0-1 0V3h-2A4.5 4.5 0 0 0 1 7.5V8a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1v1a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-1a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1v-.5A4.5 4.5 0 0 0 10.5 3h-2V1.866ZM14 7.5V13a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V7.5A3.5 3.5 0 0 1 5.5 4h5A3.5 3.5 0 0 1 14 7.5Z" />
|
|
39
|
+
</svg>
|
|
40
|
+
<% end %>
|
|
47
41
|
|
|
48
42
|
<!-- Tasks -->
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<h3 class="fw-bold mb-0"><%= number_with_delimiter(@task_count) %></h3>
|
|
63
|
-
<div class="mt-2">
|
|
64
|
-
<%= link_to raif.admin_stats_tasks_path(period: @selected_period) do %>
|
|
65
|
-
<%= t("raif.admin.common.details") %> »
|
|
66
|
-
<% end %>
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
</div>
|
|
43
|
+
<%= render "stats_tile",
|
|
44
|
+
icon_color: "success",
|
|
45
|
+
title: t("raif.admin.common.tasks"),
|
|
46
|
+
count: @task_count,
|
|
47
|
+
details_link: raif.admin_stats_tasks_path(period: @selected_period),
|
|
48
|
+
show_costs: true,
|
|
49
|
+
input_cost: @task_input_token_cost,
|
|
50
|
+
output_cost: @task_output_token_cost,
|
|
51
|
+
total_cost: @task_total_cost do %>
|
|
52
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-list-check" viewBox="0 0 16 16">
|
|
53
|
+
<path fill-rule="evenodd" d="M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM3.854 2.146a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 1 1 .708-.708L2 3.293l1.146-1.147a.5.5 0 0 1 .708 0zm0 4a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 1 1 .708-.708L2 7.293l1.146-1.147a.5.5 0 0 1 .708 0zm0 4a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 0 1 .708-.708l.146.147 1.146-1.147a.5.5 0 0 1 .708 0z" />
|
|
54
|
+
</svg>
|
|
55
|
+
<% end %>
|
|
71
56
|
|
|
72
57
|
<!-- Agents -->
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
<h3 class="fw-bold mb-0"><%= number_with_delimiter(@agent_count) %></h3>
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
58
|
+
<%= render "stats_tile",
|
|
59
|
+
icon_color: "danger",
|
|
60
|
+
title: t("raif.admin.common.agents"),
|
|
61
|
+
count: @agent_count,
|
|
62
|
+
show_costs: true,
|
|
63
|
+
input_cost: @agent_input_token_cost,
|
|
64
|
+
output_cost: @agent_output_token_cost,
|
|
65
|
+
total_cost: @agent_total_cost do %>
|
|
66
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-cpu" viewBox="0 0 16 16">
|
|
67
|
+
<path d="M5 0a.5.5 0 0 1 .5.5V2h1V.5a.5.5 0 0 1 1 0V2h1V.5a.5.5 0 0 1 1 0V2h1V.5a.5.5 0 0 1 1 0V2A2.5 2.5 0 0 1 14 4.5h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14a2.5 2.5 0 0 1-2.5 2.5v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14A2.5 2.5 0 0 1 2 11.5H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2A2.5 2.5 0 0 1 4.5 2V.5A.5.5 0 0 1 5 0zm-.5 3A1.5 1.5 0 0 0 3 4.5v7A1.5 1.5 0 0 0 4.5 13h7a1.5 1.5 0 0 0 1.5-1.5v-7A1.5 1.5 0 0 0 11.5 3h-7zM5 6.5A1.5 1.5 0 0 1 6.5 5h3A1.5 1.5 0 0 1 11 6.5v3A1.5 1.5 0 0 1 9.5 11h-3A1.5 1.5 0 0 1 5 9.5v-3zM6.5 6a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5h-3z" />
|
|
68
|
+
</svg>
|
|
69
|
+
<% end %>
|
|
88
70
|
|
|
89
71
|
<!-- Conversations -->
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
<div>
|
|
100
|
-
<h6 class="mb-0 text-muted"><%= t("raif.admin.common.conversations") %></h6>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
<h3 class="fw-bold mb-0"><%= number_with_delimiter(@conversation_count) %></h3>
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
72
|
+
<%= render "stats_tile",
|
|
73
|
+
icon_color: "info",
|
|
74
|
+
title: t("raif.admin.common.conversations"),
|
|
75
|
+
count: @conversation_count do %>
|
|
76
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-chat-dots" viewBox="0 0 16 16">
|
|
77
|
+
<path d="M5 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm4 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 1a1 1 0 1 0 0-2 1 1 0 0 0 0 2z" />
|
|
78
|
+
<path d="m2.165 15.803.02-.004c1.83-.363 2.948-.842 3.468-1.105A9.06 9.06 0 0 0 8 15c4.418 0 8-3.134 8-7s-3.582-7-8-7-8 3.134-8 7c0 1.76.743 3.37 1.97 4.6a10.437 10.437 0 0 1-.524 2.318l-.003.011a10.722 10.722 0 0 1-.244.637c-.079.186.074.394.273.362a21.673 21.673 0 0 0 .693-.125zm.8-3.108a1 1 0 0 0-.287-.801C1.618 10.83 1 9.468 1 8c0-3.192 3.004-6 7-6s7 2.808 7 6c0 3.193-3.004 6-7 6a8.06 8.06 0 0 1-2.088-.272a1 1 0 0 0-.711.074c-.387.196-1.24.57-2.634.893a10.97 10.97 0 0 0 .398-2z" />
|
|
79
|
+
</svg>
|
|
80
|
+
<% end %>
|
|
106
81
|
|
|
107
82
|
<!-- Conversation Entries -->
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
83
|
+
<%= render "stats_tile",
|
|
84
|
+
icon_color: "warning",
|
|
85
|
+
title: t("raif.admin.common.conversation_entries"),
|
|
86
|
+
count: @conversation_entry_count,
|
|
87
|
+
show_costs: true,
|
|
88
|
+
input_cost: @conversation_entry_input_token_cost,
|
|
89
|
+
output_cost: @conversation_entry_output_token_cost,
|
|
90
|
+
total_cost: @conversation_entry_total_cost do %>
|
|
91
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-chat-text" viewBox="0 0 16 16">
|
|
92
|
+
<path d="M2.678 11.894a1 1 0 0 1 .287.801 10.97 10.97 0 0 1-.398 2c1.395-.323 2.247-.697 2.634-.893a1 1 0 0 1 .71-.074A8.06 8.06 0 0 0 8 14c3.996 0 7-2.807 7-6 0-3.192-3.004-6-7-6S1 4.808 1 8c0 1.468.617 2.83 1.678 3.894zm-.493 3.905a21.682 21.682 0 0 1-.713.129c-.2.032-.352-.176-.273-.362a9.68 9.68 0 0 0 .244-.637l.003-.01c.248-.72.45-1.548.524-2.319C.743 11.37 0 9.76 0 8c0-3.866 3.582-7 8-7s8 3.134 8 7-3.582 7-8 7a9.06 9.06 0 0 1-2.347-.306c-.52.263-1.639.742-3.468 1.105z" />
|
|
93
|
+
<path d="M4 5.5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zM4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8zm0 2.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5z" />
|
|
94
|
+
</svg>
|
|
95
|
+
<% end %>
|
|
96
|
+
|
|
97
|
+
<!-- Model Tool Invocations -->
|
|
98
|
+
<%= render "stats_tile",
|
|
99
|
+
icon_color: "secondary",
|
|
100
|
+
title: t("raif.admin.common.model_tool_invocations"),
|
|
101
|
+
count: @model_tool_invocation_count,
|
|
102
|
+
details_link: raif.admin_stats_model_tool_invocations_path(period: @selected_period) do %>
|
|
103
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-tools" viewBox="0 0 16 16">
|
|
104
|
+
<path d="M1 0 0 1l2.2 3.081a1 1 0 0 0 .815.419h.07a1 1 0 0 1 .708.293l2.675 2.675-2.617 2.654A3.003 3.003 0 0 0 0 13a3 3 0 1 0 5.878-.851l2.654-2.617.968.968-.305.914a1 1 0 0 0 .242 1.023l3.27 3.27a.997.997 0 0 0 1.414 0l1.586-1.586a.997.997 0 0 0 0-1.414l-3.27-3.27a1 1 0 0 0-1.023-.242L10.5 9.5l-.96-.96 2.68-2.643A3.005 3.005 0 0 0 16 3c0-.269-.035-.53-.102-.777l-2.14 2.141L12 4l-.364-1.757L13.777.102a3 3 0 0 0-3.675 3.68L7.462 6.46 4.793 3.793a1 1 0 0 1-.293-.707v-.071a1 1 0 0 0-.419-.814L1 0Zm9.646 10.646a.5.5 0 0 1 .708 0l2.914 2.915a.5.5 0 0 1-.707.707l-2.915-2.914a.5.5 0 0 1 0-.708ZM3 11l.471.242.529.026.287.445.445.287.026.529L5 13l-.242.471-.026.529-.445.287-.287.445-.529.026L3 15l-.471-.242L2 14.732l-.287-.445L1.268 14l-.026-.529L1 13l.242-.471.026-.529.445-.287.287-.445.529-.026L3 11Z" />
|
|
105
|
+
</svg>
|
|
106
|
+
<% end %>
|
|
124
107
|
</div>
|
|
125
108
|
</div>
|
|
126
109
|
</div>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<%= link_to raif.admin_stats_path do %>
|
|
2
|
+
« <%= t("raif.admin.stats.model_tool_invocations.back_to_stats") %>
|
|
3
|
+
<% end %>
|
|
4
|
+
|
|
5
|
+
<div class="d-flex justify-content-between align-items-center my-4">
|
|
6
|
+
<h1 class="mb-0"><%= t("raif.admin.stats.model_tool_invocations.title") %></h1>
|
|
7
|
+
|
|
8
|
+
<div class="period-filter">
|
|
9
|
+
<%= form_tag raif.admin_stats_model_tool_invocations_path, method: :get, id: "period_filter_form", class: "d-flex align-items-center" do %>
|
|
10
|
+
<%= select_tag :period,
|
|
11
|
+
options_for_select(
|
|
12
|
+
[
|
|
13
|
+
[t("raif.admin.common.period_day"), "day"],
|
|
14
|
+
[t("raif.admin.common.period_week"), "week"],
|
|
15
|
+
[t("raif.admin.common.period_month"), "month"],
|
|
16
|
+
[t("raif.admin.common.period_all"), "all"]
|
|
17
|
+
],
|
|
18
|
+
@selected_period
|
|
19
|
+
),
|
|
20
|
+
class: "form-select form-select-sm me-2" %>
|
|
21
|
+
<%= submit_tag t("raif.admin.common.update"), class: "btn btn-sm btn-primary" %>
|
|
22
|
+
<% end %>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<div class="table-responsive">
|
|
27
|
+
<table class="table table-striped table-hover">
|
|
28
|
+
<thead class="table-light">
|
|
29
|
+
<tr>
|
|
30
|
+
<th><%= t("raif.admin.common.tool_type") %></th>
|
|
31
|
+
<th class="text-end"><%= t("raif.admin.common.count") %></th>
|
|
32
|
+
</tr>
|
|
33
|
+
</thead>
|
|
34
|
+
<tbody>
|
|
35
|
+
<% @model_tool_invocation_stats_by_type.each do |tool_type, count| %>
|
|
36
|
+
<tr>
|
|
37
|
+
<td><%= tool_type %></td>
|
|
38
|
+
<td class="text-end"><%= number_with_delimiter(count) %></td>
|
|
39
|
+
</tr>
|
|
40
|
+
<% end %>
|
|
41
|
+
</tbody>
|
|
42
|
+
</table>
|
|
43
|
+
</div>
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
<div class="period-filter">
|
|
9
9
|
<%= form_tag raif.admin_stats_tasks_path, method: :get, id: "period_filter_form", class: "d-flex align-items-center" do %>
|
|
10
|
+
<div class="form-check me-4 text-nowrap">
|
|
11
|
+
<%= check_box_tag :show_model_breakdown, "1", @show_model_breakdown, class: "form-check-input", id: "show_model_breakdown" %>
|
|
12
|
+
<%= label_tag :show_model_breakdown, t("raif.admin.stats.tasks.show_model_breakdown"), class: "form-check-label" %>
|
|
13
|
+
</div>
|
|
10
14
|
<%= select_tag :period,
|
|
11
15
|
options_for_select(
|
|
12
16
|
[
|
|
@@ -28,16 +32,26 @@
|
|
|
28
32
|
<thead class="table-light">
|
|
29
33
|
<tr>
|
|
30
34
|
<th><%= t("raif.admin.common.type") %></th>
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
<% if @show_model_breakdown %>
|
|
36
|
+
<th><%= t("raif.admin.common.model") %></th>
|
|
37
|
+
<% end %>
|
|
38
|
+
<th class="text-end"><%= t("raif.admin.common.count") %></th>
|
|
39
|
+
<th class="text-end"><%= t("raif.admin.common.input_token_cost") %></th>
|
|
40
|
+
<th class="text-end"><%= t("raif.admin.common.output_token_cost") %></th>
|
|
41
|
+
<th class="text-end"><%= t("raif.admin.common.total_cost") %></th>
|
|
33
42
|
</tr>
|
|
34
43
|
</thead>
|
|
35
44
|
<tbody>
|
|
36
|
-
<% @
|
|
45
|
+
<% @task_stats_by_type.each do |task_stat| %>
|
|
37
46
|
<tr>
|
|
38
|
-
<td><%= type %></td>
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
<td><%= task_stat.type %></td>
|
|
48
|
+
<% if @show_model_breakdown %>
|
|
49
|
+
<td><%= task_stat.llm_model_key %></td>
|
|
50
|
+
<% end %>
|
|
51
|
+
<td class="text-end"><%= number_with_delimiter(task_stat.count) %></td>
|
|
52
|
+
<td class="text-end"><%= number_to_currency(task_stat.input_cost, precision: 2) %></td>
|
|
53
|
+
<td class="text-end"><%= number_to_currency(task_stat.output_cost, precision: 2) %></td>
|
|
54
|
+
<td class="text-end"><%= number_to_currency(task_stat.total_cost, precision: 2) %></td>
|
|
41
55
|
</tr>
|
|
42
56
|
<% end %>
|
|
43
57
|
</tbody>
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<
|
|
1
|
+
<div class="d-flex justify-content-between align-items-center my-4">
|
|
2
|
+
<h1 class="mb-0"><%= t("raif.admin.common.tasks") %></h1>
|
|
3
|
+
<%= link_to raif.admin_stats_tasks_path, class: "btn btn-outline-primary" do %>
|
|
4
|
+
<%= t("raif.admin.common.stats") %> »
|
|
5
|
+
<% end %>
|
|
6
|
+
</div>
|
|
2
7
|
|
|
3
8
|
<div class="row">
|
|
4
9
|
<div class="col-12">
|
|
@@ -93,22 +93,55 @@
|
|
|
93
93
|
<div class="col-md-3"><strong><%= t("raif.admin.common.created_at") %>:</strong></div>
|
|
94
94
|
<div class="col-md-9"><%= @task.raif_model_completion.created_at.rfc822 %></div>
|
|
95
95
|
</div>
|
|
96
|
+
<div class="row mb-3">
|
|
97
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.retry_count") %>:</strong></div>
|
|
98
|
+
<div class="col-md-9"><%= @task.raif_model_completion.retry_count %></div>
|
|
99
|
+
</div>
|
|
96
100
|
<div class="row mb-3">
|
|
97
101
|
<div class="col-md-3"><strong><%= t("raif.admin.common.prompt_tokens") %>:</strong></div>
|
|
98
|
-
<div class="col-md-9"
|
|
102
|
+
<div class="col-md-9">
|
|
103
|
+
<% if @task.raif_model_completion.prompt_tokens %>
|
|
104
|
+
<%= number_with_delimiter(@task.raif_model_completion.prompt_tokens) %>
|
|
105
|
+
<% if @task.raif_model_completion.prompt_token_cost %>
|
|
106
|
+
<small>(<%= t("raif.admin.common.est_cost") %>: <%= "$" %><%= number_with_precision(@task.raif_model_completion.prompt_token_cost, precision: 6) %>)</small>
|
|
107
|
+
<% end %>
|
|
108
|
+
<% else %>
|
|
109
|
+
-
|
|
110
|
+
<% end %>
|
|
111
|
+
</div>
|
|
99
112
|
</div>
|
|
100
113
|
<div class="row mb-3">
|
|
101
114
|
<div class="col-md-3"><strong><%= t("raif.admin.common.completion_tokens") %>:</strong></div>
|
|
102
|
-
<div class="col-md-9"
|
|
115
|
+
<div class="col-md-9">
|
|
116
|
+
<% if @task.raif_model_completion.completion_tokens %>
|
|
117
|
+
<%= number_with_delimiter(@task.raif_model_completion.completion_tokens) %>
|
|
118
|
+
<% if @task.raif_model_completion.output_token_cost %>
|
|
119
|
+
<small>(<%= t("raif.admin.common.est_cost") %>: <%= "$" %><%= number_with_precision(@task.raif_model_completion.output_token_cost, precision: 6) %>)</small>
|
|
120
|
+
<% end %>
|
|
121
|
+
<% else %>
|
|
122
|
+
-
|
|
123
|
+
<% end %>
|
|
124
|
+
</div>
|
|
103
125
|
</div>
|
|
104
126
|
<div class="row mb-3">
|
|
105
127
|
<div class="col-md-3"><strong><%= t("raif.admin.common.total_tokens") %>:</strong></div>
|
|
106
|
-
<div class="col-md-9"
|
|
128
|
+
<div class="col-md-9">
|
|
129
|
+
<% if @task.raif_model_completion.total_tokens %>
|
|
130
|
+
<%= number_with_delimiter(@task.raif_model_completion.total_tokens) %>
|
|
131
|
+
<% if @task.raif_model_completion.total_cost %>
|
|
132
|
+
<small>(<%= t("raif.admin.common.est_cost") %>: <%= "$" %><%= number_with_precision(@task.raif_model_completion.total_cost, precision: 6) %>)</small>
|
|
133
|
+
<% end %>
|
|
134
|
+
<% else %>
|
|
135
|
+
-
|
|
136
|
+
<% end %>
|
|
137
|
+
</div>
|
|
107
138
|
</div>
|
|
108
139
|
</div>
|
|
109
140
|
</div>
|
|
110
141
|
<% end %>
|
|
111
142
|
|
|
143
|
+
<%= render "raif/admin/model_tools/list", model_tools: @task.available_model_tools_map %>
|
|
144
|
+
|
|
112
145
|
<div class="card mb-4">
|
|
113
146
|
<div class="card-header">
|
|
114
147
|
<h5 class="mb-0"><%= t("raif.admin.common.system_prompt") %></h5>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
<%# locals: (conversation:, conversation_entry:) %>
|
|
2
|
+
|
|
1
3
|
<%= form_with model: conversation_entry,
|
|
2
4
|
url: raif.conversation_entries_path(conversation),
|
|
5
|
+
id: dom_id(conversation, "entry_form"),
|
|
3
6
|
local: true do |f| %>
|
|
4
7
|
|
|
5
8
|
<% if conversation_entry.raif_user_tool_invocation %>
|
|
@@ -10,7 +13,7 @@
|
|
|
10
13
|
<% end %>
|
|
11
14
|
<% end %>
|
|
12
15
|
|
|
13
|
-
<div class="d-flex px-2">
|
|
16
|
+
<div class="d-flex px-2 align-items-center">
|
|
14
17
|
<%= f.text_field :user_message,
|
|
15
18
|
class: "form-control me-2",
|
|
16
19
|
placeholder: conversation_entry.raif_user_tool_invocation&.message_input_placeholder.presence || t("raif.common.type_your_message"),
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<%# locals: (conversation:) %>
|
|
2
|
+
|
|
3
|
+
<tr>
|
|
4
|
+
<td class="ps-2"><%= conversation.created_at.strftime("%B %d, %Y") %></td>
|
|
5
|
+
<td>
|
|
6
|
+
<%= link_to t("raif.conversations.index.table.view"),
|
|
7
|
+
raif.conversation_path(conversation),
|
|
8
|
+
class: "btn btn-sm btn-primary" %>
|
|
9
|
+
</td>
|
|
10
|
+
</tr>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<%# locals: (conversation:, conversation_entry:) %>
|
|
2
|
+
|
|
3
|
+
<%# Update the conversation entry now that it's been processed & has a model response %>
|
|
4
|
+
<%= turbo_stream.replace conversation_entry do %>
|
|
5
|
+
<%= render conversation_entry %>
|
|
6
|
+
<% end %>
|
|
7
|
+
|
|
8
|
+
<%= turbo_stream.replace dom_id(conversation, "entry_form") do %>
|
|
9
|
+
<%= render "raif/conversation_entries/form", conversation: conversation, conversation_entry: Raif::ConversationEntry.new %>
|
|
10
|
+
<% end %>
|
|
11
|
+
|
|
12
|
+
<%= turbo_stream.action :raif_scroll_to_bottom, ActionView::RecordIdentifier.dom_id(conversation, :entries) %>
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
<%= turbo_stream_from conversation %>
|
|
2
2
|
|
|
3
|
-
<div id="<%= dom_id(conversation, :entries) %>" class="flex-grow-1 overflow-auto" data-controller="raif--conversations">
|
|
4
|
-
<%= render
|
|
5
|
-
content: conversation.initial_chat_message,
|
|
6
|
-
message_type: :model_response %>
|
|
7
|
-
|
|
3
|
+
<div id="<%= dom_id(conversation, :entries) %>" class="flex-grow-1 overflow-auto raif-conversation-entries-container" data-controller="raif--conversations">
|
|
4
|
+
<%= render conversation.initial_chat_message_partial_path, conversation: conversation %>
|
|
8
5
|
<%= render conversation.entries.oldest_first %>
|
|
9
6
|
</div>
|
|
10
7
|
|
|
11
|
-
<div id="<%= dom_id(conversation, :entry_input) %>">
|
|
8
|
+
<div id="<%= dom_id(conversation, :entry_input) %>" class="raif-conversation-entry-input-container">
|
|
12
9
|
<%= render "raif/conversation_entries/form_with_available_tools",
|
|
13
10
|
conversation: conversation,
|
|
14
11
|
conversation_entry: Raif::ConversationEntry.new %>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<div class="conversation-history p-4">
|
|
2
|
+
<h2><%= t("raif.conversations.index.title") %></h2>
|
|
3
|
+
|
|
4
|
+
<% if @conversations.any? %>
|
|
5
|
+
<div class="table-responsive">
|
|
6
|
+
<table class="table table-striped">
|
|
7
|
+
<thead>
|
|
8
|
+
<tr>
|
|
9
|
+
<th><%= t("raif.conversations.index.table.started") %></th>
|
|
10
|
+
<th><%= t("raif.conversations.index.table.actions") %></th>
|
|
11
|
+
</tr>
|
|
12
|
+
</thead>
|
|
13
|
+
<tbody>
|
|
14
|
+
<%= render collection: @conversations, partial: "raif/conversations/conversation" %>
|
|
15
|
+
</tbody>
|
|
16
|
+
</table>
|
|
17
|
+
</div>
|
|
18
|
+
<% else %>
|
|
19
|
+
<div class="text-center py-4">
|
|
20
|
+
<p class="text-muted"><%= t("raif.conversations.index.no_conversations") %></p>
|
|
21
|
+
</div>
|
|
22
|
+
<% end %>
|
|
23
|
+
</div>
|
data/config/locales/admin.en.yml
CHANGED
|
@@ -10,28 +10,37 @@ en:
|
|
|
10
10
|
agents: Agents
|
|
11
11
|
all: All
|
|
12
12
|
arguments: Arguments
|
|
13
|
+
arguments_schema: Arguments Schema
|
|
13
14
|
at: at
|
|
15
|
+
available_tools: Available Tools
|
|
14
16
|
citations: Citations
|
|
15
17
|
completed: Completed
|
|
16
18
|
completed_at: Completed At
|
|
17
19
|
completion_tokens: Completion Tokens
|
|
20
|
+
config: Config
|
|
18
21
|
conversation_entries: Conversation Entries
|
|
19
22
|
conversation_history: Conversation History
|
|
20
23
|
conversations: Conversations
|
|
21
24
|
count: Count
|
|
22
25
|
created_at: Created At
|
|
23
26
|
creator: Creator
|
|
27
|
+
description: Description
|
|
24
28
|
details: Details
|
|
25
29
|
entries_count: Entries Count
|
|
26
30
|
entry: Entry
|
|
27
31
|
est_cost: est. cost
|
|
32
|
+
est_costs: est. costs
|
|
28
33
|
failed: Failed
|
|
29
34
|
failed_at: Failed At
|
|
35
|
+
failure_error: Failure Error
|
|
36
|
+
failure_reason: Failure Reason
|
|
30
37
|
filter: Filter
|
|
31
38
|
final_answer: Final Answer
|
|
32
39
|
id: ID
|
|
33
40
|
in_progress: In Progress
|
|
34
41
|
initial_task: Initial Task
|
|
42
|
+
input: Input
|
|
43
|
+
input_token_cost: Input Token Cost
|
|
35
44
|
invalid_json: Invalid JSON
|
|
36
45
|
iterations: Iterations
|
|
37
46
|
language: Language
|
|
@@ -48,6 +57,9 @@ en:
|
|
|
48
57
|
no_model_tool_invocations: No model tool invocations found.
|
|
49
58
|
no_tasks: No tasks found.
|
|
50
59
|
no_tool_calls: No tool calls
|
|
60
|
+
none: None
|
|
61
|
+
output: Output
|
|
62
|
+
output_token_cost: Output Token Cost
|
|
51
63
|
pending: Pending
|
|
52
64
|
period_all: All time
|
|
53
65
|
period_day: Past 24 hours
|
|
@@ -61,8 +73,8 @@ en:
|
|
|
61
73
|
requested_language: Requested Language
|
|
62
74
|
response: Response
|
|
63
75
|
response_format: Response Format
|
|
64
|
-
response_format_parameter: Response Format Parameter
|
|
65
76
|
result: Result
|
|
77
|
+
retry_count: Retry Count
|
|
66
78
|
running: Running
|
|
67
79
|
since: Since
|
|
68
80
|
source: Source
|
|
@@ -73,15 +85,31 @@ en:
|
|
|
73
85
|
task: Task
|
|
74
86
|
tasks: Tasks
|
|
75
87
|
tool_arguments: Tool Arguments
|
|
88
|
+
tool_call: Tool Call
|
|
76
89
|
tool_calls: Tool Calls
|
|
77
90
|
tool_invocations: Tool Invocations
|
|
78
91
|
tool_name: Tool Name
|
|
92
|
+
tool_result: Tool Result
|
|
79
93
|
tool_type: Tool Type
|
|
94
|
+
total: Total
|
|
80
95
|
total_cost: Total Cost
|
|
81
96
|
total_tokens: Total Tokens
|
|
82
97
|
type: Type
|
|
83
98
|
update: Update
|
|
84
99
|
user_message: User Message
|
|
100
|
+
config:
|
|
101
|
+
show:
|
|
102
|
+
configuration_settings: Configuration Settings
|
|
103
|
+
default: default
|
|
104
|
+
key: Key
|
|
105
|
+
no_embedding_models_registered: No embedding models registered
|
|
106
|
+
no_llms_registered: No LLMs registered
|
|
107
|
+
not_set: Not set
|
|
108
|
+
registered_embedding_models: Registered Embedding Models
|
|
109
|
+
registered_llms: Registered LLMs
|
|
110
|
+
setting: Setting
|
|
111
|
+
title: Raif Configuration
|
|
112
|
+
value: Value
|
|
85
113
|
conversations:
|
|
86
114
|
show:
|
|
87
115
|
back_to_conversations: Back to Conversations
|
|
@@ -98,8 +126,12 @@ en:
|
|
|
98
126
|
back_to_model_tool_invocations: Back to Model Tool Invocations
|
|
99
127
|
title: 'Model Tool Invocation #%{id}'
|
|
100
128
|
stats:
|
|
129
|
+
model_tool_invocations:
|
|
130
|
+
back_to_stats: Back to Stats
|
|
131
|
+
title: Model Tool Invocation Stats
|
|
101
132
|
tasks:
|
|
102
133
|
back_to_stats: Back to Stats
|
|
134
|
+
show_model_breakdown: Show model breakdown
|
|
103
135
|
title: Task Stats
|
|
104
136
|
tasks:
|
|
105
137
|
show:
|