prithivMLmods commited on
Commit
6c05448
·
verified ·
1 Parent(s): 76d5491

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +116 -0
README.md ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ ---
4
+
5
+ ## Run with llama.cpp (SystemOne API)
6
+
7
+ ### 1. Start the Server
8
+
9
+ Launch `llama-server` with the GGUF model and wait for the health check endpoint to report ready.
10
+
11
+ ```python
12
+ import subprocess, time, requests
13
+
14
+ MODEL_PATH = "/data/llama.cpp/gguf-new/d3.BF16.gguf"
15
+ BASE_URL = "[http://127.0.0.1:8080](http://127.0.0.1:8080)"
16
+
17
+ server = subprocess.Popen(
18
+ [
19
+ "/data/llama.cpp/build/bin/llama-server",
20
+ "-m", MODEL_PATH,
21
+ "--host", "127.0.0.1",
22
+ "--port", "8080",
23
+ "-ngl", "99",
24
+ ],
25
+ stdout=open("/data/llama-server.log", "w"),
26
+ stderr=subprocess.STDOUT,
27
+ )
28
+
29
+ for _ in range(120):
30
+ try:
31
+ if requests.get(f"{BASE_URL}/health", timeout=2).status_code == 200:
32
+ print("server ready")
33
+ break
34
+ except requests.exceptions.RequestException:
35
+ pass
36
+ time.sleep(2)
37
+ else:
38
+ print("server not ready, check /data/llama-server.log")
39
+ ```
40
+
41
+ ### 2. Query the `/v1/systemone` Endpoint
42
+
43
+ Send a `POST` request with a `state` context and structured `questions` (`choice`, `noul`, or `score`).
44
+
45
+ ```bash
46
+ curl -s [http://127.0.0.1:8080/v1/systemone](http://127.0.0.1:8080/v1/systemone) \
47
+ -H "Content-Type: application/json" \
48
+ -d '{
49
+ "state": "Customer message: I was charged twice for my order last week and nobody has replied.",
50
+ "questions": {
51
+ "route": {
52
+ "type": "choice",
53
+ "instructions": "Which team should handle this?",
54
+ "criteria": {
55
+ "billing": "payments, charges, refunds, invoices",
56
+ "shipping": "delivery, tracking, lost or late parcels",
57
+ "technical": "bugs, errors, login problems"
58
+ }
59
+ },
60
+ "angry": {
61
+ "type": "noul",
62
+ "instructions": "Is the customer angry?"
63
+ },
64
+ "urgency": {
65
+ "type": "score",
66
+ "instructions": "How urgent is this?",
67
+ "criteria": ["can wait", "this week", "today", "right now"]
68
+ }
69
+ }
70
+ }' | python3 -m json.tool
71
+ ```
72
+
73
+ ### 3. Example Response
74
+
75
+ ```json
76
+ {
77
+ "model": "/data/llama.cpp/gguf-new/d3.BF16.gguf",
78
+ "answers": {
79
+ "route": {
80
+ "type": "choice",
81
+ "choice": "billing",
82
+ "probabilities": {
83
+ "billing": 0.9996618974570523,
84
+ "shipping": 0.00013507157686214213,
85
+ "technical": 0.0002030309660855959
86
+ },
87
+ "confidence": 0.9970256171728359
88
+ },
89
+ "angry": {
90
+ "type": "noul",
91
+ "noul": 0.7505827517439388
92
+ },
93
+ "urgency": {
94
+ "type": "score",
95
+ "score": 2.1734206644237215,
96
+ "legend": {
97
+ "0": "can wait",
98
+ "1": "this week",
99
+ "2": "today",
100
+ "3": "right now"
101
+ },
102
+ "probabilities": {
103
+ "0": 0.007391267944072573,
104
+ "1": 0.1251241500290827,
105
+ "2": 0.5541572316858958,
106
+ "3": 0.31332735034094905
107
+ },
108
+ "confidence": 0.28797389363668036
109
+ }
110
+ },
111
+ "usage": {
112
+ "input_tokens": 350,
113
+ "output_tokens": 0
114
+ }
115
+ }
116
+ ```