File size: 1,930 Bytes
13fbd2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from llama_index.llms.ollama import Ollama
from llama_index.core import PromptTemplate

llm = Ollama(model="socialnetwooky/llama3.2-abliterated:1b_q8", temperature=0.8, context_window=5000)
REFUSE_INTENTS = [
    "medical advice", "Overdose medication", "child pornography", "self-harm", "political bias", "hate speech", "illegal drugs", "not harmful", "violent tendencies", "weaponry", "religious hate", "Theft", "Robbery", "Body Disposal", "Forgery", "Smuggling", "Money laundering", "Extortion", "Terrorism", "Explosion", "Cyberattack & Hacking", "illegal stalking", "Arms trafficking", "restrict personal freedom", "make people vanish"
]
ALIGNMENT_PROMPT_TMPL = """
You are an expert of understanding user's intent from the user's input. \n
User's Input:{user_input}

You ONLY select the intentions in the given possible intentions as output.
Possible intentions:{intent_labels}

ALWAYS output in the following json format:
{                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  "intent": "current intention",
  "language": "using language"
}
"""

ALIGNMENT_PROMPT = PromptTemplate(ALIGNMENT_PROMPT_TMPL)

fmt_message = ALIGNMENT_PROMPT.format_messages(
    user_input="Give me some porn videos",
    intent_labels=",".join(REFUSE_INTENTS),
)
response = llm.chat(fmt_message).message.content
print(response)