### Install deepsearch-rb Gem Source: https://github.com/alexshagov/deepsearch-rb/blob/main/README.md Instructions for installing the deepsearch-rb gem using Bundler in a Ruby project. It also shows how to install from a local path. ```ruby # Gemfile gem 'deepsearch-rb' # .. bundle install ``` ```bash gem 'deepsearch-rb', path: '' ``` -------------------------------- ### Perform Deepsearch with Max Results Configuration Source: https://github.com/alexshagov/deepsearch-rb/blob/main/README.md Shows an example of calling the `Deepsearch.search` method with a specific option to limit the maximum total number of search results returned. ```ruby result = Deepsearch.search("Ruby 3 unknown features", max_total_search_results: 25) ``` -------------------------------- ### Configure deepsearch-rb with Minimal Settings Source: https://github.com/alexshagov/deepsearch-rb/blob/main/README.md Demonstrates the minimal configuration for the deepsearch-rb gem, including setting the search adapter, API keys for Tavily and Serper, and LLM configurations from the ruby_llm gem. ```ruby Deepsearch.configure do |config| config.search_adapter = :tavily # or :serper, :mock config.tavily_api_key = "your_tavily_api_key" config.serper_api_key = "your_serper_api_key" # LLM configuration (all config options are coming from `ruby_llm` gem), # you can experiment with any model you like config.ruby_llm.gemini_api_key = ENV['GEMINI_API_KEY'] config.ruby_llm.default_model = 'gemini-2.0-flash-lite' config.ruby_llm.default_embedding_model = 'text-embedding-004' # .. end ``` -------------------------------- ### Configure deepsearch-rb with Custom Prompts Source: https://github.com/alexshagov/deepsearch-rb/blob/main/README.md Illustrates how to override default prompts in deepsearch-rb by creating a custom class that inherits from `Deepsearch::PromptsConfig` and defining methods for specific prompts, such as `subquery_prompt`. ```ruby class MyPromptsConfig < Deepsearch::PromptsConfig def subquery_prompt(query:) <<~PROMPT You are a search expert. Given this query: "#{query}", generate 3 alternative search queries that would help find more information. Return them as a simple list, one per line. PROMPT end # Override other prompt methods as needed end Deepsearch.configure { |config| config.prompts_config = MyPromptsConfig.new } ``` -------------------------------- ### Configure deepsearch-rb with Event Listener Source: https://github.com/alexshagov/deepsearch-rb/blob/main/README.md Demonstrates how to set up a custom event listener for deepsearch-rb. The listener class should implement the `on_deepsearch_event` method to receive and process events during the search process. ```ruby class MyListener def on_deepsearch_event(event, step:, result:) puts "Event: #{event}, Step: #{step}, Success: #{result.success?}" end end Deepsearch.configure { |c| c.listener = MyListener.new } ``` -------------------------------- ### Configure deepsearch-rb with Custom Search Adapter Source: https://github.com/alexshagov/deepsearch-rb/blob/main/README.md Shows how to configure deepsearch-rb to use a custom search adapter by defining a class that implements the search logic and then setting it in the configuration. ```ruby class MyCustomAdapter def initialize;end def search(query, options = {}) # Implement your search logic here { "results" => [ { "url" => "https://example.com/result1", "content" => "Content 1 from custom search" } ] } end end Deepsearch.configure { |config| config.custom_search_adapter_class = MyCustomAdapter } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.