Class: GroqRuby::Resources::Chat::Completions
- Defined in:
- lib/groq_ruby/resources/chat/completions.rb
Overview
‘client.chat.completions.create(…)` — the workhorse of the API. Supports both buffered and Server-Sent-Events streaming responses.
Constant Summary collapse
- PATH =
"/openai/v1/chat/completions".freeze
- SCHEMA =
Dry::Schema.define do required(:model).filled(:string) required(:messages).value(:array, min_size?: 1) optional(:temperature).filled(:float, gteq?: 0.0, lteq?: 2.0) optional(:top_p).filled(:float, gteq?: 0.0, lteq?: 1.0) optional(:n).filled(:integer, gt?: 0) optional(:max_tokens).filled(:integer, gt?: 0) optional(:max_completion_tokens).filled(:integer, gt?: 0) optional(:presence_penalty).filled(:float, gteq?: -2.0, lteq?: 2.0) optional(:frequency_penalty).filled(:float, gteq?: -2.0, lteq?: 2.0) optional(:seed).filled(:integer) optional(:stop) optional(:stream).filled(:bool) optional(:user).maybe(:string) optional(:tools).value(:array) optional(:tool_choice) optional(:response_format).value(:hash) optional(:logprobs).filled(:bool) optional(:top_logprobs).filled(:integer, gteq?: 0, lteq?: 20) optional(:reasoning_effort).filled(:string, included_in?: %w[none default low medium high]) optional(:reasoning_format).filled(:string, included_in?: %w[hidden raw parsed]) optional(:service_tier).filled(:string, included_in?: %w[auto on_demand flex performance]) optional(:parallel_tool_calls).filled(:bool) optional(:logit_bias).value(:hash) optional(:metadata).value(:hash) end
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from GroqRuby::Resources::Base
Instance Method Details
#create(stream: false, **params) {|chunk| ... } ⇒ GroqRuby::Models::ChatCompletion, GroqRuby::Streaming::ChunkStream
67 68 69 70 71 72 73 74 |
# File 'lib/groq_ruby/resources/chat/completions.rb', line 67 def create(stream: false, **params, &block) body = validate!(SCHEMA, params.merge(stream: stream)) if stream stream_response(body, &block) else buffered_response(body) end end |