├── spec ├── dummy │ ├── log │ │ └── .keep │ ├── tmp │ │ ├── .keep │ │ ├── pids │ │ │ └── .keep │ │ ├── storage │ │ │ └── .keep │ │ └── local_secret.txt │ ├── storage │ │ └── .keep │ ├── app │ │ ├── assets │ │ │ ├── images │ │ │ │ └── .keep │ │ │ └── stylesheets │ │ │ │ └── application.css │ │ ├── models │ │ │ ├── concerns │ │ │ │ └── .keep │ │ │ ├── document.rb │ │ │ ├── application_record.rb │ │ │ └── raif │ │ │ │ ├── application_conversation.rb │ │ │ │ ├── test_user.rb │ │ │ │ └── conversations │ │ │ │ └── html_conversation_with_tools.rb │ │ ├── controllers │ │ │ ├── concerns │ │ │ │ └── .keep │ │ │ ├── application_controller.rb │ │ │ ├── chat_controller.rb │ │ │ └── agents_controller.rb │ │ ├── views │ │ │ ├── layouts │ │ │ │ ├── mailer.text.erb │ │ │ │ ├── mailer.html.erb │ │ │ │ └── application.html.erb │ │ │ ├── chat │ │ │ │ └── index.html.erb │ │ │ ├── agents │ │ │ │ ├── index.html.erb │ │ │ │ └── _conversation_history_entry.html.erb │ │ │ └── pwa │ │ │ │ ├── manifest.json.erb │ │ │ │ └── service-worker.js │ │ ├── helpers │ │ │ └── application_helper.rb │ │ ├── javascript │ │ │ ├── application.js │ │ │ └── controllers │ │ │ │ ├── application.js │ │ │ │ └── index.js │ │ └── jobs │ │ │ └── application_job.rb │ ├── raif_evals │ │ ├── results │ │ │ └── .gitignore │ │ └── setup.rb │ ├── public │ │ ├── icon.png │ │ └── icon.svg │ ├── bin │ │ ├── dev │ │ ├── importmap │ │ ├── rake │ │ ├── rails │ │ └── setup │ ├── config │ │ ├── environments │ │ │ └── development_mysql.rb │ │ ├── environment.rb │ │ ├── cable.yml │ │ ├── boot.rb │ │ ├── importmap.rb │ │ ├── initializers │ │ │ ├── assets.rb │ │ │ ├── filter_parameter_logging.rb │ │ │ ├── inflections.rb │ │ │ ├── raif.rb │ │ │ └── content_security_policy.rb │ │ ├── database.yml │ │ ├── routes.rb │ │ ├── locales │ │ │ └── en.yml │ │ ├── application.rb │ │ ├── storage.yml │ │ └── puma.rb │ ├── config.ru │ ├── db │ │ └── migrate │ │ │ ├── 20250225005128_create_users.rb │ │ │ └── 20250804015504_create_documents.rb │ └── Rakefile ├── fixtures │ ├── files │ │ ├── test.pdf │ │ └── cultivate.png │ └── llm_responses │ │ ├── anthropic │ │ └── developer_managed_fetch_url.json │ │ ├── open_router │ │ └── developer_managed_fetch_url.json │ │ └── open_ai_completions │ │ └── developer_managed_fetch_url.json ├── factories │ ├── test_users.rb │ └── shared │ │ ├── model_tool_invocations.rb │ │ ├── agents.rb │ │ ├── conversations.rb │ │ ├── conversation_entries.rb │ │ ├── tasks.rb │ │ └── model_completions.rb ├── models │ └── raif │ │ ├── model_tools │ │ ├── fetch_url_spec.rb │ │ ├── wikipedia_search_spec.rb │ │ └── agent_final_answer_spec.rb │ │ ├── embedding_model_spec.rb │ │ └── model_tool_spec.rb ├── support │ ├── test_conversation.rb │ ├── test_llm.rb │ ├── test_embedding_model.rb │ ├── test_model_tool.rb │ ├── current_temperature_test_tool.rb │ └── test_task.rb ├── setup │ └── capybara.rb ├── features │ └── raif │ │ └── admin │ │ └── config_spec.rb ├── i18n_spec.rb ├── jobs │ └── raif │ │ └── conversation_entry_job_spec.rb └── shared_examples │ └── agent.rb ├── bin ├── css ├── docs ├── clean_schema ├── rubocop ├── rails └── lint ├── .rspec ├── app ├── assets │ ├── config │ │ └── raif_manifest.js │ ├── stylesheets │ │ ├── raif.scss │ │ └── raif │ │ │ ├── conversations.scss │ │ │ └── admin │ │ │ ├── stats.scss │ │ │ └── conversation.scss │ └── javascript │ │ ├── raif │ │ ├── controllers │ │ │ └── conversations_controller.js │ │ └── stream_actions │ │ │ └── raif_scroll_to_bottom.js │ │ └── raif.js ├── views │ └── raif │ │ ├── conversations │ │ ├── show.html.erb │ │ ├── _initial_chat_message.html.erb │ │ ├── _conversation.html.erb │ │ ├── _available_user_tools.html.erb │ │ ├── _entry_processed.turbo_stream.erb │ │ ├── _full_conversation.html.erb │ │ └── index.html.erb │ │ ├── conversation_entries │ │ ├── _user_avatar.html.erb │ │ ├── _model_response_avatar.html.erb │ │ ├── new.turbo_stream.erb │ │ ├── _form_with_available_tools.html.erb │ │ ├── _citations.html.erb │ │ ├── create.turbo_stream.erb │ │ ├── _form_with_user_tool_invocation.html.erb │ │ ├── _message.html.erb │ │ ├── _form.html.erb │ │ └── _conversation_entry.html.erb │ │ └── admin │ │ ├── conversations │ │ ├── _conversation.html.erb │ │ └── index.html.erb │ │ ├── model_tools │ │ ├── _list.html.erb │ │ └── _model_tool.html.erb │ │ ├── tasks │ │ └── _task.html.erb │ │ ├── model_tool_invocations │ │ └── _model_tool_invocation.html.erb │ │ ├── model_completions │ │ ├── _model_completion.html.erb │ │ └── index.html.erb │ │ ├── agents │ │ ├── index.html.erb │ │ ├── _agent.html.erb │ │ └── _conversation_message.html.erb │ │ └── stats │ │ ├── model_tool_invocations │ │ └── index.html.erb │ │ └── _stats_tile.html.erb ├── models │ └── raif │ │ ├── model_image_input.rb │ │ ├── admin │ │ └── task_stat.rb │ │ ├── model_tools │ │ ├── provider_managed │ │ │ ├── base.rb │ │ │ ├── web_search.rb │ │ │ ├── code_execution.rb │ │ │ └── image_generation.rb │ │ ├── agent_final_answer.rb │ │ └── fetch_url.rb │ │ ├── concerns │ │ ├── invokes_model_tools.rb │ │ ├── has_available_model_tools.rb │ │ ├── llm_temperature.rb │ │ ├── has_llm.rb │ │ ├── has_requested_language.rb │ │ ├── llms │ │ │ ├── anthropic │ │ │ │ └── response_tool_calls.rb │ │ │ ├── open_ai_completions │ │ │ │ ├── response_tool_calls.rb │ │ │ │ └── tool_formatting.rb │ │ │ ├── open_ai_responses │ │ │ │ ├── response_tool_calls.rb │ │ │ │ └── tool_formatting.rb │ │ │ ├── bedrock │ │ │ │ ├── response_tool_calls.rb │ │ │ │ └── tool_formatting.rb │ │ │ └── message_formatting.rb │ │ └── agent_inference_stats.rb │ │ ├── embedding_model.rb │ │ ├── embedding_models │ │ ├── bedrock.rb │ │ └── open_ai.rb │ │ ├── application_record.rb │ │ ├── user_tool_invocation.rb │ │ └── streaming_responses │ │ └── open_ai_responses.rb ├── helpers │ └── raif │ │ ├── application_helper.rb │ │ └── shared │ │ └── conversations_helper.rb ├── jobs │ └── raif │ │ ├── application_job.rb │ │ └── conversation_entry_job.rb └── controllers │ └── raif │ ├── admin │ ├── agents_controller.rb │ ├── conversations_controller.rb │ ├── model_completions_controller.rb │ ├── stats │ │ ├── model_tool_invocations_controller.rb │ │ └── tasks_controller.rb │ ├── model_tool_invocations_controller.rb │ ├── tasks_controller.rb │ └── application_controller.rb │ └── application_controller.rb ├── docs ├── _includes │ ├── table-of-contents.md │ └── footer_custom.html ├── .gitignore ├── assets │ └── images │ │ ├── raif-logo-400.png │ │ └── screenshots │ │ ├── demo-app.png │ │ ├── admin-stats.png │ │ ├── admin-agents-show.png │ │ ├── admin-stats-tasks.png │ │ ├── admin-tasks-index.png │ │ ├── admin-tasks-show.png │ │ ├── admin-agents-index.png │ │ ├── conversation-interface.png │ │ ├── admin-conversation-show.png │ │ ├── admin-conversations-index.png │ │ ├── admin-model-completion-show.png │ │ ├── admin-model-completions-index.png │ │ ├── conversation-tool-invocation.png │ │ ├── admin-model-tool-invocation-show.png │ │ └── admin-model-tool-invocations-index.png ├── _sass │ ├── custom │ │ └── setup.scss │ └── color_schemes │ │ └── raif.scss ├── README.md ├── _learn_more │ ├── demo_app.md │ ├── embedding_models.md │ └── streaming.md └── Gemfile ├── lib ├── raif │ ├── version.rb │ ├── errors │ │ ├── invalid_config_error.rb │ │ ├── unsupported_feature_error.rb │ │ ├── action_not_authorized_error.rb │ │ ├── invalid_user_tool_type_error.rb │ │ ├── invalid_model_file_input_error.rb │ │ ├── invalid_model_image_input_error.rb │ │ ├── instance_dependent_schema_error.rb │ │ ├── invalid_conversation_type_error.rb │ │ ├── open_ai │ │ │ └── json_schema_error.rb │ │ └── streaming_error.rb │ ├── utils │ │ ├── html_to_markdown_converter.rb │ │ ├── colors.rb │ │ └── readable_content_extractor.rb │ ├── utils.rb │ ├── rspec.rb │ ├── languages.rb │ ├── errors.rb │ ├── evals.rb │ ├── evals │ │ ├── eval.rb │ │ ├── llm_judge.rb │ │ └── expectation_result.rb │ └── cli │ │ ├── evals_setup.rb │ │ ├── base.rb │ │ └── evals.rb ├── generators │ └── raif │ │ ├── task │ │ ├── templates │ │ │ ├── application_task.rb.tt │ │ │ └── task_eval_set.rb.tt │ │ └── task_generator.rb │ │ ├── agent │ │ ├── templates │ │ │ ├── application_agent.rb.tt │ │ │ ├── agent.rb.tt │ │ │ └── agent_eval_set.rb.tt │ │ └── agent_generator.rb │ │ ├── conversation │ │ └── templates │ │ │ └── application_conversation.rb.tt │ │ ├── base_generator.rb │ │ ├── eval_set │ │ ├── templates │ │ │ └── eval_set.rb.tt │ │ └── eval_set_generator.rb │ │ ├── model_tool │ │ ├── templates │ │ │ └── model_tool_invocation_partial.html.erb.tt │ │ └── model_tool_generator.rb │ │ ├── views_generator.rb │ │ ├── install │ │ └── install_generator.rb │ │ └── evals │ │ └── setup │ │ └── setup_generator.rb ├── tasks │ ├── raif_tasks.rake │ └── annotate_rb.rake └── raif.rb ├── exe └── raif ├── .gitignore ├── db └── migrate │ ├── 20250911125234_add_source_to_raif_tasks.rb │ ├── 20251020005853_add_source_to_raif_agents.rb │ ├── 20251020011346_rename_task_run_args_to_run_with.rb │ ├── 20251128202941_add_tool_choice_to_raif_model_completions.rb │ ├── 20250507155314_add_retry_count_to_raif_model_completions.rb │ ├── 20250421202149_add_response_format_to_raif_conversations.rb │ ├── 20250811171150_make_raif_task_creator_optional.rb │ ├── 20250603202013_add_stream_response_to_raif_model_completions.rb │ ├── 20251124185033_add_provider_tool_call_id_to_raif_model_tool_invocations.rb │ ├── 20250904194456_add_generating_entry_response_to_raif_conversations.rb │ ├── 20251020011405_add_run_with_to_raif_agents.rb │ ├── 20250804013843_add_task_run_args_to_raif_tasks.rb │ ├── 20250424232946_add_created_at_indexes.rb │ ├── 20250603140622_add_citations_to_raif_model_completions.rb │ ├── 20250527213016_add_response_id_and_response_array_to_model_completions.rb │ ├── 20251024160119_add_llm_messages_max_length_to_raif_conversations.rb │ ├── 20250502155330_add_status_indexes_to_raif_tasks.rb │ └── 20250424200755_add_cost_columns_to_raif_model_completions.rb ├── config ├── importmap.rb ├── initializers │ └── pagy.rb └── routes.rb ├── .github └── dependabot.yml ├── .claude ├── commands │ └── release-prep.md └── settings.local.json ├── Rakefile ├── gemfiles └── rails72.gemfile ├── Gemfile ├── .erb_lint.yml ├── MIT-LICENSE ├── CONTRIBUTING.md ├── package.json ├── .annotaterb.yml ├── vcr_cassettes ├── open_router │ └── text_response.yml ├── bedrock │ ├── json_response.yml │ └── text_response.yml └── open_ai_responses │ └── streaming_error.yml ├── raif.gemspec └── .rubocop.yml /spec/dummy/log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/dummy/tmp/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/dummy/storage/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/dummy/tmp/pids/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/dummy/tmp/storage/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/dummy/app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/dummy/app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/dummy/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bin/css: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | bundle exec yarn watch:css -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require spec_helper --format documentation 2 | -------------------------------------------------------------------------------- /spec/dummy/app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /spec/dummy/raif_evals/results/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /bin/docs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd docs 4 | bundle exec jekyll serve -------------------------------------------------------------------------------- /bin/clean_schema: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | bundle exec rails app:db:migrate:reset -------------------------------------------------------------------------------- /app/assets/config/raif_manifest.js: -------------------------------------------------------------------------------- 1 | //= link_directory ../stylesheets/raif .css 2 | -------------------------------------------------------------------------------- /app/assets/stylesheets/raif.scss: -------------------------------------------------------------------------------- 1 | @use "raif/loader"; 2 | @use "raif/conversations"; -------------------------------------------------------------------------------- /app/views/raif/conversations/show.html.erb: -------------------------------------------------------------------------------- 1 | <%= raif_conversation(@conversation) %> 2 | -------------------------------------------------------------------------------- /spec/dummy/app/views/chat/index.html.erb: -------------------------------------------------------------------------------- 1 | <%= raif_conversation(@conversation) %> 2 | -------------------------------------------------------------------------------- /docs/_includes/table-of-contents.md: -------------------------------------------------------------------------------- 1 | ### Table of Contents 2 | {: .no_toc .text-delta } 3 | 1. TOC 4 | {:toc} -------------------------------------------------------------------------------- /spec/dummy/public/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/spec/dummy/public/icon.png -------------------------------------------------------------------------------- /lib/raif/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | VERSION = "1.4.0.pre" 5 | end 6 | -------------------------------------------------------------------------------- /spec/fixtures/files/test.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/spec/fixtures/files/test.pdf -------------------------------------------------------------------------------- /app/assets/stylesheets/raif/conversations.scss: -------------------------------------------------------------------------------- 1 | .raif-conversation-entries-container { 2 | scroll-behavior: smooth; 3 | } -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _site/ 2 | .sass-cache/ 3 | .jekyll-cache/ 4 | .jekyll-metadata 5 | .bundle/ 6 | vendor/ 7 | Gemfile.lock -------------------------------------------------------------------------------- /spec/dummy/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module ApplicationHelper 4 | end 5 | -------------------------------------------------------------------------------- /spec/dummy/app/models/document.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Document < ApplicationRecord 4 | end 5 | -------------------------------------------------------------------------------- /spec/dummy/bin/dev: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | exec "./bin/rails", "server", *ARGV 5 | -------------------------------------------------------------------------------- /spec/fixtures/files/cultivate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/spec/fixtures/files/cultivate.png -------------------------------------------------------------------------------- /docs/assets/images/raif-logo-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/raif-logo-400.png -------------------------------------------------------------------------------- /app/views/raif/conversation_entries/_user_avatar.html.erb: -------------------------------------------------------------------------------- 1 | <%# so the host app can override to show a user avatar, if desired %> 2 | -------------------------------------------------------------------------------- /docs/_sass/custom/setup.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Setup file to import color scheme variables 3 | // 4 | 5 | @import "./color_schemes/raif"; -------------------------------------------------------------------------------- /app/models/raif/model_image_input.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Raif::ModelImageInput < Raif::ModelFileInput 4 | end 5 | -------------------------------------------------------------------------------- /app/views/raif/conversation_entries/_model_response_avatar.html.erb: -------------------------------------------------------------------------------- 1 | <%# so the host app can override to show a user avatar, if desired %> 2 | -------------------------------------------------------------------------------- /docs/assets/images/screenshots/demo-app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/demo-app.png -------------------------------------------------------------------------------- /docs/assets/images/screenshots/admin-stats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/admin-stats.png -------------------------------------------------------------------------------- /docs/assets/images/screenshots/admin-agents-show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/admin-agents-show.png -------------------------------------------------------------------------------- /docs/assets/images/screenshots/admin-stats-tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/admin-stats-tasks.png -------------------------------------------------------------------------------- /docs/assets/images/screenshots/admin-tasks-index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/admin-tasks-index.png -------------------------------------------------------------------------------- /docs/assets/images/screenshots/admin-tasks-show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/admin-tasks-show.png -------------------------------------------------------------------------------- /docs/_includes/footer_custom.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/assets/images/screenshots/admin-agents-index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/admin-agents-index.png -------------------------------------------------------------------------------- /spec/dummy/public/icon.svg: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /spec/dummy/tmp/local_secret.txt: -------------------------------------------------------------------------------- 1 | 1e7ecad2ed971ddc81cab497d3a32562825efab2a6cfbfe699bb6c2d130835a01868e0c7b4a2473ce74dfc1eb421911abf922d5d4f5bcb83f95b66693a496da2 -------------------------------------------------------------------------------- /docs/assets/images/screenshots/conversation-interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/conversation-interface.png -------------------------------------------------------------------------------- /spec/dummy/app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ApplicationRecord < ActiveRecord::Base 4 | primary_abstract_class 5 | end 6 | -------------------------------------------------------------------------------- /spec/dummy/bin/importmap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | require_relative "../config/application" 5 | require "importmap/commands" 6 | -------------------------------------------------------------------------------- /spec/dummy/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | require_relative "../config/boot" 5 | require "rake" 6 | Rake.application.run 7 | -------------------------------------------------------------------------------- /app/helpers/raif/application_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | module ApplicationHelper 5 | include Pagy::Frontend 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /docs/assets/images/screenshots/admin-conversation-show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/admin-conversation-show.png -------------------------------------------------------------------------------- /exe/raif: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | require_relative "../lib/raif/cli" 5 | 6 | # Run the CLI 7 | Raif::CLI::Runner.new(ARGV).run 8 | -------------------------------------------------------------------------------- /spec/dummy/config/environments/development_mysql.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative "development" 4 | 5 | Rails.application.configure do 6 | end 7 | -------------------------------------------------------------------------------- /docs/assets/images/screenshots/admin-conversations-index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/admin-conversations-index.png -------------------------------------------------------------------------------- /docs/assets/images/screenshots/admin-model-completion-show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/admin-model-completion-show.png -------------------------------------------------------------------------------- /lib/generators/raif/task/templates/application_task.rb.tt: -------------------------------------------------------------------------------- 1 | module Raif 2 | class ApplicationTask < Raif::Task 3 | # Add any shared task behavior here 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /docs/assets/images/screenshots/admin-model-completions-index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/admin-model-completions-index.png -------------------------------------------------------------------------------- /docs/assets/images/screenshots/conversation-tool-invocation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/conversation-tool-invocation.png -------------------------------------------------------------------------------- /docs/assets/images/screenshots/admin-model-tool-invocation-show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/admin-model-tool-invocation-show.png -------------------------------------------------------------------------------- /docs/assets/images/screenshots/admin-model-tool-invocations-index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CultivateLabs/raif/HEAD/docs/assets/images/screenshots/admin-model-tool-invocations-index.png -------------------------------------------------------------------------------- /lib/raif/errors/invalid_config_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | module Errors 5 | class InvalidConfigError < StandardError 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /app/jobs/raif/application_job.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | class ApplicationJob < ::ApplicationJob 5 | include ActionView::RecordIdentifier 6 | 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/raif/errors/unsupported_feature_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | module Errors 5 | class UnsupportedFeatureError < StandardError 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/generators/raif/agent/templates/application_agent.rb.tt: -------------------------------------------------------------------------------- 1 | module Raif 2 | class ApplicationAgent < Raif::Agents::NativeToolCallingAgent 3 | # Add any shared agent behavior here 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /lib/raif/errors/action_not_authorized_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | module Errors 5 | class ActionNotAuthorizedError < StandardError 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/raif/errors/invalid_user_tool_type_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | module Errors 5 | class InvalidUserToolTypeError < StandardError 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/raif/errors/invalid_model_file_input_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | module Errors 5 | class InvalidModelFileInputError < StandardError 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/raif/errors/invalid_model_image_input_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | module Errors 5 | class InvalidModelImageInputError < StandardError 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/dummy/raif_evals/setup.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # This file is loaded at the start of a run of your evals. 5 | # 6 | # Add any setup code that should run before your evals. 7 | # 8 | -------------------------------------------------------------------------------- /lib/generators/raif/conversation/templates/application_conversation.rb.tt: -------------------------------------------------------------------------------- 1 | module Raif 2 | class ApplicationConversation < Raif::Conversation 3 | # Add any shared conversation behavior here 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /lib/raif/errors/instance_dependent_schema_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | module Errors 5 | class InstanceDependentSchemaError < StandardError 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/raif/errors/invalid_conversation_type_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | module Errors 5 | class InvalidConversationTypeError < StandardError 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/dummy/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | APP_PATH = File.expand_path("../config/application", __dir__) 5 | require_relative "../config/boot" 6 | require "rails/commands" 7 | -------------------------------------------------------------------------------- /spec/dummy/config/environment.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Load the Rails application. 4 | require_relative "application" 5 | 6 | # Initialize the Rails application. 7 | Rails.application.initialize! 8 | -------------------------------------------------------------------------------- /app/models/raif/admin/task_stat.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | module Admin 5 | TaskStat = Data.define(:type, :llm_model_key, :count, :input_cost, :output_cost, :total_cost) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy/app/javascript/application.js: -------------------------------------------------------------------------------- 1 | // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails 2 | import "@hotwired/turbo-rails" 3 | import "controllers" 4 | import "raif" 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /log/*.log 3 | /pkg/ 4 | /tmp/ 5 | /spec/dummy/log/*.log 6 | /spec/dummy/storage/ 7 | /spec/dummy/tmp/ 8 | /spec/examples.txt 9 | /node_modules/ 10 | /.yardoc/ 11 | /doc/ 12 | *.gem 13 | .erb_lint_cache/ -------------------------------------------------------------------------------- /lib/raif/utils/html_to_markdown_converter.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Raif::Utils::HtmlToMarkdownConverter 4 | def self.convert(html) 5 | ReverseMarkdown.convert(html, unknown_tags: :bypass) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy/app/models/raif/application_conversation.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | class ApplicationConversation < Raif::Conversation 5 | # Add any shared conversation behavior here 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy/config.ru: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # This file is used by Rack-based servers to start the application. 4 | 5 | require_relative "config/environment" 6 | 7 | run Rails.application 8 | Rails.application.load_server 9 | -------------------------------------------------------------------------------- /app/views/raif/conversations/_initial_chat_message.html.erb: -------------------------------------------------------------------------------- 1 | <%# locals: (conversation:) %> 2 | 3 | <%= render "raif/conversation_entries/message", 4 | content: conversation.initial_chat_message, 5 | message_type: :model_response %> 6 | -------------------------------------------------------------------------------- /lib/raif/errors/open_ai/json_schema_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif 4 | module Errors 5 | module OpenAi 6 | class JsonSchemaError < StandardError 7 | end 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /app/assets/stylesheets/raif/admin/stats.scss: -------------------------------------------------------------------------------- 1 | .stats-icon { 2 | min-width: 46px; 3 | text-align: center; 4 | } 5 | 6 | .stats-card { 7 | transition: transform 0.2s; 8 | } 9 | 10 | .stats-card:hover { 11 | transform: translateY(-5px); 12 | } -------------------------------------------------------------------------------- /app/views/raif/conversation_entries/new.turbo_stream.erb: -------------------------------------------------------------------------------- 1 | <%= turbo_stream.update dom_id(@conversation, :entry_input) do %> 2 | <%= render @form_partial, 3 | conversation: @conversation, 4 | conversation_entry: @conversation_entry 5 | %> 6 | <% end %> -------------------------------------------------------------------------------- /app/models/raif/model_tools/provider_managed/base.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Raif::ModelTools::ProviderManaged::Base < Raif::ModelTool 4 | class << self 5 | def provider_managed? 6 | true 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/20250911125234_add_source_to_raif_tasks.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddSourceToRaifTasks < ActiveRecord::Migration[7.1] 4 | def change 5 | add_reference :raif_tasks, :source, polymorphic: true, index: true 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /db/migrate/20251020005853_add_source_to_raif_agents.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddSourceToRaifAgents < ActiveRecord::Migration[7.1] 4 | def change 5 | add_reference :raif_agents, :source, polymorphic: true, index: true 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /db/migrate/20251020011346_rename_task_run_args_to_run_with.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class RenameTaskRunArgsToRunWith < ActiveRecord::Migration[7.1] 4 | def change 5 | rename_column :raif_tasks, :task_run_args, :run_with 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy/config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: test 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: dummy_production 11 | -------------------------------------------------------------------------------- /lib/raif/utils.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Raif::Utils 4 | require "raif/utils/readable_content_extractor" 5 | require "raif/utils/html_to_markdown_converter" 6 | require "raif/utils/html_fragment_processor" 7 | require "raif/utils/colors" 8 | end 9 | -------------------------------------------------------------------------------- /db/migrate/20251128202941_add_tool_choice_to_raif_model_completions.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddToolChoiceToRaifModelCompletions < ActiveRecord::Migration[7.2] 4 | def change 5 | add_column :raif_model_completions, :tool_choice, :string 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy/app/models/raif/test_user.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Raif::TestUser < ApplicationRecord 4 | has_one_attached :avatar 5 | has_many_attached :documents 6 | 7 | def preferred_language_key 8 | # no-op so we can stub in tests 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /config/importmap.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | pin "raif", to: "raif.js" 4 | 5 | pin "raif/controllers/conversations_controller", to: "raif/controllers/conversations_controller.js" 6 | pin "raif/stream_actions/raif_scroll_to_bottom", to: "raif/stream_actions/raif_scroll_to_bottom.js" 7 | -------------------------------------------------------------------------------- /spec/dummy/db/migrate/20250225005128_create_users.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateUsers < ActiveRecord::Migration[7.1] 4 | def change 5 | create_table :raif_test_users do |t| 6 | t.string :email 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20250507155314_add_retry_count_to_raif_model_completions.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddRetryCountToRaifModelCompletions < ActiveRecord::Migration[7.1] 4 | def change 5 | add_column :raif_model_completions, :retry_count, :integer, default: 0, null: false 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy/Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Add your own tasks in files placed in lib/tasks ending in .rake, 4 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 5 | 6 | require_relative "config/application" 7 | 8 | Rails.application.load_tasks 9 | -------------------------------------------------------------------------------- /db/migrate/20250421202149_add_response_format_to_raif_conversations.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddResponseFormatToRaifConversations < ActiveRecord::Migration[7.1] 4 | def change 5 | add_column :raif_conversations, :response_format, :integer, default: 0, null: false 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy/app/javascript/controllers/application.js: -------------------------------------------------------------------------------- 1 | import { Application } from "@hotwired/stimulus" 2 | 3 | const application = Application.start() 4 | 5 | // Configure Stimulus development experience 6 | application.debug = false 7 | window.Stimulus = application 8 | 9 | export { application } 10 | -------------------------------------------------------------------------------- /db/migrate/20250811171150_make_raif_task_creator_optional.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class MakeRaifTaskCreatorOptional < ActiveRecord::Migration[7.1] 4 | def change 5 | change_column_null :raif_tasks, :creator_id, true 6 | change_column_null :raif_tasks, :creator_type, true 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: bundler 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | - package-ecosystem: github-actions 9 | directory: "/" 10 | schedule: 11 | interval: daily 12 | open-pull-requests-limit: 10 13 | -------------------------------------------------------------------------------- /app/views/raif/conversation_entries/_form_with_available_tools.html.erb: -------------------------------------------------------------------------------- 1 |
<%= t("raif.common.tools") %>
3 |<%%= JSON.pretty_generate(<%= file_name %>.result || {}) %>
9 | Edit this file in <%%= __FILE__ %> to customize the display of the tool invocation.
| <%= t("raif.conversations.index.table.started") %> | 10 |<%= t("raif.conversations.index.table.actions") %> | 11 |
|---|
<%= t("raif.conversations.index.no_conversations") %>
21 |,