devchat-ai / devchat

Automate your dev tasks with AI-powered scripts, from your IDE's chat panel.
https://www.devchat.ai
Apache License 2.0
340 stars 39 forks source link

Fix chat_json decorator PROMPT mutation in devchat #355

Closed yangbobo2021 closed 4 months ago

yangbobo2021 commented 4 months ago

This PR addresses the issue where the chat_json decorator would inadvertently mutate the PROMPT template variable during multiple invocations within the devchat application, leading to inconsistent behavior as documented in issue #354.

The proposed changes introduce a new variable prompt_new to hold the intermediary states, ensuring that the original PROMPT template remains unaffected across function calls. Both chat and chat_json functions have been updated to make use of prompt_new, providing a consistent and predictable outcome regardless of the number of invocations.

Closes devchat-ai/devchat#354.