Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ from transformers import pipeline
|
|
| 3 |
from typing import List, Dict
|
| 4 |
|
| 5 |
# Initialize the Hugging Face pipeline (make sure to replace with your model name)
|
| 6 |
-
model_name = "your_huggingface_model_name"
|
| 7 |
try:
|
| 8 |
generator = pipeline("text-generation", model=model_name)
|
| 9 |
except Exception as e:
|
|
@@ -12,11 +12,9 @@ except Exception as e:
|
|
| 12 |
def generate_attack(prompt: str, history: List[Dict[str, str]]) -> List[str]:
|
| 13 |
"""
|
| 14 |
Simulates a Blackhat AI scenario by generating attack strategies and potential impacts.
|
| 15 |
-
|
| 16 |
Args:
|
| 17 |
prompt (str): The user's input to the simulator.
|
| 18 |
history (List[Dict]): The user's message history with timestamps.
|
| 19 |
-
|
| 20 |
Returns:
|
| 21 |
List[str]: A list of attack responses from the AI.
|
| 22 |
"""
|
|
@@ -34,6 +32,7 @@ def generate_attack(prompt: str, history: List[Dict[str, str]]) -> List[str]:
|
|
| 34 |
if "assistant" in val:
|
| 35 |
messages.append({"role": "assistant", "content": val["assistant"]})
|
| 36 |
|
|
|
|
| 37 |
messages.append({"role": "user", "content": prompt})
|
| 38 |
|
| 39 |
# Generate a response using the Hugging Face model
|
|
|
|
| 3 |
from typing import List, Dict
|
| 4 |
|
| 5 |
# Initialize the Hugging Face pipeline (make sure to replace with your model name)
|
| 6 |
+
model_name = "your_huggingface_model_name" # Ensure to use a valid model
|
| 7 |
try:
|
| 8 |
generator = pipeline("text-generation", model=model_name)
|
| 9 |
except Exception as e:
|
|
|
|
| 12 |
def generate_attack(prompt: str, history: List[Dict[str, str]]) -> List[str]:
|
| 13 |
"""
|
| 14 |
Simulates a Blackhat AI scenario by generating attack strategies and potential impacts.
|
|
|
|
| 15 |
Args:
|
| 16 |
prompt (str): The user's input to the simulator.
|
| 17 |
history (List[Dict]): The user's message history with timestamps.
|
|
|
|
| 18 |
Returns:
|
| 19 |
List[str]: A list of attack responses from the AI.
|
| 20 |
"""
|
|
|
|
| 32 |
if "assistant" in val:
|
| 33 |
messages.append({"role": "assistant", "content": val["assistant"]})
|
| 34 |
|
| 35 |
+
# Append the current user prompt
|
| 36 |
messages.append({"role": "user", "content": prompt})
|
| 37 |
|
| 38 |
# Generate a response using the Hugging Face model
|