source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/agents_spec.rb
Ruby
mit
296
main
8,910
# frozen_string_literal: true require "rails_helper" RSpec.describe "Agent features", type: :feature do let(:creator) { FB.create(:raif_test_user) } let(:wikipedia_page_content){ File.read("#{Raif::Engine.root}/spec/fixtures/files/wikipedia_page_content.html") } before do allow_any_instance_of(Application...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/conversations_spec.rb
Ruby
mit
296
main
10,473
# frozen_string_literal: true require "rails_helper" RSpec.describe "Conversation interface", type: :feature do let(:creator) { FB.create(:raif_test_user) } it "displays the conversation interface", js: true do stub_raif_conversation(Raif::Conversation) do |_messages| "I'm great how are you?" end ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/model_completions_spec.rb
Ruby
mit
296
main
13,010
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::ModelCompletions", type: :feature do let(:user) { FB.create(:raif_test_user) } let(:task) { FB.create(:raif_test_task, creator: user) } let(:task2) { FB.create(:raif_test_task, creator: user) } let(:task3) { FB.create(:raif_test_task,...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/stats_spec.rb
Ruby
mit
296
main
4,047
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::Stats", type: :feature do let(:creator) { FB.create(:raif_test_user) } describe "index page" do let!(:model_completions) { FB.create_list(:raif_model_completion, 3, model_api_name: "gpt-4", created_at: 12.hours.ago) } let!(:tasks...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/model_tool_invocations_spec.rb
Ruby
mit
296
main
10,402
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::ModelToolInvocations", type: :feature do let(:creator) { FB.create(:raif_test_user) } let(:task) { FB.create(:raif_test_task, creator: creator) } let(:conversation) { FB.create(:raif_test_conversation, creator: creator) } let(:convers...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/conversations_spec.rb
Ruby
mit
296
main
3,187
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::Conversations", type: :feature do let(:creator) { FB.create(:raif_test_user) } describe "index page" do let!(:conversations) { FB.create_list(:raif_test_conversation, 2, creator: creator) } let!(:conversation_with_entries) { FB.c...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/llms_spec.rb
Ruby
mit
296
main
810
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::Llms", type: :feature do describe "index page" do it "displays the registered LLMs with pricing information" do visit raif.admin_llms_path expect(page).to have_content("Registered LLMs") expect(page).to have_content("...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/tasks_spec.rb
Ruby
mit
296
main
5,979
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::Tasks", type: :feature do let(:creator) { FB.create(:raif_test_user) } describe "index page" do let!(:tasks) { FB.create_list(:raif_test_task, 2, creator: creator) } let!(:completed_task) do FB.create( :raif_test_ta...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/config_spec.rb
Ruby
mit
296
main
1,165
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::Config", type: :feature do describe "show page" do it "displays the Raif configuration settings" do allow(Raif.config).to receive(:open_ai_api_key).and_return("oai-key-1234567890abcdef") allow(Raif.config).to receive(:anthro...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/agents_spec.rb
Ruby
mit
296
main
8,098
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::Agents", type: :feature do let(:creator) { FB.create(:raif_test_user) } describe "index page" do let!(:pending_agent) do FB.create( :raif_native_tool_calling_agent, creator: creator, task: "What is the c...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/prompt_studio/tasks_spec.rb
Ruby
mit
296
main
3,573
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::PromptStudio::Tasks", type: :feature do let(:creator) { FB.create(:raif_test_user) } describe "index page" do let!(:completed_task) { FB.create(:raif_test_task, :completed, creator: creator) } let!(:incomplete_task) { FB.create(:...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/prompt_studio/batch_runs_spec.rb
Ruby
mit
296
main
2,952
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::PromptStudio::BatchRuns", type: :feature do let(:creator) { FB.create(:raif_test_user) } describe "tasks index with batch form" do let!(:task1) { FB.create(:raif_test_task, :completed, creator: creator) } let!(:task2) { FB.create...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/prompt_studio/conversations_spec.rb
Ruby
mit
296
main
2,273
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::PromptStudio::Conversations", type: :feature do let(:creator) { FB.create(:raif_test_user) } describe "index page" do let!(:conversations) { FB.create_list(:raif_test_conversation, 2, creator: creator) } it "displays a type sele...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/prompt_studio/agents_spec.rb
Ruby
mit
296
main
2,585
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::PromptStudio::Agents", type: :feature do let(:creator) { FB.create(:raif_test_user) } describe "index page" do let!(:agent) do FB.create( :raif_native_tool_calling_agent, creator: creator, task: "Test ta...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/stats/model_tool_invocations_spec.rb
Ruby
mit
296
main
5,805
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::Stats::ModelToolInvocations", type: :feature do let(:creator) { FB.create(:raif_test_user) } let(:task) { FB.create(:raif_test_task, creator: creator) } let(:conversation) { FB.create(:raif_conversation, creator: creator) } let(:conve...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/features/raif/admin/stats/tasks_spec.rb
Ruby
mit
296
main
5,418
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::Stats::Tasks", type: :feature do let(:creator) { FB.create(:raif_test_user) } describe "index page" do # Create tasks of different types with explicit llm_model_key values let!(:task1) { FB.create(:raif_test_task, creator: creato...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/shared_examples/open_ai_completions_tool_formatting.rb
Ruby
mit
296
main
2,045
# frozen_string_literal: true RSpec.shared_examples "an LLM that uses OpenAI's Completions API tool formatting" do describe "#build_tools_parameter" do let(:model_completion) do Raif::ModelCompletion.new( messages: [{ role: "user", content: "Hello" }], llm_model_key: "open_ai_gpt_4o", ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/shared_examples/agent.rb
Ruby
mit
296
main
1,538
# frozen_string_literal: true RSpec.shared_examples "an agent" do |_parameter| describe "validations" do it "validates presence of task" do agent = described_class.new( creator: creator, system_prompt: "System prompt", max_iterations: 5, available_model_tools: [Raif::TestMod...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/shared_examples/open_ai_completions_message_formatting.rb
Ruby
mit
296
main
3,402
# frozen_string_literal: true RSpec.shared_examples "an LLM that uses OpenAI's Completions API message formatting" do describe "#format_messages" do it "formats the messages correctly with a string as the content" do messages = [{ "role" => "user", "content" => "Hello" }] formatted_messages = llm.for...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/requests/raif/admin/prompt_studio/tasks_spec.rb
Ruby
mit
296
main
2,766
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::PromptStudio::Tasks", type: :request do let(:creator) { FB.create(:raif_test_user) } describe "POST /admin/prompt_studio/tasks" do let!(:task) { FB.create(:raif_test_task, :completed, creator: creator) } def post_create(llm_mode...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/requests/raif/admin/prompt_studio/batch_runs_spec.rb
Ruby
mit
296
main
5,376
# frozen_string_literal: true require "rails_helper" RSpec.describe "Admin::PromptStudio::BatchRuns", type: :request do let(:creator) { FB.create(:raif_test_user) } describe "POST /admin/prompt_studio/batch_runs" do let!(:task1) { FB.create(:raif_test_task, :completed, creator: creator) } let!(:task2) { ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/dummy/app/models/raif/test_user.rb
Ruby
mit
296
main
206
# frozen_string_literal: true class Raif::TestUser < ApplicationRecord has_one_attached :avatar has_many_attached :documents def preferred_language_key # no-op so we can stub in tests end end
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/dummy/app/models/raif/conversations/html_conversation_with_tools.rb
Ruby
mit
296
main
993
# frozen_string_literal: true module Raif module Conversations class HtmlConversationWithTools < Raif::ApplicationConversation llm_response_format :html before_create -> { self.available_model_tools = ["Raif::ModelTools::ProviderManaged::WebSearch"] } def system_prompt_intro <<~PROMPT...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/dummy/app/controllers/agents_controller.rb
Ruby
mit
296
main
659
# frozen_string_literal: true class AgentsController < ApplicationController def index end def create agent = Raif::Agents::NativeToolCallingAgent.new( task: params[:task], available_model_tools: [Raif::ModelTools::WikipediaSearch, Raif::ModelTools::FetchUrl], creator: current_user ) ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/dummy/app/controllers/application_controller.rb
Ruby
mit
296
main
384
# frozen_string_literal: true class ApplicationController < ActionController::Base # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. allow_browser versions: :modern # Used by Raif to get the current user def current_user @current_user ||= Raif::...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/dummy/app/controllers/chat_controller.rb
Ruby
mit
296
main
512
# frozen_string_literal: true class ChatController < ApplicationController def index conversation_type = params[:conversation_type] == "html" ? Raif::Conversations::HtmlConversationWithTools : Raif::Conversation # Find the latest conversation for this user or create a new one @conversation = conversation...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/dummy/db/schema.rb
Ruby
mit
296
main
11,495
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # This file is the source Rails uses to define your schema when running `bin/rai...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/dummy/db/migrate/20250430201231_create_active_storage_tables.active_storage.rb
Ruby
mit
296
main
2,205
# frozen_string_literal: true # This migration comes from active_storage (originally 20170806125915) class CreateActiveStorageTables < ActiveRecord::Migration[7.0] def change # Use Active Record's configured type for primary and foreign keys primary_key_type, foreign_key_type = primary_and_foreign_key_types ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/dummy/db/migrate/20250804015504_create_documents.rb
Ruby
mit
296
main
214
# frozen_string_literal: true class CreateDocuments < ActiveRecord::Migration[7.1] def change create_table :documents do |t| t.string :title t.text :content t.timestamps end end end
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/dummy/config/importmap.rb
Ruby
mit
296
main
308
# frozen_string_literal: true # Pin npm packages by running ./bin/importmap pin "application" pin "@hotwired/turbo-rails", to: "turbo.js" pin "@hotwired/stimulus", to: "stimulus.js" pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" pin_all_from "app/javascript/controllers", under: "controllers"
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/dummy/config/application.rb
Ruby
mit
296
main
1,085
# frozen_string_literal: true require_relative "boot" require "rails/all" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Dummy class Application < Rails::Application config.load_defaults Rails::VERSION::ST...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/dummy/config/routes.rb
Ruby
mit
296
main
818
# frozen_string_literal: true Rails.application.routes.draw do # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to ver...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/dummy/config/initializers/raif.rb
Ruby
mit
296
main
897
# frozen_string_literal: true Raif.configure do |config| # config.conversations_controller = "ConversationsController" # config.conversation_entries_controller = "ConversationEntriesController" # config.conversation_llm_messages_max_length_default = 50 config.anthropic_api_key = "placeholder" config.anthrop...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/dummy/config/initializers/assets.rb
Ruby
mit
296
main
393
# frozen_string_literal: true # Be sure to restart your server when you modify this file. # Rails 8 uses propshaft for the asset pipeline # Add additional assets to the asset load path if needed # Rails.application.config.assets.paths << Rails.root.join("node_modules") # Set an explicit assets prefix if needed (def...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/setup/capybara.rb
Ruby
mit
296
main
498
# frozen_string_literal: true require "capybara/cuprite" Capybara.javascript_driver = :cuprite Capybara.register_driver(:cuprite) do |app| headless = ENV["HEADLESS"] != "false" browser_options = { "no-sandbox": nil } opts = { browser_options: browser_options, flatten: false, process_timeout: 25, ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/setup/vcr.rb
Ruby
mit
296
main
4,158
# frozen_string_literal: true require "vcr" VCR.configure do |config| config.cassette_library_dir = "vcr_cassettes" config.hook_into :webmock config.configure_rspec_metadata! config.ignore_localhost = true # config.debug_logger = $stdout config.default_cassette_options = { match_requests_on: [ ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/lib/raif/migration_checker_spec.rb
Ruby
mit
296
main
4,469
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::MigrationChecker do describe ".uninstalled_migrations" do before do # Mock engine migration names allow(described_class).to receive(:engine_migration_names_from_context).and_return([ "CreateRaifTables", "AddRes...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/lib/raif/token_estimator_spec.rb
Ruby
mit
296
main
1,642
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::TokenEstimator do describe ".available?" do it "returns a boolean matching whether Tiktoken is defined" do if defined?(Tiktoken) expect(described_class.available?).to be true else expect(described_class.availab...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/lib/raif/messages_spec.rb
Ruby
mit
296
main
11,222
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Messages do describe Raif::Messages::UserMessage do describe "#initialize" do it "creates a message with content" do message = described_class.new(content: "Hello, world!") expect(message.content).to eq("Hello, world...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/lib/raif/utils/html_fragment_processor_spec.rb
Ruby
mit
296
main
17,732
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Utils::HtmlFragmentProcessor do describe ".clean_html_fragment" do context "when cleaning HTML content" do it "removes empty text nodes" do html = "<p>Hello</p> <div> </div><span>World</span>" result = described_cl...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/lib/raif/evals/run_spec.rb
Ruby
mit
296
main
7,679
# frozen_string_literal: true require "rails_helper" require "fileutils" RSpec.describe Raif::Evals::Run do let(:test_eval_set) do Class.new(Raif::Evals::EvalSet) do eval "passes" do expect "always true" do true end end eval "fails" do expect "always false" d...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/lib/raif/evals/expectation_result_spec.rb
Ruby
mit
296
main
2,470
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Evals::ExpectationResult do describe "#initialize" do it "creates an expectation result with passed status" do result = described_class.new(description: "test passes", status: :passed) expect(result.description).to eq("test p...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/lib/raif/evals/eval_spec.rb
Ruby
mit
296
main
2,909
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Evals::Eval do describe "#initialize" do it "creates an eval with description and empty expectation results" do eval = described_class.new(description: "test eval") expect(eval.description).to eq("test eval") expect(eva...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/lib/raif/evals/scoring_rubric_spec.rb
Ruby
mit
296
main
4,624
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Evals::ScoringRubric do describe "#initialize" do it "creates a scoring rubric with name, description, and levels" do rubric = described_class.new( name: :test_rubric, description: "Test rubric description", ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/lib/raif/evals/eval_set_spec.rb
Ruby
mit
296
main
10,145
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Evals::EvalSet do let(:test_eval_set_class) do Class.new(described_class) do setup do @setup_called = true end teardown do @teardown_called = true end eval "test passes" do expect "a...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/lib/raif/evals/eval_sets/llm_judge_expectations_spec.rb
Ruby
mit
296
main
11,036
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Evals::EvalSets::LlmJudgeExpectations do let(:test_eval_set_class) do Class.new(Raif::Evals::EvalSet) do def self.name "TestEvalSet" end def initialize(output: $stdout) super @current_eval = Rai...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/support/test_conversation.rb
Ruby
mit
296
main
394
# frozen_string_literal: true class Raif::TestConversation < Raif::Conversation before_create :populate_available_model_tools def populate_available_model_tools self.available_model_tools = [ "Raif::TestModelTool", "Raif::ModelTools::WikipediaSearch", ] end def process_model_response_mes...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/support/complex_test_tool.rb
Ruby
mit
296
main
1,977
# frozen_string_literal: true class Raif::ModelTools::ComplexTestTool < Raif::ModelTool tool_arguments_schema do string :title, description: "The title of the operation", minLength: 3 object :settings, description: "Configuration settings" do boolean :enabled, description: "Whether the tool is enabled...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/support/test_template_task.rb
Ruby
mit
296
main
787
# frozen_string_literal: true class Raif::TestTemplateTask < Raif::Task run_with :topic after_initialize -> { self.topic ||= "pirates" } def topic_description "the topic of #{topic}" end end class Raif::TestTemplateSystemPromptTask < Raif::Task run_with :persona after_initialize -> { self.persona |...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/support/test_embedding_model.rb
Ruby
mit
296
main
703
# frozen_string_literal: true module Raif module EmbeddingModels class Test < Raif::EmbeddingModel attr_accessor :embedding_handler def generate_embedding!(input, dimensions: nil) if input.is_a?(Array) input.map { |text| generate_test_embedding!(text, dimensions:) } else ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/support/test_model_tool.rb
Ruby
mit
296
main
718
# frozen_string_literal: true class Raif::TestModelTool < Raif::ModelTool tool_arguments_schema do array :items do object do string :title, description: "The title of the item" string :description end end end example_model_invocation do { "name": tool_name, "a...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/support/test_task.rb
Ruby
mit
296
main
1,129
# frozen_string_literal: true class Raif::TestTask < Raif::Task llm_temperature 0.5 def build_prompt "Tell me a joke" end def build_system_prompt super + "\nYou are also good at telling jokes." end end class Raif::TestJsonTask < Raif::Task llm_response_format :json llm_temperature 0.75 json...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/support/current_temperature_test_tool.rb
Ruby
mit
296
main
848
# frozen_string_literal: true class Raif::ModelTools::CurrentTemperatureTestTool < Raif::ModelTool tool_arguments_schema do string :zip_code, description: "The zip code to get the current temperature for" end tool_description do "A tool to get the current temperature for a given zip code" end class...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/support/test_llm.rb
Ruby
mit
296
main
712
# frozen_string_literal: true module Raif module Llms class TestLlm < Raif::Llm include Raif::Concerns::Llms::OpenAiCompletions::MessageFormatting attr_accessor :chat_handler def perform_model_completion!(model_completion) result = chat_handler.call(model_completion.messages, model_co...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/support/rspec_helpers.rb
Ruby
mit
296
main
2,460
# frozen_string_literal: true module Raif module RspecHelpers def stubbed_llm(llm_model_key, source_instance, &block) test_llm = Raif.llm(llm_model_key.to_sym) allow(test_llm).to receive(:perform_model_completion!) do |model_completion, &streaming_block| result = block.call(model_completion...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/embedding_model_spec.rb
Ruby
mit
296
main
2,077
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::EmbeddingModel, type: :model do it "generates test embeddings" do model = Raif.embedding_model(:raif_test_embedding_model) embedding = model.generate_embedding!("Hello, world!") expect(embedding).to be_a(Array) expect(embeddin...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/conversation_spec.rb
Ruby
mit
296
main
15,810
# frozen_string_literal: true # == Schema Information # # Table name: raif_conversations # # id :bigint not null, primary key # available_model_tools :jsonb not null # available_user_tools :jsonb not null # conversation_entries_count :integer ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/model_tool_spec.rb
Ruby
mit
296
main
2,499
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::ModelTool, type: :model do describe ".prepare_tool_arguments" do it "strips unknown keys from arguments" do result = Raif::TestModelTool.prepare_tool_arguments({ "items" => [{ "title" => "foo", "description" => "bar" }], ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/prompt_studio_batch_run_item_spec.rb
Ruby
mit
296
main
12,927
# frozen_string_literal: true # == Schema Information # # Table name: raif_prompt_studio_batch_run_items # # id :bigint not null, primary key # metadata :jsonb # status :string default("pending"), not null # created_at :datetime not null # updated_at :...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/model_image_input_spec.rb
Ruby
mit
296
main
4,491
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::ModelImageInput, type: :model do let(:file_path) { Raif::Engine.root.join("spec/fixtures/files/cultivate.png") } let(:base64_string) { Base64.strict_encode64(File.binread(file_path)) } it "requires either an input or a URL" do expect...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/model_file_input_spec.rb
Ruby
mit
296
main
4,488
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::ModelFileInput, type: :model do let(:file_path) { Raif::Engine.root.join("spec/fixtures/files/test.pdf") } let(:base64_string) { Base64.strict_encode64(File.binread(file_path)) } it "requires either an input or a URL" do expect { des...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/llm_spec.rb
Ruby
mit
296
main
18,737
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Llm, type: :model do describe "#chat" do let(:messages) { [{ role: "user", content: "Hello" }] } let(:system_prompt) { "You are a helpful assistant." } let(:test_llm) do Raif::Llms::TestLlm.new(key: :raif_test_llm, api_name...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/conversation_entry_spec.rb
Ruby
mit
296
main
20,957
# frozen_string_literal: true # == Schema Information # # Table name: raif_conversation_entries # # id :bigint not null, primary key # completed_at :datetime # creator_type :string not null # failed_at :datetime # model_response_message :tex...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/prompt_studio_batch_run_spec.rb
Ruby
mit
296
main
7,143
# frozen_string_literal: true # == Schema Information # # Table name: raif_prompt_studio_batch_runs # # id :bigint not null, primary key # completed_at :datetime # completed_count :integer default(0), not null # failed_at :datetime # failed_count :in...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/model_completion_spec.rb
Ruby
mit
296
main
25,010
# frozen_string_literal: true # == Schema Information # # Table name: raif_model_completions # # id :bigint not null, primary key # available_model_tools :jsonb not null # cache_creation_input_tokens :integer # cache_read_input_tokens :integer # citations ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/task_spec.rb
Ruby
mit
296
main
20,340
# frozen_string_literal: true # == Schema Information # # Table name: raif_tasks # # id :bigint not null, primary key # available_model_tools :jsonb not null # completed_at :datetime # creator_type :string # failed_at :datetime # llm_mode...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/model_tool_invocation_spec.rb
Ruby
mit
296
main
6,035
# frozen_string_literal: true # == Schema Information # # Table name: raif_model_tool_invocations # # id :bigint not null, primary key # completed_at :datetime # failed_at :datetime # result :jsonb not null # source_type :string...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/task_run_args_spec.rb
Ruby
mit
296
main
8,605
# frozen_string_literal: true require "rails_helper" RSpec.describe "Raif::Task run_with", type: :model do # Create a test task class with run_with before do stub_const("Raif::TaskRunArgsTestTask", Class.new(Raif::Task) do run_with :conversation run_with :user run_with :options run_wit...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/json_schema_builder_spec.rb
Ruby
mit
296
main
6,897
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::JsonSchemaBuilder do subject(:builder) { described_class.new } describe "#string" do it "adds a string property" do builder.string "name", description: "User name" schema = builder.to_schema expect(schema[:properties...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/concerns/has_prompt_templates_spec.rb
Ruby
mit
296
main
5,391
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Concerns::HasPromptTemplates do describe "template resolution for tasks" do context "when a .prompt.erb template exists" do it "uses the template to build the prompt" do task = Raif::TestTemplateTask.new(topic: "cats") ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/concerns/llm_response_parsing_spec.rb
Ruby
mit
296
main
11,575
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Concerns::LlmResponseParsing do describe "llm_response_allowed_tags" do it "allows the specified tags" do expect(Raif::TestHtmlTask.allowed_tags).to eq(%w[p b i u s a]) end it "strips tags that are not allowed" do tas...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/concerns/json_schema_definition_spec.rb
Ruby
mit
296
main
16,144
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Concerns::JsonSchemaDefinition do # Test class for instance-dependent schemas class TestInstanceDependentTask < Raif::Task attr_accessor :include_extra_field, :detail_level json_response_schema do |task| string "name", descri...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/concerns/tool_call_validation_spec.rb
Ruby
mit
296
main
4,203
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Concerns::ToolCallValidation do let(:validator) do Class.new do include Raif::Concerns::ToolCallValidation end.new end let(:tool_map) do { Raif::TestModelTool.tool_name => Raif::TestModelTool } end descri...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/concerns/llm_prompt_caching_spec.rb
Ruby
mit
296
main
795
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Concerns::LlmPromptCaching do describe ".enable_anthropic_prompt_caching" do it "sets anthropic_prompt_caching_enabled to true" do expect(Raif::TestCachedTask.anthropic_prompt_caching_enabled).to be(true) end it "defaults t...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/model_tools/wikipedia_search_spec.rb
Ruby
mit
296
main
343
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::ModelTools::WikipediaSearch do describe "#tool_arguments_schema" do it "validates against OpenAI's rules" do llm = Raif.llm(:open_ai_gpt_4o_mini) expect(llm.validate_json_schema!(described_class.tool_arguments_schema)).to eq(t...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/model_tools/fetch_url_spec.rb
Ruby
mit
296
main
336
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::ModelTools::FetchUrl do describe "#tool_arguments_schema" do it "validates against OpenAI's rules" do llm = Raif.llm(:open_ai_gpt_4o_mini) expect(llm.validate_json_schema!(described_class.tool_arguments_schema)).to eq(true) ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/model_tools/agent_final_answer_spec.rb
Ruby
mit
296
main
344
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::ModelTools::AgentFinalAnswer do describe "#tool_arguments_schema" do it "validates against OpenAI's rules" do llm = Raif.llm(:open_ai_gpt_4o_mini) expect(llm.validate_json_schema!(described_class.tool_arguments_schema)).to eq(...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/evals/llm_judge_spec.rb
Ruby
mit
296
main
4,883
# frozen_string_literal: true # == Schema Information # # Table name: raif_tasks # # id :bigint not null, primary key # available_model_tools :jsonb not null # completed_at :datetime # creator_type :string # failed_at :datetime # llm_mode...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/evals/llm_judges/summarization_spec.rb
Ruby
mit
296
main
14,523
# frozen_string_literal: true # == Schema Information # # Table name: raif_tasks # # id :bigint not null, primary key # available_model_tools :jsonb not null # completed_at :datetime # creator_type :string # failed_at :datetime # llm_mode...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/evals/llm_judges/binary_spec.rb
Ruby
mit
296
main
7,182
# frozen_string_literal: true # == Schema Information # # Table name: raif_tasks # # id :bigint not null, primary key # available_model_tools :jsonb not null # completed_at :datetime # creator_type :string # failed_at :datetime # llm_mode...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/evals/llm_judges/comparative_spec.rb
Ruby
mit
296
main
8,136
# frozen_string_literal: true # == Schema Information # # Table name: raif_tasks # # id :bigint not null, primary key # available_model_tools :jsonb not null # completed_at :datetime # creator_type :string # failed_at :datetime # llm_mode...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/evals/llm_judges/scored_spec.rb
Ruby
mit
296
main
5,305
# frozen_string_literal: true # == Schema Information # # Table name: raif_tasks # # id :bigint not null, primary key # available_model_tools :jsonb not null # completed_at :datetime # creator_type :string # failed_at :datetime # llm_mode...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/llms/open_ai_completions_spec.rb
Ruby
mit
296
main
23,007
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Llms::OpenAiCompletions, type: :model do it_behaves_like "an LLM that uses OpenAI's Completions API message formatting" it_behaves_like "an LLM that uses OpenAI's Completions API tool formatting" let(:llm){ Raif.llm(:open_ai_gpt_4o) } ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/llms/open_ai_responses_spec.rb
Ruby
mit
296
main
40,259
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Llms::OpenAiResponses, type: :model do let(:llm){ Raif.llm(:open_ai_responses_gpt_4o) } before do allow(Raif.config).to receive(:llm_api_requests_enabled){ true } end describe "#chat" do context "when the response format is te...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/llms/anthropic_spec.rb
Ruby
mit
296
main
37,243
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Llms::Anthropic, type: :model do let(:llm){ Raif.llm(:anthropic_claude_3_5_haiku) } let(:stubs) { Faraday::Adapter::Test::Stubs.new } let(:test_connection) do Faraday.new do |builder| builder.adapter :test, stubs builder....
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/llms/open_router_spec.rb
Ruby
mit
296
main
24,236
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Llms::OpenRouter, type: :model do it_behaves_like "an LLM that uses OpenAI's Completions API message formatting" it_behaves_like "an LLM that uses OpenAI's Completions API tool formatting" let(:llm){ Raif.llm(:open_router_llama_3_1_8b_in...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/llms/google_spec.rb
Ruby
mit
296
main
43,527
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Llms::Google, type: :model do let(:llm) { Raif.llm(:google_gemini_2_5_flash) } before do allow(Raif.config).to receive(:llm_api_requests_enabled) { true } allow(Raif.config).to receive(:google_models_enabled) { true } allow(Rai...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/llms/bedrock_spec.rb
Ruby
mit
296
main
33,681
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::Llms::Bedrock, type: :model do let(:llm){ Raif.llm(:bedrock_claude_3_5_sonnet) } before do allow(Raif.config).to receive(:llm_api_requests_enabled){ true } allow(Raif.config).to receive(:bedrock_models_enabled).and_return(true) ...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/streaming_responses/bedrock_spec.rb
Ruby
mit
296
main
7,008
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::StreamingResponses::Bedrock, type: :model do subject(:streaming_response) { described_class.new } let(:llm_key) { :test_bedrock_streaming_llm } let(:llm_api_name) { "test-bedrock-model" } let(:llm) { Raif::Llms::Bedrock.new(key: llm_ke...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/agents/native_tool_calling_agent_anthropic_spec.rb
Ruby
mit
296
main
15,474
# frozen_string_literal: true # == Schema Information # # Table name: raif_agents # # id :bigint not null, primary key # available_model_tools :jsonb not null # completed_at :datetime # conversation_history :jsonb not null # creator_type :...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/agents/native_tool_calling_agent_spec.rb
Ruby
mit
296
main
27,974
# frozen_string_literal: true # == Schema Information # # Table name: raif_agents # # id :bigint not null, primary key # available_model_tools :jsonb not null # completed_at :datetime # conversation_history :jsonb not null # creator_type :...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/agents/native_tool_calling_agent_open_router_spec.rb
Ruby
mit
296
main
18,334
# frozen_string_literal: true # == Schema Information # # Table name: raif_agents # # id :bigint not null, primary key # available_model_tools :jsonb not null # completed_at :datetime # conversation_history :jsonb not null # creator_type :...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/agents/native_tool_calling_agent_open_ai_responses_spec.rb
Ruby
mit
296
main
13,917
# frozen_string_literal: true # == Schema Information # # Table name: raif_agents # # id :bigint not null, primary key # available_model_tools :jsonb not null # completed_at :datetime # conversation_history :jsonb not null # creator_type :...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/agents/native_tool_calling_agent_bedrock_spec.rb
Ruby
mit
296
main
17,705
# frozen_string_literal: true # == Schema Information # # Table name: raif_agents # # id :bigint not null, primary key # available_model_tools :jsonb not null # completed_at :datetime # conversation_history :jsonb not null # creator_type :...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/embedding_models/google_spec.rb
Ruby
mit
296
main
4,468
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::EmbeddingModels::Google, type: :model do let(:model) { Raif.embedding_model(:google_gemini_embedding_2) } let(:stubs) { Faraday::Adapter::Test::Stubs.new } let(:test_connection) do Faraday.new do |builder| builder.adapter :test,...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/embedding_models/open_ai_spec.rb
Ruby
mit
296
main
6,156
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::EmbeddingModels::OpenAi, type: :model do let(:model) { Raif.embedding_model(:open_ai_text_embedding_3_small) } let(:stubs) { Faraday::Adapter::Test::Stubs.new } let(:test_connection) do Faraday.new do |builder| builder.adapter :...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
spec/models/raif/embedding_models/bedrock_spec.rb
Ruby
mit
296
main
3,711
# frozen_string_literal: true require "rails_helper" RSpec.describe Raif::EmbeddingModels::Bedrock, type: :model do let(:model) { Raif.embedding_model(:bedrock_titan_embed_text_v2) } let(:client) { Aws::BedrockRuntime::Client.new(stub_responses: true) } let(:mock_response) { double("MockResponse") } before d...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
config/importmap.rb
Ruby
mit
296
main
928
# frozen_string_literal: true pin "raif", to: "raif.js" pin "raif_admin", to: "raif_admin.js" pin "raif/controllers/conversations_controller", to: "raif/controllers/conversations_controller.js" pin "raif/admin/judge_config_controller", to: "raif/admin/judge_config_controller.js" pin "raif/admin/select_all_checkboxes_...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
config/routes.rb
Ruby
mit
296
main
1,242
# frozen_string_literal: true Raif::Engine.routes.draw do resources :conversations, only: [:index, :show], controller: "/#{Raif.config.conversations_controller.constantize.controller_path}" do resources :conversation_entries, only: [:new, :create], as: :entries, path: "entries", c...
github
CultivateLabs/raif
https://github.com/CultivateLabs/raif
config/initializers/pagy.rb
Ruby
mit
296
main
649
# frozen_string_literal: true # Pagy initializer file # See https://ddnexus.github.io/pagy/api/pagy#backend # Optionally override some pagy default options # Pagy::DEFAULT[:items] = 20 # items per page # Pagy::DEFAULT[:size] = [1,4,4,1] # nav bar links # When you are done setting your own default freeze it, ...