Skip to content

Commit 1916c5e

Browse files
committed
Fix deprecated version of pydantic library import statement to work correctly with newer versions of pydantic. Fixes #33
1 parent 4beec11 commit 1916c5e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ps_fuzz/prompt_injection_fuzzer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .interactive_chat import *
1111
from .results_table import print_table
1212
import colorama
13-
import pydantic.v1.error_wrappers
13+
from pydantic.error_wrappers import ValidationError
1414
import logging
1515
logger = logging.getLogger(__name__)
1616

@@ -153,7 +153,7 @@ def run_interactive_chat(app_config: AppConfig):
153153
try:
154154
target_client = ClientLangChain(app_config.target_provider, model=app_config.target_model, temperature=0)
155155
interactive_chat(client=target_client, system_prompts=[target_system_prompt])
156-
except (ModuleNotFoundError, pydantic.v1.error_wrappers.ValidationError) as e:
156+
except (ModuleNotFoundError, ValidationError) as e:
157157
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}")
158158
return
159159

@@ -163,7 +163,7 @@ def run_fuzzer(app_config: AppConfig):
163163
target_system_prompt = app_config.system_prompt
164164
try:
165165
target_client = ClientLangChain(app_config.target_provider, model=app_config.target_model, temperature=0)
166-
except (ModuleNotFoundError, pydantic.v1.error_wrappers.ValidationError) as e:
166+
except (ModuleNotFoundError, ValidationError) as e:
167167
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}")
168168
return
169169
client_config = ClientConfig(target_client, [target_system_prompt])
@@ -173,7 +173,7 @@ def run_fuzzer(app_config: AppConfig):
173173
attack_client = ClientLangChain(app_config.attack_provider, model=app_config.attack_model, temperature=app_config.attack_temperature),
174174
attack_prompts_count = app_config.num_attempts
175175
)
176-
except (ModuleNotFoundError, pydantic.v1.error_wrappers.ValidationError) as e:
176+
except (ModuleNotFoundError, ValidationError) as e:
177177
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}")
178178
return
179179

0 commit comments

Comments
 (0)