Skip to content

Commit

Permalink
[__INIT__]
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Sep 12, 2024
1 parent a8a4601 commit 4bb2e69
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
55 changes: 54 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions code_guardian/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from code_guardian.main import CodeGuardian

__all__ = ["CodeGuardian"]
Empty file added code_guardian/prompt.py
Empty file.

0 comments on commit 4bb2e69

Please sign in to comment.