mirror of
https://github.com/lightbroker/llmsecops-research.git
synced 2026-07-31 00:27:25 +02:00
test output for test_02_malicious_prompts
This commit is contained in:
@@ -53,11 +53,12 @@ class BaseSecurityGuidelinesService(AbstractSecurityGuidelinesService):
|
||||
raise NotImplementedError("Subclasses must implement _get_template()")
|
||||
|
||||
def apply_guidelines(self, user_prompt: str) -> AbstractGuidelinesProcessedCompletion:
|
||||
print(f'applying guidelines (if any set)')
|
||||
if not user_prompt:
|
||||
raise ValueError(f"Parameter 'user_prompt' cannot be empty or None")
|
||||
|
||||
try:
|
||||
prompt_template: FewShotPromptTemplate = self._get_template(user_prompt=user_prompt)
|
||||
prompt_template: StringPromptTemplate = self._get_template(user_prompt=user_prompt)
|
||||
prompt_value: PromptValue = prompt_template.format_prompt(input=user_prompt)
|
||||
|
||||
# Create a comprehensive dict
|
||||
|
||||
+1
@@ -58,6 +58,7 @@ class RetrievalAugmentedGenerationSecurityGuidelinesConfigurationBuilder(
|
||||
def _get_relevant_examples(self, user_prompt: str, k: int = 3):
|
||||
"""Retrieve the most relevant examples based on the user prompt using RAG"""
|
||||
# Use similarity search to find relevant examples
|
||||
print(f'checking for relevant examples...')
|
||||
relevant_docs = self.vectorstore.similarity_search(user_prompt, k=k)
|
||||
|
||||
# Convert documents back to the format expected by the few-shot template
|
||||
|
||||
Reference in New Issue
Block a user