Spaces:
Sleeping
Sleeping
Update prompt_engine.py
Browse files- prompt_engine.py +8 -53
prompt_engine.py
CHANGED
|
@@ -1,54 +1,9 @@
|
|
| 1 |
-
# prompt_engine.py
|
| 2 |
-
|
| 3 |
-
from textwrap import dedent
|
| 4 |
-
|
| 5 |
class PromptEngine:
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
structured threat intelligence with cultural nuance preserved.
|
| 15 |
-
""")
|
| 16 |
-
|
| 17 |
-
def classify_threat(self, text):
|
| 18 |
-
return dedent(f"""
|
| 19 |
-
{self.system_context}
|
| 20 |
-
|
| 21 |
-
TASK:
|
| 22 |
-
Classify the following text into one or more categories:
|
| 23 |
-
- stolen_data
|
| 24 |
-
- malware_service
|
| 25 |
-
- laundering_service
|
| 26 |
-
- access_broker
|
| 27 |
-
- scam_indicator
|
| 28 |
-
- unknown
|
| 29 |
-
|
| 30 |
-
Also extract:
|
| 31 |
-
- slang terms
|
| 32 |
-
- vendor signals
|
| 33 |
-
- action verbs (buying, selling, promoting)
|
| 34 |
-
- risk level (1–5)
|
| 35 |
-
|
| 36 |
-
TEXT:
|
| 37 |
-
{text}
|
| 38 |
-
""")
|
| 39 |
-
|
| 40 |
-
def translate_explain(self, text):
|
| 41 |
-
return dedent(f"""
|
| 42 |
-
{self.system_context}
|
| 43 |
-
|
| 44 |
-
TASK:
|
| 45 |
-
Translate this Mandarin/Cantonese text into English.
|
| 46 |
-
Then explain: the idioms, cultural tone, and implied intent.
|
| 47 |
-
|
| 48 |
-
TEXT:
|
| 49 |
-
{text}
|
| 50 |
-
""")
|
| 51 |
-
|
| 52 |
-
# Example usage:
|
| 53 |
-
# engine = PromptEngine()
|
| 54 |
-
# prompt = engine.classify_threat("專收黑料,秒到!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
class PromptEngine:
|
| 2 |
+
def translate_explain(self, text: str) -> str:
|
| 3 |
+
return f"""
|
| 4 |
+
Translate the following Chinese (Mandarin or Cantonese) text and explain
|
| 5 |
+
any cultural or underground marketplace slang.
|
| 6 |
+
|
| 7 |
+
TEXT:
|
| 8 |
+
{text}
|
| 9 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|