-
Notifications
You must be signed in to change notification settings - Fork 140
Description
name: 🐛 Bug Report
about: Create a report to help us improve FireForm.
title: "[BUG]: AttributeError when adding multiple values to the same JSON field"
labels: bug
assignees: ''
⚡️ Describe the Bug
In src/llm.py, the add_response_to_json method throws an AttributeError when attempting to add a second value to an already existing key in the parsed JSON dictionary. The code assumes that if the key exists, it is a list and calls .append(). However, the initial value is stored as a string (or extracted scalar), not a list, causing the application to crash with AttributeError: 'str' object has no attribute 'append'.
👣 Steps to Reproduce
- Initialize the
LLMclass fromsrc/llm.py. - Call
llm.add_response_to_json("my_field", "first_value"). The internal dictionary becomes{"my_field": "first_value"}. - Call
llm.add_response_to_json("my_field", "second_value"). - See error:
AttributeError: 'str' object has no attribute 'append'.
📉 Expected Behavior
When a second value is added to an existing key, the code should gracefully handle it by converting the existing string value into a list containing both the old and new values, or the initial insertion should automatically instantiate a list.
🖥️ Environment Information
- OS: macOS
- Docker/Compose Version: N/A
- Ollama Model used: mistral (default in
main_loop)
📸 Screenshots/Logs
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/src/llm.py", line 102, in add_response_to_json
self._json[field].append(parsed_value)
AttributeError: 'str' object has no attribute 'append'