-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbars_cli.py
More file actions
40 lines (33 loc) · 964 Bytes
/
Copy pathbars_cli.py
File metadata and controls
40 lines (33 loc) · 964 Bytes
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
import subprocess
# Loads the instruction
with open("bars_system_prompt.txt", "r", encoding="utf-8") as f:
system_prompt = f.read()
# Load Bars memory
with open("bars_chat_history.txt", "r", encoding="utf-8") as f:
memory = f.read()
with open("test_code.txt", "r") as f:
code = f.read()
# Chat loop
print("🧠 Bars is online (phi model)")
while True:
user_input = input("You > ")
if user_input.lower() in ['exit', 'quit']:
break
# Merge memory + user input
full_prompt = (
f"{system_prompt}\n\n"
f"{memory}\n\n"
f"{code}\n\n"
f"Aditya: {user_input}\n"
f"Bars:"
)
# Run phi with prompt
process = subprocess.Popen(
["ollama", "run", "llama3.2"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
output, error = process.communicate(input=full_prompt)
print(f"Bars > {output.strip()}")