File size: 1,443 Bytes
097eaf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# frozen_string_literal: true

module Firecrawl
  module Models
    # Question format for asking a question about page content.
    class QuestionFormat
      attr_reader :question

      def initialize(question:)
        @question = question
      end

      def to_h
        {
          "type" => "question",
          "question" => question,
        }
      end

      def type
        "question"
      end
    end

    # Highlights format for extracting direct highlights from page content.
    class HighlightsFormat
      attr_reader :query

      def initialize(query:)
        @query = query
      end

      def to_h
        {
          "type" => "highlights",
          "query" => query,
        }
      end

      def type
        "highlights"
      end
    end

    # Deprecated query format for asking a question about page content.
    class QueryFormat
      MODE_FREEFORM = "freeform"
      MODE_DIRECT_QUOTE = "directQuote"

      attr_reader :prompt, :mode

      def initialize(prompt:, mode: nil)
        unless mode.nil? || [MODE_FREEFORM, MODE_DIRECT_QUOTE].include?(mode)
          raise ArgumentError, "query mode must be 'freeform' or 'directQuote'"
        end

        @prompt = prompt
        @mode = mode
      end

      def to_h
        {
          "type" => "query",
          "prompt" => prompt,
          "mode" => mode,
        }.compact
      end

      def type
        "query"
      end
    end
  end
end