Class: Raif::ModelTools::FetchUrl
- Inherits:
-
Raif::ModelTool
- Object
- Raif::ModelTool
- Raif::ModelTools::FetchUrl
- Defined in:
- app/models/raif/model_tools/fetch_url.rb
Class Method Summary collapse
- .format_result_for_llm(invocation) ⇒ Object
- .process_invocation(tool_invocation) ⇒ Object
- .triggers_immediate_llm_follow_up?(_invocation) ⇒ Boolean
Class Method Details
.format_result_for_llm(invocation) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/models/raif/model_tools/fetch_url.rb', line 20 def format_result_for_llm(invocation) return "No results found" unless invocation.result.present? <<~RESULT Result Status: #{invocation.result["status"]} Result Content: #{invocation.result["content"]} RESULT end |
.process_invocation(tool_invocation) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/raif/model_tools/fetch_url.rb', line 34 def process_invocation(tool_invocation) url = tool_invocation.tool_arguments["url"] response = Faraday.get(url) readable_content = Raif::Utils::ReadableContentExtractor.new(response.body).extract_readable_content markdown_content = Raif::Utils::HtmlToMarkdownConverter.convert(readable_content) tool_invocation.update!( result: { status: response.status, content: markdown_content } ) tool_invocation.result end |
.triggers_immediate_llm_follow_up?(_invocation) ⇒ Boolean
30 31 32 |
# File 'app/models/raif/model_tools/fetch_url.rb', line 30 def triggers_immediate_llm_follow_up?(_invocation) true end |