SixpertAI commited on
Commit
f99d7b6
·
verified ·
1 Parent(s): 0b854db

Upload examples/api_server.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. examples/api_server.py +67 -0
examples/api_server.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Sixpert K2 - OpenAI-Compatible API Server
4
+ ==========================================
5
+ Runs Sixpert K2 as an OpenAI-compatible API server using llama-cpp-python.
6
+
7
+ The MoE architecture means K2 activates only ~1.2B parameters per token,
8
+ making it significantly faster than dense models of similar total parameter count.
9
+
10
+ Usage:
11
+ pip install llama-cpp-python
12
+ python api_server.py
13
+
14
+ Then use with any OpenAI-compatible client:
15
+ curl http://localhost:8000/v1/chat/completions \
16
+ -H "Content-Type: application/json" \
17
+ -d '{
18
+ "model": "sixpert-k2",
19
+ "messages": [{"role": "user", "content": "Explain quantum computing deeply"}]
20
+ }'
21
+ """
22
+
23
+ import argparse
24
+ from llama_cpp.server.app import create_app
25
+ from llama_cpp import Llama
26
+
27
+
28
+ def main():
29
+ parser = argparse.ArgumentParser(description="Sixpert K2 API Server")
30
+ parser.add_argument(
31
+ "--model", type=str, default="SixpertK2.gguf", help="Path to GGUF model"
32
+ )
33
+ parser.add_argument("--host", type=str, default="0.0.0.0", help="Server host")
34
+ parser.add_argument("--port", type=int, default=8000, help="Server port")
35
+ parser.add_argument("--gpu-layers", type=int, default=-1, help="GPU layers (-1 = all)")
36
+ parser.add_argument("--threads", type=int, default=8, help="CPU threads")
37
+
38
+ args = parser.parse_args()
39
+
40
+ print("=" * 60)
41
+ print(" Sixpert K2 API Server")
42
+ print(" Deep Reasoning Engine (MoE)")
43
+ print(" Total: ~8.9B params | Active: ~1.2B per token")
44
+ print("=" * 60)
45
+
46
+ llm = Llama(
47
+ model_path=args.model,
48
+ n_ctx=131072,
49
+ n_gpu_layers=args.gpu_layers,
50
+ n_threads=args.threads,
51
+ verbose=False,
52
+ )
53
+
54
+ app = create_app(llm)
55
+
56
+ print(f"\n Server running at http://{args.host}:{args.port}")
57
+ print(f" Model: sixpert-k2")
58
+ print(f" Endpoint: POST /v1/chat/completions")
59
+ print(f" Endpoint: POST /v1/completions")
60
+ print("=" * 60)
61
+
62
+ import uvicorn
63
+ uvicorn.run(app, host=args.host, port=args.port)
64
+
65
+
66
+ if __name__ == "__main__":
67
+ main()