devika
devika copied to clipboard
Update coder.py
this code reduce file i/0 operations like minimizing file operations by writing the code directly without splitting and joining.. and it also implements better error handling to handle unexpected responses from the model.. and streamline the looping and sleeping mechanisms to avoid unnecessary delays..
Hey. thanks for helping out. I am working on refactoring these classes at https://github.com/stitionai/devika/pull/242 . Do you mind holding these changes until then?
sure
I think this is the case that generate this error: I only have it on Windows laptop, ubuntu server run normally.
project='python005' id=5 state_stack_json='[{"internal_monologue": null, "browser_session": {"url": null, "screenshot": null}, "terminal_session": {"command": null, "output": null, "title": null}, "step": null, "message": null, "completed": false, "agent_is_active": true, "token_usage": 1116, "timestamp": "2024-03-29 23:47:58"}, {"internal_monologue": "Researching Pygame documentation to understand its structure for creating games.", "browser_session": {"url": null, "screenshot": null}, "terminal_session": {"command": null, "output": null, "title": null}, "step": null, "message": null, "completed": false, "agent_is_active": true, "token_usage": 947, "timestamp": "2024-03-29 23:48:16"}, {"internal_monologue": "Browsing the web right now...", "browser_session": {"url": "https://www.techwithtim.net/tutorials/game-development-with-python/pygame-tutorial/pygame-tutorial-movement", "screenshot": "screenshots\\\\be6c056f6071d39ffcfb33de688d5961922c3d47.png"}, "terminal_session": {"command": null, "output": null, "title": null}, "step": null, "message": null, "completed": false, "agent_is_active": true, "token_usage": 1843, "timestamp": "2024-03-29 23:48:26"}, {"internal_monologue": "Browsing the web right now...", "browser_session": {"url": "https://www.geeksforgeeks.org/collision-detection-in-pygame/", "screenshot": "screenshots\\\\0d6fc49f63e27aa7606056d52aa0ac7832d9bc09.png"}, "terminal_session": {"command": null, "output": null, "title": null}, "step": null, "message": null, "completed": false, "agent_is_active": true, "token_usage": 3701, "timestamp": "2024-03-29 23:48:36"}, {"internal_monologue": "Browsing the web right now...", "browser_session": {"url": "https://dev.to/emilossola/step-by-step-guide-to-build-python-snake-game-with-pygame-4bp", "screenshot": "screenshots\\\\d33f726d5f578e88825cf40e56d350f56336c953.png"}, "terminal_session": {"command": null, "output": null, "title": null}, "step": null, "message": null, "completed": false, "agent_is_active": true, "token_usage": 7225, "timestamp": "2024-03-29 23:48:45"}]'
Exception in thread Thread-518 (<lambda>):
Traceback (most recent call last):
File "C:\Users\Nicolas\miniconda3\envs\devika001\Lib\threading.py", line 1045, in _bootstrap_inner
self.run()
File "C:\Users\Nicolas\miniconda3\envs\devika001\Lib\threading.py", line 982, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Nicolas\Documents\devika\devika.py", line 52, in <lambda>
target=lambda: Agent(base_model=base_model).execute(prompt, project_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nicolas\Documents\devika\src\agents\agent.py", line 340, in execute
code = self.coder.execute(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nicolas\Documents\devika\src\agents\coder\coder.py", line 107, in execute
valid_response = self.validate_response(response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Nicolas\Documents\devika\src\agents\coder\coder.py", line 34, in validate_response
response = response.split("~~~", 1)[1]
~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
I think this is the case that generate this error: I only have it on Windows laptop, ubuntu server run normally.
project='python005' id=5 state_stack_json='[{"internal_monologue": null, "browser_session": {"url": null, "screenshot": null}, "terminal_session": {"command": null, "output": null, "title": null}, "step": null, "message": null, "completed": false, "agent_is_active": true, "token_usage": 1116, "timestamp": "2024-03-29 23:47:58"}, {"internal_monologue": "Researching Pygame documentation to understand its structure for creating games.", "browser_session": {"url": null, "screenshot": null}, "terminal_session": {"command": null, "output": null, "title": null}, "step": null, "message": null, "completed": false, "agent_is_active": true, "token_usage": 947, "timestamp": "2024-03-29 23:48:16"}, {"internal_monologue": "Browsing the web right now...", "browser_session": {"url": "https://www.techwithtim.net/tutorials/game-development-with-python/pygame-tutorial/pygame-tutorial-movement", "screenshot": "screenshots\\\\be6c056f6071d39ffcfb33de688d5961922c3d47.png"}, "terminal_session": {"command": null, "output": null, "title": null}, "step": null, "message": null, "completed": false, "agent_is_active": true, "token_usage": 1843, "timestamp": "2024-03-29 23:48:26"}, {"internal_monologue": "Browsing the web right now...", "browser_session": {"url": "https://www.geeksforgeeks.org/collision-detection-in-pygame/", "screenshot": "screenshots\\\\0d6fc49f63e27aa7606056d52aa0ac7832d9bc09.png"}, "terminal_session": {"command": null, "output": null, "title": null}, "step": null, "message": null, "completed": false, "agent_is_active": true, "token_usage": 3701, "timestamp": "2024-03-29 23:48:36"}, {"internal_monologue": "Browsing the web right now...", "browser_session": {"url": "https://dev.to/emilossola/step-by-step-guide-to-build-python-snake-game-with-pygame-4bp", "screenshot": "screenshots\\\\d33f726d5f578e88825cf40e56d350f56336c953.png"}, "terminal_session": {"command": null, "output": null, "title": null}, "step": null, "message": null, "completed": false, "agent_is_active": true, "token_usage": 7225, "timestamp": "2024-03-29 23:48:45"}]' Exception in thread Thread-518 (<lambda>): Traceback (most recent call last): File "C:\Users\Nicolas\miniconda3\envs\devika001\Lib\threading.py", line 1045, in _bootstrap_inner self.run() File "C:\Users\Nicolas\miniconda3\envs\devika001\Lib\threading.py", line 982, in run self._target(*self._args, **self._kwargs) File "C:\Users\Nicolas\Documents\devika\devika.py", line 52, in <lambda> target=lambda: Agent(base_model=base_model).execute(prompt, project_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Nicolas\Documents\devika\src\agents\agent.py", line 340, in execute code = self.coder.execute( ^^^^^^^^^^^^^^^^^^^ File "C:\Users\Nicolas\Documents\devika\src\agents\coder\coder.py", line 107, in execute valid_response = self.validate_response(response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Nicolas\Documents\devika\src\agents\coder\coder.py", line 34, in validate_response response = response.split("~~~", 1)[1] ~~~~~~~~~~~~~~~~~~~~~~~~^^^ IndexError: list index out of range
I've updated the validate_response function to handle potential IndexError gracefully. Now, the function includes error handling to ensure that the code gracefully handles cases where the response string does not contain the expected delimiter or is empty. This modification should prevent the IndexError from occurring and ensure smoother execution of the code
the second commit fix the response delay before writing code
So is that working good for u?
@ImSuvodeep it was fixed! Than you!!!
@ImSuvodeep it was fixed! Than you!!! Itll be good if owner of this repo merge it
can you resolve the conflicts?
can you resolve the conflicts?
Which conflicts...look im new in github..so it would be better if u elaborate more
can you resolve the conflicts?
Which conflicts...look im new in github..so it would be better if u elaborate more
Your branch is conflicting with the current main.
please check it and let me know it that fixes or i've to try something else thank you
your code is so much broken. you remove many things from the logger to add an agent state. I guess you first take the latest change find the problem, mention it, and state why the code needs to change—currently closing.