mirror of
https://github.com/dongdongunique/EvoSynth.git
synced 2026-02-12 17:22:44 +00:00
🔧 Fix Quick Start code example
- Add missing 'import os' statement - Properly formatted imports and load_dotenv() call - Code now correctly uses os.getenv() for environment variables
This commit is contained in:
23
README.md
23
README.md
@@ -132,36 +132,41 @@ Create a `.env` file with your API credentials:
|
||||
|
||||
```python
|
||||
import asyncio
|
||||
import os
|
||||
from jailbreak_toolbox.models.implementations.openai_model import OpenAIModel
|
||||
from jailbreak_toolbox.attacks.blackbox.implementations.evosynth import EvosynthAttack, EvosynthConfig
|
||||
from jailbreak_toolbox.judges.implementations import LLMJudge
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
async def main():
|
||||
# Initialize models (using router platform like OpenRouter or BoyueRichData)
|
||||
target_model = OpenAIModel(
|
||||
model_name="gpt-4o",
|
||||
api_key="your_key",
|
||||
base_url="https://openrouter.ai/api/v1" # or your router's endpoint
|
||||
api_key=os.getenv("OPENAI_API_KEY"),
|
||||
base_url=os.getenv("OPENAI_BASE_URL") # or your router's endpoint
|
||||
)
|
||||
judge_model = OpenAIModel(
|
||||
model_name="gpt-4o",
|
||||
api_key="your_key",
|
||||
base_url="https://openrouter.ai/api/v1"
|
||||
api_key=os.getenv("OPENAI_API_KEY"),
|
||||
base_url=os.getenv("OPENAI_BASE_URL")
|
||||
)
|
||||
|
||||
# Configure attack
|
||||
config = EvosynthConfig(
|
||||
max_iterations=15,
|
||||
success_threshold=5,
|
||||
pipeline="full_pipeline"
|
||||
pipeline="full_pipeline",
|
||||
openai_api_key=os.getenv("OPENAI_API_KEY"),
|
||||
base_url=os.getenv("OPENAI_BASE_URL"),
|
||||
attack_model_base="deepseek-chat",
|
||||
langfuse_host=None
|
||||
)
|
||||
|
||||
# Create judge and attack
|
||||
judge = LLMJudge(judge_model=judge_model)
|
||||
attack = EvosynthAttack(
|
||||
target_model=target_model,
|
||||
judge=judge,
|
||||
config=config
|
||||
judge=judge_model,
|
||||
config=config,
|
||||
)
|
||||
|
||||
# Execute attack (async)
|
||||
|
||||
Reference in New Issue
Block a user