Releases: drnic/groq-ruby
Releases · drnic/groq-ruby
v0.3.2 - allow faraday v1 and v2 dependency
Thanks @itstheraj PR 16 for lowering the requirement on faraday gem to 1+ and 2+ version.
v0.3.1 - rails generator
Thanks to @bugloper for adding a Rails installer.
v0.3.0 - streaming
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.