Module: LLM::Anthropic::Response::WebSearch

Defined in:
lib/llm/providers/anthropic/response/web_search.rb

Overview

The LLM::Anthropic::Response::WebSearch module provides methods for accessing web search results from a web search tool call made via the LLM::Provider#web_search method.

Instance Method Summary collapse

Instance Method Details

#search_resultsArray<LLM::Object>

Returns one or more search results

Returns:



13
14
15
16
17
18
19
# File 'lib/llm/providers/anthropic/response/web_search.rb', line 13

def search_results
  LLM::Object.from_hash(
    content
      .select { _1["type"] == "web_search_tool_result" }
      .flat_map { |n| n.content.map { _1.slice(:title, :url) } }
  )
end