Commit 3df4a80

mo khan <mo@mokhan.ca>
2025-08-15 00:09:44
feat: normalize the data before adding it to the conversation
1 parent c76358b
Changed files (1)
lib/elelem/conversation.rb
@@ -21,7 +21,7 @@ module Elelem
       if @items.last && @items.last[:role] == role
         @items.last[:content] += content
       else
-        @items.push({ role: role, content: content })
+        @items.push({ role: role, content: normalize(content) })
       end
     end
 
@@ -30,5 +30,13 @@ module Elelem
     def system_prompt
       ERB.new(Pathname.new(__dir__).join("system_prompt.erb").read).result(binding)
     end
+
+    def normalize(content)
+      if content.is_a?(Array)
+        content.join(", ")
+      else
+        content.to_s
+      end
+    end
   end
 end