Skip to content

Commit

Permalink
Fix context = nil.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed May 8, 2024
1 parent 2185654 commit a6a1855
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/chatbot/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ def update_conversation(prompt)
Console.info(self, "Updating conversation", id: conversation.id, prompt: prompt)

Async::Ollama::Client.open do |client|
previous_context = conversation.context

conversation_message = conversation.conversation_messages.create!(prompt: prompt, response: String.new)

self.append(".conversation .messages") do |builder|
self.render_message(builder, conversation_message)
end

generate = client.generate(prompt, context: conversation.context) do |response|
generate = client.generate(prompt, context: previous_context) do |response|
response.body.each do |token|
conversation_message.response += token

Expand Down

0 comments on commit a6a1855

Please sign in to comment.