Sha256: 25f5c66c53fb1e9af4dbce981a8730101d0b378b0bb0f96caffb861a2c3100d4

Contents?: true

Size: 762 Bytes

Versions: 3

Compression:

Stored size: 762 Bytes

Contents

require "active_support/concern"

module Groq::Helpers
  extend ActiveSupport::Concern
  included do
    def U(content)
      {role: "user", content: content}
    end
    alias_method :User, :U

    def A(content)
      {role: "assistant", content: content}
    end
    alias_method :Assistant, :A

    def S(content, json_schema: nil)
      if json_schema
        content += "\nJSON must use schema: #{json_schema}"
      end
      {role: "system", content: content}
    end
    alias_method :System, :S

    def T(content, tool_call_id:, name:)
      {role: "function", tool_call_id: tool_call_id, name: name, content: content}
    end
    alias_method :Tool, :T
    alias_method :ToolReply, :T
    alias_method :Function, :T
    alias_method :F, :T
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
groq-0.3.2 lib/groq/helpers.rb
groq-0.3.1 lib/groq/helpers.rb
groq-0.3.0 lib/groq/helpers.rb