Skip to content

Commit

Permalink
Merge pull request #36 from prompt-security/fix_pydantic_deprecated_i…
Browse files Browse the repository at this point in the history
…mport

Fix deprecated version of pydantic library import statement to work correctly with newer versions of pydantic. Fixes #33
  • Loading branch information
vitaly-ps authored Apr 17, 2024
2 parents 6e80682 + 1916c5e commit 6378dd9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ps_fuzz/prompt_injection_fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .interactive_chat import *
from .results_table import print_table
import colorama
import pydantic.v1.error_wrappers
from pydantic.error_wrappers import ValidationError
import logging
logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -153,7 +153,7 @@ def run_interactive_chat(app_config: AppConfig):
try:
target_client = ClientLangChain(app_config.target_provider, model=app_config.target_model, temperature=0)
interactive_chat(client=target_client, system_prompts=[target_system_prompt])
except (ModuleNotFoundError, pydantic.v1.error_wrappers.ValidationError) as e:
except (ModuleNotFoundError, ValidationError) as e:
logger.warning(f"Error accessing the Target LLM provider {app_config.target_provider} with model '{app_config.target_model}': {colorama.Fore.RED}{e}{colorama.Style.RESET_ALL}")
return

Expand All @@ -163,7 +163,7 @@ def run_fuzzer(app_config: AppConfig):
target_system_prompt = app_config.system_prompt
try:
target_client = ClientLangChain(app_config.target_provider, model=app_config.target_model, temperature=0)
except (ModuleNotFoundError, pydantic.v1.error_wrappers.ValidationError) as e:
except (ModuleNotFoundError, ValidationError) as e:
logger.warning(f"Error accessing the Target LLM provider {app_config.target_provider} with model '{app_config.target_model}': {colorama.Fore.RED}{e}{colorama.Style.RESET_ALL}")
return
client_config = ClientConfig(target_client, [target_system_prompt])
Expand All @@ -173,7 +173,7 @@ def run_fuzzer(app_config: AppConfig):
attack_client = ClientLangChain(app_config.attack_provider, model=app_config.attack_model, temperature=app_config.attack_temperature),
attack_prompts_count = app_config.num_attempts
)
except (ModuleNotFoundError, pydantic.v1.error_wrappers.ValidationError) as e:
except (ModuleNotFoundError, ValidationError) as e:
logger.warning(f"Error accessing the Attack LLM provider {app_config.attack_provider} with model '{app_config.attack_model}': {colorama.Fore.RED}{e}{colorama.Style.RESET_ALL}")
return

Expand Down

0 comments on commit 6378dd9

Please sign in to comment.