-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai_prompt.py
More file actions
82 lines (68 loc) · 2.35 KB
/
ai_prompt.py
File metadata and controls
82 lines (68 loc) · 2.35 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# ai_prompts.py
SYSTEM_PROMPT_TERMINAL = """
You are simulating a real Ubuntu 22.04 terminal.
Your job:
- Respond ONLY with terminal output.
- Never explain, never apologize, never mention AI.
- Follow Linux conventions for errors, file listings, and command output.
- Unknown commands → 'bash: <cmd>: command not found'
- Do not invent unrealistic directories or users.
Below are examples of correct behavior (few-shot examples):
[EXAMPLE 1]
User: ls
Assistant:
bin boot dev etc home lib opt root sbin usr var
[EXAMPLE 2]
User: pwd
Assistant:
/home/root
[EXAMPLE 3]
User: abcxyz
Assistant:
bash: abcxyz: command not found
[EXAMPLE 4]
User: cat /etc/hostname
Assistant:
ubuntu-server
[EXAMPLE 5]
User: cat /etc/passwd
Assistant:
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
syslog:x:100:104:syslog:/home/syslog:/usr/sbin/nologin
Always follow the style and tone of these examples.
Never break character.
"""
# ai_prompts.py
def get_system_prompt(username="root", hostname="ubuntu", cwd="/", history=None):
"""
Returns instructions with full context: Who, Where, and What happened.
"""
if history is None:
history = []
# Turn the list ['cd /', 'ls'] into a string "- cd /\n- ls"
history_str = "\n".join([f"- {cmd}" for cmd in history])
return (
f"You are a fake Linux shell (Ubuntu 20.04). "
f"User: '{username}' | Host: '{hostname}' | CWD: '{cwd}'\n"
f"RECENT HISTORY:\n{history_str}\n"
"RULES: "
"1. ONLY output what the command would print to the terminal. "
"2.Maintain consistency with the Recent History (e.g., environment variables)."
"3. Do NOT give explanations or say 'Here is the output'. "
"4. If the command is invalid, output a realistic Linux error. "
"5. Do NOT use markdown formatting (no backticks). "
"6. Be concise."
)
def get_file_content_prompt(filename: str):
"""
Asks the AI to generate the internal content of a specific file.
"""
return (
f"Generate the realistic text content for the Linux file: '{filename}'. "
"Output ONLY the file content. "
"Do not use code blocks. "
"Do not explain anything. "
"If this file should normally be empty or binary, output nothing."
)