-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
61 lines (53 loc) · 2.29 KB
/
Copy pathmodels.py
File metadata and controls
61 lines (53 loc) · 2.29 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import socket
from langchain_community.llms import Ollama
from langchain_community.embeddings import OllamaEmbeddings
from langchain_core.messages import SystemMessage, HumanMessage
OLLAMA_URL = f"http://{socket.gethostname()}:11434"
LLM_MODEL = "llama3.2"
EMBED_MODEL = "mxbai-embed-large"
llm = Ollama(
model=LLM_MODEL,
base_url=OLLAMA_URL,
temperature=0.2
)
embeddings = OllamaEmbeddings(
model=EMBED_MODEL,
base_url=OLLAMA_URL
)
def build_translator_prompt(question, context):
"""
Prompt for translating cybercrime / evidence collection jargon into layman's terms.
"""
system = SystemMessage(content=(
"You are a cybersecurity translator. Use only the provided context to explain "
"technical terms and procedures in clear, concise, plain English suitable for a layperson. "
"When you are not certain, say 'I don't know'. Do not invent facts."
))
human = HumanMessage(content=f"""
CONTEXT:
{context}
INSTRUCTION:
Rewrite the context or answer the question below in simple, everyday English that a non-technical legal layperson can understand. Keep explanations concise and avoid jargon.
QUESTION:
{question}
""")
return [system, human]
def build_compliance_prompt(question, context):
"""
Prompt for evaluating admissibility/compliance of a digital evidence collector's testimony.
"""
system = SystemMessage(content=(
"You are an expert in digital evidence admissibility and chain-of-custody issues. "
"Use only the provided context (testimony and supporting text) to analyze compliance with typical legal standards for admissibility. "
"State whether the testimony appears admissible, list any specific problems, and cite the relevant parts of the provided context. "
"If unsure, say 'I don't know' and list the missing information needed to decide."
))
human = HumanMessage(content=f"""
TESTIMONY / CONTEXT:
{context}
INSTRUCTION:
Based only on the context, answer whether the testimony meets typical standards for admissibility (chain of custody, proper procedures, authorization, integrity of evidence, etc.). Give a short conclusion (Admissible / Potential issues / Not admissible) and a bullet list with the specific reasons or missing items.
QUESTION:
{question}
""")
return [system, human]