Skip to content

Releases: drnic/groq-ruby

v0.3.1 - rails generator

05 May 08:02
Compare
Choose a tag to compare

Thanks to @bugloper for adding a Rails installer.

v0.3.0 - streaming

25 Apr 09:13
Compare
Choose a tag to compare

In this release we add some options for receiving streaming chunks from Groq API, rather than blocking until the entire response is ready. This is lovely when your end user is waiting patiently for feedback.

There is nice simple option to pass a block to chat() and receive each chunk as simple text:

@client.chat("Write a long poem about patience") do |content|
  print content
end

Or you can use an object with a call(content) method:

class MessageBits
  def initialize(emoji)
    print "#{emoji} "
    @bits = []
  end

  def call(content)
    if content.nil?
      puts
    else
      print(content)
      @bits << content
    end
  end

  def to_s
    @bits.join("")
  end

  def to_assistant_message
    Assistant(to_s)
  end
end

bits = MessageBits.new("🍕")
@client.chat("Write a long poem about pizza", stream: bits)

In both modes, you can pass an optional 2nd argument to receive the original chunk returned from the Groq API.