unisi 0.3.15__py3-none-any.whl → 0.3.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- unisi/llmrag.py +3 -4
- unisi/server.py +17 -6
- {unisi-0.3.15.dist-info → unisi-0.3.16.dist-info}/METADATA +1 -1
- {unisi-0.3.15.dist-info → unisi-0.3.16.dist-info}/RECORD +7 -7
- {unisi-0.3.15.dist-info → unisi-0.3.16.dist-info}/WHEEL +0 -0
- {unisi-0.3.15.dist-info → unisi-0.3.16.dist-info}/entry_points.txt +0 -0
- {unisi-0.3.15.dist-info → unisi-0.3.16.dist-info}/licenses/LICENSE +0 -0
unisi/llmrag.py
CHANGED
@@ -90,7 +90,7 @@ def Q(str_prompt, type_value = str, blank = True, **format_model):
|
|
90
90
|
if not re.search(r'json', str_prompt, re.IGNORECASE):
|
91
91
|
jtype = jstype(type_value)
|
92
92
|
format = " dd/mm/yyyy string" if type_value == 'date' else f'a JSON {jtype}' if jtype != 'string' else jtype
|
93
|
-
str_prompt = f"System: You are an intelligent and extremely smart assistant. Output STRONGLY {format}." + str_prompt
|
93
|
+
str_prompt = f"System: You are an intelligent and extremely smart assistant. Output STRONGLY {format}. Do not output any commentary." + str_prompt
|
94
94
|
async def f():
|
95
95
|
io = await llm.ainvoke(str_prompt)
|
96
96
|
js = io.content.strip().strip('`').replace('json', '')
|
@@ -107,9 +107,8 @@ def Q(str_prompt, type_value = str, blank = True, **format_model):
|
|
107
107
|
else:
|
108
108
|
if blank:
|
109
109
|
parsed[k] = None
|
110
|
-
continue
|
111
|
-
|
112
|
-
raise KeyError(f'Key {k} not found in {parsed}')
|
110
|
+
continue
|
111
|
+
raise KeyError(f'Key {k} not found in {parsed}')
|
113
112
|
|
114
113
|
if not is_type(parsed[k], v):
|
115
114
|
raise TypeError(f'Invalid type for {k}: {type(parsed[k])} != {v}')
|
unisi/server.py
CHANGED
@@ -9,7 +9,12 @@ from .llmrag import setup_llmrag
|
|
9
9
|
from .dbunits import dbupdates
|
10
10
|
from .kdb import Database
|
11
11
|
from config import port, upload_dir
|
12
|
-
import traceback, json
|
12
|
+
import traceback, json, random, string
|
13
|
+
from urllib.parse import parse_qs
|
14
|
+
|
15
|
+
def generate_random_string(length=10):
|
16
|
+
characters = string.ascii_letters + string.digits
|
17
|
+
return ''.join(random.choices(characters, k=length))
|
13
18
|
|
14
19
|
def context_user():
|
15
20
|
return context_object(User)
|
@@ -34,11 +39,17 @@ if config.db_dir:
|
|
34
39
|
Unishare.db = Database(config.db_dir, message_logger)
|
35
40
|
|
36
41
|
def make_user(request):
|
37
|
-
|
38
|
-
if
|
39
|
-
|
42
|
+
parsed_query = parse_qs(request.query_string)
|
43
|
+
if 'session' in parsed_query:
|
44
|
+
session = parsed_query['session'][0]
|
45
|
+
user_id = session.split('-')[1]
|
46
|
+
else:
|
47
|
+
user_id = parsed_query.get('id', [User.count])[0]
|
48
|
+
session = f'{generate_random_string()}-{user_id}'
|
49
|
+
if config.share and 'session' in parsed_query:
|
50
|
+
user = Unishare.sessions.get(session, None)
|
40
51
|
if not user:
|
41
|
-
error = f'Session id "{
|
52
|
+
error = f'Session id "{session}" is unknown. Connection refused!'
|
42
53
|
with logging_lock:
|
43
54
|
logging.error(error)
|
44
55
|
return None, Error(error)
|
@@ -106,7 +117,7 @@ async def static_serve(request):
|
|
106
117
|
|
107
118
|
async def websocket_handler(request):
|
108
119
|
ws = web.WebSocketResponse()
|
109
|
-
await ws.prepare(request)
|
120
|
+
await ws.prepare(request)
|
110
121
|
user, status = make_user(request)
|
111
122
|
if not user:
|
112
123
|
await ws.send_str(toJson(status))
|
@@ -1,7 +1,7 @@
|
|
1
|
-
unisi-0.3.
|
2
|
-
unisi-0.3.
|
3
|
-
unisi-0.3.
|
4
|
-
unisi-0.3.
|
1
|
+
unisi-0.3.16.dist-info/METADATA,sha256=o3bi9eL509XYvMrr-juU0QEGBeRAAp3X_ST4itU5Ulk,27266
|
2
|
+
unisi-0.3.16.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
+
unisi-0.3.16.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
4
|
+
unisi-0.3.16.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
5
5
|
unisi/__init__.py,sha256=prG4FwJzpNJRX1trto0x_4Bne3kkpEX1dUxcRnIxWVw,301
|
6
6
|
unisi/autotest.py,sha256=qYKwSPEPUEio6koUSu1tc71pDkX-doCQJlyRppaXCtY,8709
|
7
7
|
unisi/common.py,sha256=bMPZo7V9nlJW5HC0yJLRDbrh0DZ4oqmEtBuOvGyN6fw,5759
|
@@ -14,11 +14,11 @@ unisi/jsoncomparison/config.py,sha256=LbdLJE1KIebFq_tX7zcERhPvopKhnzcTqMCnS3jN12
|
|
14
14
|
unisi/jsoncomparison/errors.py,sha256=wqphE1Xn7K6n16uvUhDC45m2BxbsMUhIF2olPbhqf4o,1192
|
15
15
|
unisi/jsoncomparison/ignore.py,sha256=xfF0a_BBEyGdZBoq-ovpCpawgcX8SRwwp7IrGnu1c2w,2634
|
16
16
|
unisi/kdb.py,sha256=K-Lqc3e9hLTwO0i1ilTC6qrwZp90tXjLm7HFb_lM1Os,13621
|
17
|
-
unisi/llmrag.py,sha256=
|
17
|
+
unisi/llmrag.py,sha256=xlye9OodtIZaoMWEV8hfF_Vjo4VtXVYxY3qiY3qaD74,7077
|
18
18
|
unisi/multimon.py,sha256=YKwCuvMsMfdgOGkJoqiqh_9wywXMeo9bUhHmbAIUeSE,4060
|
19
19
|
unisi/proxy.py,sha256=QMHSSFJtmVZIexIMAsuFNlF5JpnYNG90rkTM3PYJhY4,7750
|
20
20
|
unisi/reloader.py,sha256=qml-ufoUME7mrWrPMwMo3T8Jsh4e26CBj564cHCB6I0,6749
|
21
|
-
unisi/server.py,sha256=
|
21
|
+
unisi/server.py,sha256=9qgSH-HjQDQwSK2gor_dUGqHocrJS-Z-t5B54EjUDd0,6594
|
22
22
|
unisi/tables.py,sha256=tszF62VToSchILzPhJgA4U02MFjv44LopXgD5mYg7fg,13822
|
23
23
|
unisi/units.py,sha256=SCUZAOV0nu9khg6JE0lWwsKjiCVz29hiUCRXyZJffeA,11111
|
24
24
|
unisi/users.py,sha256=JeIori4XsW1blkasLwqZeK8XloX7UjDV_0aHE7WNWjo,16169
|
@@ -46,4 +46,4 @@ unisi/web/js/885.d3e9dd2b.js,sha256=7A39S4SDApVc4iHHABjOd5julybSa4UwaH4kj8vSn0E,
|
|
46
46
|
unisi/web/js/935.cc0c012c.js,sha256=FzVIRBr4vyQgW38ROCoh929gtzuXqM73Cf77vejfDWk,6561
|
47
47
|
unisi/web/js/app.3d5227f7.js,sha256=lJkD2OPQOYlxivZmNY8FYKI1JMQ_bh1Pm4zC7y8Ayt0,6150
|
48
48
|
unisi/web/js/vendor.1bb14e9d.js,sha256=7q80jaZcms7UhWSqHAk2pXSx67cYQJGlsp-6DBXBZuU,1253597
|
49
|
-
unisi-0.3.
|
49
|
+
unisi-0.3.16.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|