From eb25f2780c689d238e538f4f15e5a3acc2947f39 Mon Sep 17 00:00:00 2001 From: dongdongunique <909580378@qq.com> Date: Wed, 10 Dec 2025 18:26:50 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Fix=20Quick=20Start=20code=20exa?= =?UTF-8?q?mple?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add missing 'import os' statement - Properly formatted imports and load_dotenv() call - Code now correctly uses os.getenv() for environment variables --- README.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 665b572..bbcf0ab 100644 --- a/README.md +++ b/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)