From 4bb2e69323e8b420519a819832e15c2989f0cf9f Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 12 Sep 2024 17:35:37 -0400 Subject: [PATCH] [__INIT__] --- README.md | 55 ++++++++++++++++++++++++++++++++++++++- code_guardian/__init__.py | 3 +++ code_guardian/prompt.py | 0 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 code_guardian/prompt.py diff --git a/README.md b/README.md index 702140e..d6167b1 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,60 @@ pip3 install -U code-guardian ``` - +## Example + +```python +import os + +from dotenv import load_dotenv +from swarms import Agent, OpenAIChat + +from code_guardian.main import CodeGuardian + +load_dotenv() + +# Get the OpenAI API key from the environment variable +api_key = os.getenv("OPENAI_API_KEY") + +# Create an instance of the OpenAIChat class +model = OpenAIChat( + openai_api_key=api_key, + model_name="gpt-4o-mini", + temperature=0.1, + max_tokens=2000, +) + +# Initialize the agent for generating unit tests +agent = Agent( + agent_name="Unit-Test-Generator-Agent", # Changed agent name + system_prompt="Generate unit tests for the provided classes using pytest.", # Updated system prompt + llm=model, + max_loops=1, + autosave=True, + dashboard=False, + verbose=True, + dynamic_temperature_enabled=True, + saved_state_path="unit_test_agent.json", # Updated saved state path + user_name="swarms_corp", + retry_attempts=1, + context_length=200000, + return_step_meta=False, + # output_type="json", +) + +# Classes you want to generate tests for +classes_to_test = [CodeGuardian] + +# Initialize CodeGuardian and run +guardian = CodeGuardian( + classes=classes_to_test, # classes to test + agent=agent, # agent to use + dir_path="tests", # directory to save tests + package_name="code-guardian", # package name + module_name="code_guardian.main", # module name +) +guardian.run() +``` ### Configuration Options diff --git a/code_guardian/__init__.py b/code_guardian/__init__.py index e69de29..c695959 100644 --- a/code_guardian/__init__.py +++ b/code_guardian/__init__.py @@ -0,0 +1,3 @@ +from code_guardian.main import CodeGuardian + +__all__ = ["CodeGuardian"] \ No newline at end of file diff --git a/code_guardian/prompt.py b/code_guardian/prompt.py new file mode 100644 index 0000000..e69de29