File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : mi-os-7b
2+ parameters :
3+ model : mi-os-7b
4+ context_size : 4096
5+ template :
6+ chat : |
7+ {{.Input}}
8+ system : |
9+ # MiOS Autonomous Agent Specification
10+ (Loaded from /usr/share/mios/ai/v1/system.md)
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ import sys
3+ import os
4+ import requests
5+ import json
6+
7+ SYSTEM_SPEC_PATH = "/usr/share/mios/ai/v1/system.md"
8+ API_URL = "http://localhost:8080/v1/chat/completions"
9+
10+ def get_system_spec ():
11+ try :
12+ with open (SYSTEM_SPEC_PATH , 'r' ) as f :
13+ return f .read ()
14+ except FileNotFoundError :
15+ # Fallback to relative path if not installed to rootfs
16+ local_path = os .path .join (os .path .dirname (__file__ ), "../share/mios/ai/v1/system.md" )
17+ try :
18+ with open (local_path , 'r' ) as f :
19+ return f .read ()
20+ except FileNotFoundError :
21+ return "MiOS Autonomous Agent Specification"
22+
23+ def chat (prompt ):
24+ system_prompt = get_system_spec ()
25+
26+ payload = {
27+ "model" : "mi-os-7b" ,
28+ "messages" : [
29+ {"role" : "system" , "content" : system_prompt },
30+ {"role" : "user" , "content" : prompt }
31+ ],
32+ "stream" : False
33+ }
34+
35+ try :
36+ response = requests .post (API_URL , json = payload )
37+ response .raise_for_status ()
38+ result = response .json ()
39+ print (result ['choices' ][0 ]['message' ]['content' ])
40+ except Exception as e :
41+ print (f"Error: Could not connect to MiOS AI backend ({ e } )" )
42+ sys .exit (1 )
43+
44+ if __name__ == "__main__" :
45+ if len (sys .argv ) < 2 :
46+ print ("Usage: mios <prompt>" )
47+ sys .exit (1 )
48+
49+ chat (" " .join (sys .argv [1 :]))
You can’t perform that action at this time.
0 commit comments