mirror of
https://github.com/lightbroker/llmsecops-research.git
synced 2026-10-01 05:49:47 +02:00
updates for RAG + CoT tests
This commit is contained in:
1 parent
72785c6420
commit
741629908c
10 files changed
+6603
-61
No files matched your search
@@ -15,12 +15,13 @@ class PromptInjectionExampleRepository(AbstractPromptInjectionExampleRepository)
|
||||
def _examples(self) -> List[Dict[str, str]]:
|
||||
"""Get the list of prompt injection examples."""
|
||||
|
||||
base_path = os.environ.get('BASE_PATH', '.')
|
||||
json_filename = 'process_random_requests_and_responses.output.50_count.json'
|
||||
base_path = os.environ.get('INJECTION_DATA_DIR', '.')
|
||||
json_filename = 'process_random_requests_and_responses.output.545_count.json'
|
||||
file_path = os.path.join(base_path, json_filename)
|
||||
result = []
|
||||
|
||||
try:
|
||||
print(f'opening {file_path}')
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
data = json.load(file)
|
||||
|
||||
@@ -33,6 +34,8 @@ class PromptInjectionExampleRepository(AbstractPromptInjectionExampleRepository)
|
||||
print("Error: JSON file should contain an object or array of objects")
|
||||
return []
|
||||
|
||||
print(f'data length: {len(data)}')
|
||||
|
||||
for item in data:
|
||||
if isinstance(item, dict):
|
||||
# Extract prompt and completion keys, ignore others
|
||||
@@ -50,8 +53,7 @@ class PromptInjectionExampleRepository(AbstractPromptInjectionExampleRepository)
|
||||
extracted['prompt_injection_completion'] = item[key]
|
||||
break
|
||||
|
||||
# Only add if we found both prompt and completion
|
||||
if 'prompt' in extracted and 'completion' in extracted:
|
||||
if 'prompt_injection_prompt' in extracted and 'prompt_injection_completion' in extracted:
|
||||
result.append(extracted)
|
||||
|
||||
except FileNotFoundError:
|
||||
|
||||
Reference in new issue
Block a user