Skip to content

Commit

Permalink
Added fix for supercoder (TransformerOptimus#521)
Browse files Browse the repository at this point in the history
* Added logic for requirements and dependencies

* Added generate logic prompt

* Refactored pytest for unittest

---------

Co-authored-by: COLONAYUSH <ayushkaps9462@gmail.com>
  • Loading branch information
2 people authored and primed-lan-laucirica committed Jun 28, 2023
1 parent e0d369c commit b4f49dc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions superagi/tools/code/prompts/generate_logic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
You typically always place distinct classes in separate files.
Always create a run.sh file which act as the entrypoint of the program, create it intellligently after analyzing the file types
For Python, always generate a suitable requirements.txt file.
For NodeJS, consistently produce an appropriate package.json file.
Always include a brief comment that describes the purpose of the function definition.
Attempt to provide comments that explain complicated logic.
Consistently adhere to best practices for the specified languages, ensuring code is defined as a package or project.

Preferred Python toolbelt:
- pytest
- dataclasses
2 changes: 1 addition & 1 deletion superagi/tools/code/write_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _execute(self, code_description: str) -> str:
Returns:
Generated codes files or error message.
"""
prompt = PromptReader.read_tools_prompt(__file__, "write_code.txt")
prompt = PromptReader.read_tools_prompt(__file__, "write_code.txt") + "\nUseful to know:\n" + PromptReader.read_tools_prompt(__file__, "generate_logic.txt")
prompt = prompt.replace("{goals}", AgentPromptBuilder.add_list_items_to_string(self.goals))
prompt = prompt.replace("{code_description}", code_description)
spec_response = self.tool_response_manager.get_last_response("WriteSpecTool")
Expand Down
4 changes: 2 additions & 2 deletions superagi/tools/code/write_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class WriteTestSchema(BaseModel):

class WriteTestTool(BaseTool):
"""
Used to generate pytest unit tests based on the specification.
Used to generate unit tests based on the specification.
Attributes:
llm: LLM used for test generation.
Expand Down Expand Up @@ -62,7 +62,7 @@ def _execute(self, test_description: str, test_file_name: str) -> str:
test_file_name: The name of the file where the generated tests will be saved.
Returns:
Generated pytest unit tests or error message.
Generated unit tests or error message.
"""
prompt = PromptReader.read_tools_prompt(__file__, "write_test.txt")
prompt = prompt.replace("{goals}", AgentPromptBuilder.add_list_items_to_string(self.goals))
Expand Down

0 comments on commit b4f49dc

Please sign in to comment.