raif 1.0.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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +678 -0
- data/Rakefile +20 -0
- data/app/assets/builds/raif.css +74 -0
- data/app/assets/builds/raif_admin.css +266 -0
- data/app/assets/config/raif_manifest.js +1 -0
- data/app/assets/javascript/raif/controllers/conversations_controller.js +11 -0
- data/app/assets/javascript/raif/stream_actions/raif_scroll_to_bottom.js +12 -0
- data/app/assets/javascript/raif.js +10 -0
- data/app/assets/stylesheets/raif/admin/conversation.scss +64 -0
- data/app/assets/stylesheets/raif/loader.scss +85 -0
- data/app/assets/stylesheets/raif.scss +1 -0
- data/app/assets/stylesheets/raif_admin.scss +299 -0
- data/app/controllers/raif/admin/agents_controller.rb +17 -0
- data/app/controllers/raif/admin/application_controller.rb +20 -0
- data/app/controllers/raif/admin/conversations_controller.rb +17 -0
- data/app/controllers/raif/admin/model_completions_controller.rb +17 -0
- data/app/controllers/raif/admin/model_tool_invocations_controller.rb +17 -0
- data/app/controllers/raif/admin/tasks_controller.rb +23 -0
- data/app/controllers/raif/application_controller.rb +20 -0
- data/app/controllers/raif/conversation_entries_controller.rb +60 -0
- data/app/controllers/raif/conversations_controller.rb +58 -0
- data/app/helpers/raif/application_helper.rb +7 -0
- data/app/helpers/raif/shared/conversations_helper.rb +13 -0
- data/app/jobs/raif/application_job.rb +8 -0
- data/app/jobs/raif/conversation_entry_job.rb +30 -0
- data/app/models/raif/agent.rb +133 -0
- data/app/models/raif/agents/native_tool_calling_agent.rb +127 -0
- data/app/models/raif/agents/re_act_agent.rb +121 -0
- data/app/models/raif/agents/re_act_step.rb +33 -0
- data/app/models/raif/application_record.rb +14 -0
- data/app/models/raif/concerns/boolean_timestamp.rb +69 -0
- data/app/models/raif/concerns/has_available_model_tools.rb +13 -0
- data/app/models/raif/concerns/has_llm.rb +19 -0
- data/app/models/raif/concerns/has_requested_language.rb +20 -0
- data/app/models/raif/concerns/invokes_model_tools.rb +13 -0
- data/app/models/raif/concerns/llm_response_parsing.rb +44 -0
- data/app/models/raif/conversation.rb +67 -0
- data/app/models/raif/conversation_entry.rb +85 -0
- data/app/models/raif/llm.rb +88 -0
- data/app/models/raif/llms/anthropic.rb +120 -0
- data/app/models/raif/llms/bedrock_claude.rb +134 -0
- data/app/models/raif/llms/open_ai.rb +259 -0
- data/app/models/raif/model_completion.rb +28 -0
- data/app/models/raif/model_tool.rb +69 -0
- data/app/models/raif/model_tool_invocation.rb +43 -0
- data/app/models/raif/model_tools/agent_final_answer.rb +46 -0
- data/app/models/raif/model_tools/fetch_url.rb +57 -0
- data/app/models/raif/model_tools/wikipedia_search.rb +78 -0
- data/app/models/raif/task.rb +137 -0
- data/app/models/raif/user_tool_invocation.rb +29 -0
- data/app/views/layouts/raif/admin.html.erb +98 -0
- data/app/views/raif/admin/agents/_agent.html.erb +18 -0
- data/app/views/raif/admin/agents/_conversation_message.html.erb +15 -0
- data/app/views/raif/admin/agents/index.html.erb +33 -0
- data/app/views/raif/admin/agents/show.html.erb +131 -0
- data/app/views/raif/admin/conversations/_conversation.html.erb +7 -0
- data/app/views/raif/admin/conversations/_conversation_entry.html.erb +34 -0
- data/app/views/raif/admin/conversations/index.html.erb +32 -0
- data/app/views/raif/admin/conversations/show.html.erb +56 -0
- data/app/views/raif/admin/model_completions/_model_completion.html.erb +9 -0
- data/app/views/raif/admin/model_completions/index.html.erb +34 -0
- data/app/views/raif/admin/model_completions/show.html.erb +117 -0
- data/app/views/raif/admin/model_tool_invocations/_model_tool_invocation.html.erb +16 -0
- data/app/views/raif/admin/model_tool_invocations/index.html.erb +33 -0
- data/app/views/raif/admin/model_tool_invocations/show.html.erb +66 -0
- data/app/views/raif/admin/tasks/_task.html.erb +19 -0
- data/app/views/raif/admin/tasks/index.html.erb +49 -0
- data/app/views/raif/admin/tasks/show.html.erb +176 -0
- data/app/views/raif/conversation_entries/_conversation_entry.html.erb +26 -0
- data/app/views/raif/conversation_entries/_form.html.erb +25 -0
- data/app/views/raif/conversation_entries/_form_with_available_tools.html.erb +4 -0
- data/app/views/raif/conversation_entries/_form_with_user_tool_invocation.html.erb +18 -0
- data/app/views/raif/conversation_entries/_message.html.erb +17 -0
- data/app/views/raif/conversation_entries/_model_response_avatar.html.erb +1 -0
- data/app/views/raif/conversation_entries/_user_avatar.html.erb +1 -0
- data/app/views/raif/conversation_entries/create.turbo_stream.erb +11 -0
- data/app/views/raif/conversation_entries/new.turbo_stream.erb +6 -0
- data/app/views/raif/conversations/_available_user_tools.html.erb +11 -0
- data/app/views/raif/conversations/_full_conversation.html.erb +15 -0
- data/app/views/raif/conversations/show.html.erb +1 -0
- data/config/i18n-tasks.yml +181 -0
- data/config/importmap.rb +6 -0
- data/config/initializers/pagy.rb +14 -0
- data/config/locales/admin.en.yml +91 -0
- data/config/locales/en.yml +50 -0
- data/config/routes.rb +22 -0
- data/db/migrate/20250224234252_create_raif_tables.rb +114 -0
- data/lib/generators/raif/agent/agent_generator.rb +22 -0
- data/lib/generators/raif/agent/templates/agent.rb.tt +28 -0
- data/lib/generators/raif/conversation/conversation_generator.rb +27 -0
- data/lib/generators/raif/conversation/templates/conversation.rb.tt +37 -0
- data/lib/generators/raif/install/install_generator.rb +31 -0
- data/lib/generators/raif/install/templates/initializer.rb +81 -0
- data/lib/generators/raif/model_tool/model_tool_generator.rb +27 -0
- data/lib/generators/raif/model_tool/templates/model_tool.rb.tt +74 -0
- data/lib/generators/raif/task/task_generator.rb +28 -0
- data/lib/generators/raif/task/templates/application_task.rb.tt +7 -0
- data/lib/generators/raif/task/templates/task.rb.tt +52 -0
- data/lib/generators/raif/views_generator.rb +22 -0
- data/lib/raif/configuration.rb +82 -0
- data/lib/raif/default_llms.rb +37 -0
- data/lib/raif/engine.rb +86 -0
- data/lib/raif/errors/action_not_authorized_error.rb +8 -0
- data/lib/raif/errors/anthropic/api_error.rb +10 -0
- data/lib/raif/errors/invalid_config_error.rb +8 -0
- data/lib/raif/errors/invalid_conversation_type_error.rb +8 -0
- data/lib/raif/errors/invalid_user_tool_type_error.rb +8 -0
- data/lib/raif/errors/open_ai/api_error.rb +10 -0
- data/lib/raif/errors/open_ai/json_schema_error.rb +10 -0
- data/lib/raif/errors.rb +9 -0
- data/lib/raif/languages.rb +33 -0
- data/lib/raif/rspec.rb +7 -0
- data/lib/raif/utils/html_to_markdown_converter.rb +7 -0
- data/lib/raif/utils/readable_content_extractor.rb +61 -0
- data/lib/raif/utils.rb +6 -0
- data/lib/raif/version.rb +5 -0
- data/lib/raif.rb +65 -0
- data/lib/tasks/raif_tasks.rake +6 -0
- metadata +294 -0
@@ -0,0 +1,176 @@
|
|
1
|
+
<div class="d-flex justify-content-between align-items-center my-4">
|
2
|
+
<h1><%= t(".title", id: @task.id) %></h1>
|
3
|
+
<%= link_to t(".back_to_tasks"), raif.admin_tasks_path, class: "btn btn-outline-secondary" %>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<div class="card mb-4">
|
7
|
+
<div class="card-header">
|
8
|
+
<h5 class="mb-0"><%= t("raif.admin.common.details") %></h5>
|
9
|
+
</div>
|
10
|
+
<div class="card-body">
|
11
|
+
<div class="row mb-3">
|
12
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.id") %>:</strong></div>
|
13
|
+
<div class="col-md-9"><%= @task.id %></div>
|
14
|
+
</div>
|
15
|
+
<div class="row mb-3">
|
16
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.creator") %>:</strong></div>
|
17
|
+
<div class="col-md-9"><%= @task.creator_type %> #<%= @task.creator_id %></div>
|
18
|
+
</div>
|
19
|
+
<div class="row mb-3">
|
20
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.model") %>:</strong></div>
|
21
|
+
<div class="col-md-9"><%= @task.llm_model_key %></div>
|
22
|
+
</div>
|
23
|
+
<div class="row mb-3">
|
24
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.response_format") %>:</strong></div>
|
25
|
+
<div class="col-md-9"><%= @task.response_format %></div>
|
26
|
+
</div>
|
27
|
+
<div class="row mb-3">
|
28
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.created_at") %>:</strong></div>
|
29
|
+
<div class="col-md-9"><%= @task.created_at.rfc822 %></div>
|
30
|
+
</div>
|
31
|
+
<div class="row mb-3">
|
32
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.started_at") %>:</strong></div>
|
33
|
+
<div class="col-md-9">
|
34
|
+
<% if @task.started_at? %>
|
35
|
+
<%= @task.started_at.rfc822 %>
|
36
|
+
<% end %>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
<div class="row mb-3">
|
40
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.completed_at") %>:</strong></div>
|
41
|
+
<div class="col-md-9">
|
42
|
+
<% if @task.completed_at? %>
|
43
|
+
<%= @task.completed_at.rfc822 %>
|
44
|
+
<% end %>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
<div class="row mb-3">
|
48
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.failed_at") %>:</strong></div>
|
49
|
+
<div class="col-md-9">
|
50
|
+
<% if @task.failed_at? %>
|
51
|
+
<%= @task.failed_at.rfc822 %>
|
52
|
+
<% end %>
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
<div class="row mb-3">
|
56
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.status") %>:</strong></div>
|
57
|
+
<div class="col-md-9">
|
58
|
+
<% if @task.completed_at? %>
|
59
|
+
<span class="badge bg-success"><%= t("raif.admin.common.completed") %></span>
|
60
|
+
<% elsif @task.failed_at? %>
|
61
|
+
<span class="badge bg-danger"><%= t("raif.admin.common.failed") %></span>
|
62
|
+
<% elsif @task.started_at? %>
|
63
|
+
<span class="badge bg-warning text-dark"><%= t("raif.admin.common.in_progress") %></span>
|
64
|
+
<% else %>
|
65
|
+
<span class="badge bg-secondary"><%= t("raif.admin.common.pending") %></span>
|
66
|
+
<% end %>
|
67
|
+
</div>
|
68
|
+
</div>
|
69
|
+
<% if @task.requested_language_key.present? %>
|
70
|
+
<div class="row mb-3">
|
71
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.requested_language") %>:</strong></div>
|
72
|
+
<div class="col-md-9"><%= @task.requested_language_key %></div>
|
73
|
+
</div>
|
74
|
+
<% end %>
|
75
|
+
</div>
|
76
|
+
</div>
|
77
|
+
|
78
|
+
<% if @task.raif_model_completion.present? %>
|
79
|
+
<div class="card mb-4">
|
80
|
+
<div class="card-header">
|
81
|
+
<h5 class="mb-0"><%= t("raif.admin.common.model_completion") %></h5>
|
82
|
+
</div>
|
83
|
+
<div class="card-body">
|
84
|
+
<div class="row mb-3">
|
85
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.id") %>:</strong></div>
|
86
|
+
<div class="col-md-9">
|
87
|
+
<%= link_to "##{@task.raif_model_completion.id}", raif.admin_model_completion_path(@task.raif_model_completion) %>
|
88
|
+
</div>
|
89
|
+
</div>
|
90
|
+
<div class="row mb-3">
|
91
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.created_at") %>:</strong></div>
|
92
|
+
<div class="col-md-9"><%= @task.raif_model_completion.created_at.rfc822 %></div>
|
93
|
+
</div>
|
94
|
+
<div class="row mb-3">
|
95
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.prompt_tokens") %>:</strong></div>
|
96
|
+
<div class="col-md-9"><%= @task.raif_model_completion.prompt_tokens ? number_with_delimiter(@task.raif_model_completion.prompt_tokens) : "-" %></div>
|
97
|
+
</div>
|
98
|
+
<div class="row mb-3">
|
99
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.completion_tokens") %>:</strong></div>
|
100
|
+
<div class="col-md-9"><%= @task.raif_model_completion.completion_tokens ? number_with_delimiter(@task.raif_model_completion.completion_tokens) : "-" %></div>
|
101
|
+
</div>
|
102
|
+
<div class="row mb-3">
|
103
|
+
<div class="col-md-3"><strong><%= t("raif.admin.common.total_tokens") %>:</strong></div>
|
104
|
+
<div class="col-md-9"><%= @task.raif_model_completion.total_tokens ? number_with_delimiter(@task.raif_model_completion.total_tokens) : "-" %></div>
|
105
|
+
</div>
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
<% end %>
|
109
|
+
|
110
|
+
<div class="card mb-4">
|
111
|
+
<div class="card-header">
|
112
|
+
<h5 class="mb-0"><%= t("raif.admin.common.system_prompt") %></h5>
|
113
|
+
</div>
|
114
|
+
<div class="card-body">
|
115
|
+
<pre class="pre-wrap"><%= @task.system_prompt %></pre>
|
116
|
+
</div>
|
117
|
+
</div>
|
118
|
+
|
119
|
+
<div class="card mb-4">
|
120
|
+
<div class="card-header">
|
121
|
+
<h5 class="mb-0"><%= t("raif.admin.common.prompt") %></h5>
|
122
|
+
</div>
|
123
|
+
<div class="card-body">
|
124
|
+
<pre class="pre-wrap"><%= @task.prompt %></pre>
|
125
|
+
</div>
|
126
|
+
</div>
|
127
|
+
|
128
|
+
<div class="card mb-4">
|
129
|
+
<div class="card-header">
|
130
|
+
<h5 class="mb-0"><%= t("raif.admin.common.response") %> (<%= @task.response_format %>)</h5>
|
131
|
+
</div>
|
132
|
+
<div class="card-body">
|
133
|
+
|
134
|
+
<% if @task.response_format_json? %>
|
135
|
+
<h5 class="mb-0"><%= t("raif.admin.common.raw") %></h5>
|
136
|
+
<pre class="pre-wrap"><%= @task.raw_response %></pre>
|
137
|
+
|
138
|
+
<h5 class="mb-0 mt-4"><%= t("raif.admin.common.prettified") %></h5>
|
139
|
+
<% begin %>
|
140
|
+
<pre class="pre-wrap"><%= JSON.pretty_generate(@task.parsed_response) %></pre>
|
141
|
+
<% rescue StandardError %>
|
142
|
+
<%= t("raif.admin.common.invalid_json") %>
|
143
|
+
<% end %>
|
144
|
+
<% else %>
|
145
|
+
<pre class="pre-wrap"><%= @task.raw_response %></pre>
|
146
|
+
<% end %>
|
147
|
+
</div>
|
148
|
+
</div>
|
149
|
+
|
150
|
+
<% if @task.raif_model_tool_invocations.any? %>
|
151
|
+
<div class="card mb-4">
|
152
|
+
<div class="card-header">
|
153
|
+
<h5 class="mb-0"><%= t("raif.admin.common.tool_invocations") %></h5>
|
154
|
+
</div>
|
155
|
+
<div class="card-body">
|
156
|
+
<div class="list-group">
|
157
|
+
<% @task.raif_model_tool_invocations.each do |invocation| %>
|
158
|
+
<div class="list-group-item">
|
159
|
+
<div class="d-flex w-100 justify-content-between">
|
160
|
+
<h5 class="mb-1"><%= invocation.tool_name %></h5>
|
161
|
+
<small class="text-muted"><%= invocation.created_at.rfc822 %></small>
|
162
|
+
</div>
|
163
|
+
|
164
|
+
<p class="mb-1"><strong><%= t("raif.admin.common.arguments") %>:</strong></p>
|
165
|
+
|
166
|
+
<pre class="pre-wrap"><%= begin
|
167
|
+
JSON.pretty_generate(invocation.tool_arguments)
|
168
|
+
rescue StandardError
|
169
|
+
invocation.tool_arguments
|
170
|
+
end %></pre>
|
171
|
+
</div>
|
172
|
+
<% end %>
|
173
|
+
</div>
|
174
|
+
</div>
|
175
|
+
</div>
|
176
|
+
<% end %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<div id="<%= dom_id(conversation_entry) %>" class="my-2">
|
2
|
+
<%= render "raif/conversation_entries/message",
|
3
|
+
conversation_entry: conversation_entry,
|
4
|
+
content: conversation_entry.user_message,
|
5
|
+
message_type: :user %>
|
6
|
+
|
7
|
+
<% if conversation_entry.completed? || conversation_entry.generating_response? %>
|
8
|
+
<%= render "raif/conversation_entries/message",
|
9
|
+
conversation_entry: conversation_entry,
|
10
|
+
content: conversation_entry.generating_response? ? content_tag(:span, "", class: "raif-loader") : conversation_entry.model_response_message,
|
11
|
+
message_type: :model_response %>
|
12
|
+
|
13
|
+
<% conversation_entry.raif_model_tool_invocations.select(&:renderable?).each do |ti| %>
|
14
|
+
<div class="mb-4 container">
|
15
|
+
<%= render ti, conversation_entry: conversation_entry %>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
18
|
+
<% elsif conversation_entry.failed? %>
|
19
|
+
<div class="mb-4 container">
|
20
|
+
<%= render "raif/conversation_entries/message",
|
21
|
+
conversation_entry: conversation_entry,
|
22
|
+
content: t("raif.common.there_was_an_error_generating_this_response"),
|
23
|
+
message_type: :model_response %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
</div>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%= form_with model: conversation_entry,
|
2
|
+
url: raif.conversation_entries_path(conversation),
|
3
|
+
local: true do |f| %>
|
4
|
+
|
5
|
+
<% if conversation_entry.raif_user_tool_invocation %>
|
6
|
+
<%= hidden_field_tag :user_tool_type, conversation_entry.raif_user_tool_invocation.class.name %>
|
7
|
+
|
8
|
+
<%= f.fields_for :raif_user_tool_invocation, conversation_entry.raif_user_tool_invocation do |builder| %>
|
9
|
+
<%= render "raif/user_tool_invocations/form/#{conversation_entry.raif_user_tool_invocation.tool_key}_fields", f: builder %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<div class="d-flex">
|
14
|
+
<%= f.text_field :user_message,
|
15
|
+
class: "form-control me-2",
|
16
|
+
placeholder: conversation_entry.raif_user_tool_invocation&.message_input_placeholder.presence || t("raif.common.type_your_message"),
|
17
|
+
aria_label: conversation_entry.raif_user_tool_invocation&.message_input_placeholder.presence || t("raif.common.type_your_message") %>
|
18
|
+
|
19
|
+
<div class="d-flex justify-content-end align-items-end">
|
20
|
+
<%= button_tag type: "submit", class: "btn btn-primary d-flex align-items-center" do %>
|
21
|
+
<%= t("raif.common.send") %>
|
22
|
+
<% end %>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div class="card text-dark bg-light">
|
2
|
+
<div class="card-header py-2 px-3">
|
3
|
+
<div class="d-flex align-items-center">
|
4
|
+
<h5 class="mb-0 text-uppercase flex-grow-1"><%= conversation_entry.raif_user_tool_invocation.tool_name %></h5>
|
5
|
+
|
6
|
+
<%= link_to raif.new_conversation_entry_path(conversation), class: "text-dark", data: { turbo_stream: true } do %>
|
7
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
8
|
+
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z" />
|
9
|
+
</svg>
|
10
|
+
<% end %>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
<div class="card-body py-2 px-3">
|
14
|
+
<%= render "raif/conversation_entries/form",
|
15
|
+
conversation: conversation,
|
16
|
+
conversation_entry: conversation_entry %>
|
17
|
+
</div>
|
18
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div class="d-flex mb-2 chat-message">
|
2
|
+
<div class="d-flex w-100 <%= "justify-content-end" if message_type == :user %>">
|
3
|
+
<% if message_type == :model_response %>
|
4
|
+
<%= render "raif/conversation_entries/model_response_avatar", conversation_entry: local_assigns[:conversation_entry] %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<% if content.present? %>
|
8
|
+
<div class="mb-1 rounded-2 p-3 <%= message_type == :user ? "bg-primary text-white" : "border" %>">
|
9
|
+
<%= simple_format content %>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<% if message_type == :user %>
|
14
|
+
<%= render "raif/conversation_entries/user_avatar", conversation_entry: local_assigns[:conversation_entry] %>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
17
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%# so the host app can override to show a user avatar, if desired %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%# so the host app can override to show a user avatar, if desired %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% if @conversation_entry.persisted? %>
|
2
|
+
<%= turbo_stream.append dom_id(@conversation, :entries), @conversation_entry %>
|
3
|
+
<%= turbo_stream.action :raif_scroll_to_bottom, dom_id(@conversation, :entries) %>
|
4
|
+
|
5
|
+
<%= turbo_stream.update dom_id(@conversation, :entry_input) do %>
|
6
|
+
<%= render "raif/conversation_entries/form_with_available_tools",
|
7
|
+
conversation: @conversation,
|
8
|
+
conversation_entry: Raif::ConversationEntry.new
|
9
|
+
%>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% if conversation.available_user_tools.any? %>
|
2
|
+
<p class="mb-1 fs-10 text-body-tertiary text-opacity-85 fw-semibold"><%= t("raif.common.tools") %></p>
|
3
|
+
<div class="d-flex mb-2">
|
4
|
+
<% conversation.available_user_tool_classes.each do |tool| %>
|
5
|
+
<%= link_to tool.tool_name,
|
6
|
+
raif.new_conversation_entry_path(conversation, user_tool_type: tool.name),
|
7
|
+
class: "btn btn-sm btn-phoenix-secondary rounded-pill fs-10 me-1 mb-1",
|
8
|
+
data: { turbo_stream: true } %>
|
9
|
+
<% end %>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= turbo_stream_from conversation %>
|
2
|
+
|
3
|
+
<div id="<%= dom_id(conversation, :entries) %>" class="flex-grow-1 overflow-auto" data-controller="raif--conversations">
|
4
|
+
<%= render "raif/conversation_entries/message",
|
5
|
+
content: conversation.initial_chat_message,
|
6
|
+
message_type: :model_response %>
|
7
|
+
|
8
|
+
<%= render conversation.entries.oldest_first %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div id="<%= dom_id(conversation, :entry_input) %>">
|
12
|
+
<%= render "raif/conversation_entries/form_with_available_tools",
|
13
|
+
conversation: conversation,
|
14
|
+
conversation_entry: Raif::ConversationEntry.new %>
|
15
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= raif_conversation(@conversation) %>
|
@@ -0,0 +1,181 @@
|
|
1
|
+
# i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
|
2
|
+
|
3
|
+
# The "main" locale.
|
4
|
+
base_locale: en
|
5
|
+
## All available locales are inferred from the data by default. Alternatively, specify them explicitly:
|
6
|
+
# locales: [es, fr]
|
7
|
+
## Reporting locale, default: en. Available: en, ru.
|
8
|
+
# internal_locale: en
|
9
|
+
|
10
|
+
# Read and write translations.
|
11
|
+
data:
|
12
|
+
## Translations are read from the file system. Supported format: YAML, JSON.
|
13
|
+
## Provide a custom adapter:
|
14
|
+
# adapter: I18n::Tasks::Data::FileSystem
|
15
|
+
|
16
|
+
# Locale files or `Dir.glob` patterns where translations are read from:
|
17
|
+
read:
|
18
|
+
## Default:
|
19
|
+
- config/locales/%{locale}.yml
|
20
|
+
## More files:
|
21
|
+
- config/locales/**/*.%{locale}.yml
|
22
|
+
- config/locales/admin.%{locale}.yml
|
23
|
+
|
24
|
+
# Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
|
25
|
+
# `i18n-tasks normalize -p` will force move the keys according to these rules
|
26
|
+
write:
|
27
|
+
## For example, write devise and simple form keys to their respective files:
|
28
|
+
# - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml']
|
29
|
+
## Catch-all default:
|
30
|
+
- config/locales/%{locale}.yml
|
31
|
+
- ['raif.admin.*', 'config/locales/admin.%{locale}.yml']
|
32
|
+
|
33
|
+
# External locale data (e.g. gems).
|
34
|
+
# This data is not considered unused and is never written to.
|
35
|
+
external:
|
36
|
+
## Example (replace %#= with %=):
|
37
|
+
# - "<%#= %x[bundle info vagrant --path].chomp %>/templates/locales/%{locale}.yml"
|
38
|
+
|
39
|
+
## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class.
|
40
|
+
# router: conservative_router
|
41
|
+
|
42
|
+
yaml:
|
43
|
+
write:
|
44
|
+
# do not wrap lines at 80 characters
|
45
|
+
line_width: -1
|
46
|
+
|
47
|
+
## Pretty-print JSON:
|
48
|
+
# json:
|
49
|
+
# write:
|
50
|
+
# indent: ' '
|
51
|
+
# space: ' '
|
52
|
+
# object_nl: "\n"
|
53
|
+
# array_nl: "\n"
|
54
|
+
|
55
|
+
# Find translate calls
|
56
|
+
search:
|
57
|
+
## Paths or `Find.find` patterns to search in:
|
58
|
+
paths:
|
59
|
+
- app/
|
60
|
+
- lib/
|
61
|
+
|
62
|
+
## Root directories for relative keys resolution.
|
63
|
+
# relative_roots:
|
64
|
+
# - app/controllers
|
65
|
+
# - app/helpers
|
66
|
+
# - app/mailers
|
67
|
+
# - app/presenters
|
68
|
+
# - app/views
|
69
|
+
|
70
|
+
## Directories where method names which should not be part of a relative key resolution.
|
71
|
+
# By default, if a relative translation is used inside a method, the name of the method will be considered part of the resolved key.
|
72
|
+
# Directories listed here will not consider the name of the method part of the resolved key
|
73
|
+
#
|
74
|
+
# relative_exclude_method_name_paths:
|
75
|
+
# -
|
76
|
+
|
77
|
+
## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
|
78
|
+
## *.jpg *.jpeg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less
|
79
|
+
## *.yml *.json *.zip *.tar.gz *.swf *.flv *.mp3 *.wav *.flac *.webm *.mp4 *.ogg *.opus *.webp *.map *.xlsx
|
80
|
+
exclude:
|
81
|
+
- app/assets/images
|
82
|
+
- app/assets/fonts
|
83
|
+
- app/assets/videos
|
84
|
+
- app/assets/builds
|
85
|
+
|
86
|
+
## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`:
|
87
|
+
## If specified, this settings takes priority over `exclude`, but `exclude` still applies.
|
88
|
+
# only: ["*.rb", "*.html.slim"]
|
89
|
+
|
90
|
+
## If `strict` is `false`, guess usages such as t("categories.#{category}.title"). The default is `true`.
|
91
|
+
# strict: true
|
92
|
+
|
93
|
+
## Allows adding ast_matchers for finding translations using the AST-scanners
|
94
|
+
## The available matchers are:
|
95
|
+
## - RailsModelMatcher
|
96
|
+
## Matches ActiveRecord translations like
|
97
|
+
## User.human_attribute_name(:email) and User.model_name.human
|
98
|
+
## - DefaultI18nSubjectMatcher
|
99
|
+
## Matches ActionMailer's default_i18n_subject method
|
100
|
+
##
|
101
|
+
## To implement your own, please see `I18n::Tasks::Scanners::AstMatchers::BaseMatcher`.
|
102
|
+
# ast_matchers:
|
103
|
+
# - 'I18n::Tasks::Scanners::AstMatchers::RailsModelMatcher'
|
104
|
+
# - 'I18n::Tasks::Scanners::AstMatchers::DefaultI18nSubjectMatcher'
|
105
|
+
|
106
|
+
## Multiple scanners can be used. Their results are merged.
|
107
|
+
## The options specified above are passed down to each scanner. Per-scanner options can be specified as well.
|
108
|
+
## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example
|
109
|
+
|
110
|
+
## Translation Services
|
111
|
+
# translation:
|
112
|
+
# # Google Translate
|
113
|
+
# # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
|
114
|
+
# google_translate_api_key: "AbC-dEf5"
|
115
|
+
# # DeepL Pro Translate
|
116
|
+
# # Get an API key and subscription at https://www.deepl.com/pro to use DeepL Pro
|
117
|
+
# deepl_api_key: "48E92789-57A3-466A-9959-1A1A1A1A1A1A"
|
118
|
+
# # deepl_host: "https://api.deepl.com"
|
119
|
+
# # deepl_version: "v2"
|
120
|
+
# # deepl_glossary_ids:
|
121
|
+
# # - f28106eb-0e06-489e-82c6-8215d6f95089
|
122
|
+
# # - 2c6415be-1852-4f54-9e1b-d800463496b4
|
123
|
+
# # add additional options to the DeepL.translate call: https://www.deepl.com/docs-api/translate-text/translate-text/
|
124
|
+
# deepl_options:
|
125
|
+
# formality: prefer_less
|
126
|
+
# # OpenAI
|
127
|
+
# openai_api_key: "sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
|
128
|
+
# # openai_model: "gpt-3.5-turbo" # see https://platform.openai.com/docs/models
|
129
|
+
# # may contain `%{from}` and `%{to}`, which will be replaced by source and target locale codes, respectively (using `Kernel.format`)
|
130
|
+
# # openai_system_prompt: >-
|
131
|
+
# # You are a professional translator that translates content from the %{from} locale
|
132
|
+
# # to the %{to} locale in an i18n locale array.
|
133
|
+
# #
|
134
|
+
# # The array has a structured format and contains multiple strings. Your task is to translate
|
135
|
+
# # each of these strings and create a new array with the translated strings.
|
136
|
+
# #
|
137
|
+
# # HTML markups (enclosed in < and > characters) must not be changed under any circumstance.
|
138
|
+
# # Variables (starting with %%{ and ending with }) must not be changed under any circumstance.
|
139
|
+
# #
|
140
|
+
# # Keep in mind the context of all the strings for a more accurate translation.
|
141
|
+
|
142
|
+
## Do not consider these keys missing:
|
143
|
+
# ignore_missing:
|
144
|
+
# - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
|
145
|
+
# - '{devise,simple_form}.*'
|
146
|
+
|
147
|
+
## Consider these keys used:
|
148
|
+
# ignore_unused:
|
149
|
+
# - 'activerecord.attributes.*'
|
150
|
+
# - '{devise,kaminari,will_paginate}.*'
|
151
|
+
# - 'simple_form.{yes,no}'
|
152
|
+
# - 'simple_form.{placeholders,hints,labels}.*'
|
153
|
+
# - 'simple_form.{error_notification,required}.:'
|
154
|
+
|
155
|
+
## Exclude these keys from the `i18n-tasks eq-base' report:
|
156
|
+
# ignore_eq_base:
|
157
|
+
# all:
|
158
|
+
# - common.ok
|
159
|
+
# fr,es:
|
160
|
+
# - common.brand
|
161
|
+
|
162
|
+
## Exclude these keys from the `i18n-tasks check-consistent-interpolations` report:
|
163
|
+
# ignore_inconsistent_interpolations:
|
164
|
+
# - 'activerecord.attributes.*'
|
165
|
+
|
166
|
+
## Ignore these keys completely:
|
167
|
+
# ignore:
|
168
|
+
# - kaminari.*
|
169
|
+
|
170
|
+
## Sometimes, it isn't possible for i18n-tasks to match the key correctly,
|
171
|
+
## e.g. in case of a relative key defined in a helper method.
|
172
|
+
## In these cases you can use the built-in PatternMapper to map patterns to keys, e.g.:
|
173
|
+
#
|
174
|
+
# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
|
175
|
+
# only: %w(*.html.haml *.html.slim),
|
176
|
+
# patterns: [['= title\b', '.page_title']] %>
|
177
|
+
#
|
178
|
+
# The PatternMapper can also match key literals via a special %{key} interpolation, e.g.:
|
179
|
+
#
|
180
|
+
# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
|
181
|
+
# patterns: [['\bSpree\.t[( ]\s*%{key}', 'spree.%{key}']] %>
|
data/config/importmap.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Pagy initializer file
|
4
|
+
# See https://ddnexus.github.io/pagy/api/pagy#backend
|
5
|
+
|
6
|
+
# Optionally override some pagy default options
|
7
|
+
# Pagy::DEFAULT[:items] = 20 # items per page
|
8
|
+
# Pagy::DEFAULT[:size] = [1,4,4,1] # nav bar links
|
9
|
+
|
10
|
+
# When you are done setting your own default freeze it, so it will not get changed accidentally
|
11
|
+
# Pagy::DEFAULT.freeze
|
12
|
+
|
13
|
+
# Add the pagy backend to a controller or to an object that includes it
|
14
|
+
require "pagy/extras/bootstrap"
|
@@ -0,0 +1,91 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
raif:
|
4
|
+
admin:
|
5
|
+
agents:
|
6
|
+
show:
|
7
|
+
back_to_agents: Back to Agents
|
8
|
+
title: 'Agent #%{id}'
|
9
|
+
common:
|
10
|
+
agents: Agents
|
11
|
+
arguments: Arguments
|
12
|
+
at: at
|
13
|
+
completed: Completed
|
14
|
+
completed_at: Completed At
|
15
|
+
completion_tokens: Completion Tokens
|
16
|
+
conversation_entries: Conversation Entries
|
17
|
+
conversation_history: Conversation History
|
18
|
+
conversations: Conversations
|
19
|
+
created_at: Created At
|
20
|
+
creator: Creator
|
21
|
+
details: Details
|
22
|
+
entries_count: Entries Count
|
23
|
+
entry: Entry
|
24
|
+
failed: Failed
|
25
|
+
failed_at: Failed At
|
26
|
+
filter: Filter
|
27
|
+
final_answer: Final Answer
|
28
|
+
id: ID
|
29
|
+
in_progress: In Progress
|
30
|
+
initial_task: Initial Task
|
31
|
+
invalid_json: Invalid JSON
|
32
|
+
iterations: Iterations
|
33
|
+
language: Language
|
34
|
+
messages: Messages
|
35
|
+
model: Model
|
36
|
+
model_completion: Model Completion
|
37
|
+
model_completions: Model Completions
|
38
|
+
model_response: Model Response
|
39
|
+
model_tool_invocations: Model Tool Invocations
|
40
|
+
no_agents: No agents found.
|
41
|
+
no_conversations: No conversations found.
|
42
|
+
no_model_completions: No model completions found.
|
43
|
+
no_model_tool_invocations: No model tool invocations found.
|
44
|
+
no_tasks: No tasks found.
|
45
|
+
no_tool_calls: No tool calls
|
46
|
+
pending: Pending
|
47
|
+
prettified: Prettified
|
48
|
+
prompt: Prompt
|
49
|
+
prompt_tokens: Prompt Tokens
|
50
|
+
raw: Raw
|
51
|
+
rendered: Rendered
|
52
|
+
requested_language: Requested Language
|
53
|
+
response: Response
|
54
|
+
response_format: Response Format
|
55
|
+
response_format_parameter: Response Format Parameter
|
56
|
+
result: Result
|
57
|
+
running: Running
|
58
|
+
since: Since
|
59
|
+
source: Source
|
60
|
+
started_at: Started At
|
61
|
+
status: Status
|
62
|
+
system_prompt: System Prompt
|
63
|
+
task: Task
|
64
|
+
tasks: Tasks
|
65
|
+
tool_arguments: Tool Arguments
|
66
|
+
tool_calls: Tool Calls
|
67
|
+
tool_invocations: Tool Invocations
|
68
|
+
tool_name: Tool Name
|
69
|
+
tool_type: Tool Type
|
70
|
+
total_tokens: Total Tokens
|
71
|
+
type: Type
|
72
|
+
user_message: User Message
|
73
|
+
conversations:
|
74
|
+
show:
|
75
|
+
back_to_conversations: Back to Conversations
|
76
|
+
title: 'Conversation #%{id}'
|
77
|
+
layouts:
|
78
|
+
admin:
|
79
|
+
title: Raif Admin
|
80
|
+
model_completions:
|
81
|
+
show:
|
82
|
+
back_to_model_completions: Back to Model Completions
|
83
|
+
title: 'Model Completion #%{id}'
|
84
|
+
model_tool_invocations:
|
85
|
+
show:
|
86
|
+
back_to_model_tool_invocations: Back to Model Tool Invocations
|
87
|
+
title: 'Model Tool Invocation #%{id}'
|
88
|
+
tasks:
|
89
|
+
show:
|
90
|
+
back_to_tasks: Back to Tasks
|
91
|
+
title: 'Task #%{id}'
|