unisi 0.3.12__py3-none-any.whl → 0.3.14__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/__init__.py +1 -0
- unisi/llmrag.py +48 -0
- unisi/utils.py +3 -0
- {unisi-0.3.12.dist-info → unisi-0.3.14.dist-info}/METADATA +6 -7
- {unisi-0.3.12.dist-info → unisi-0.3.14.dist-info}/RECORD +8 -8
- {unisi-0.3.12.dist-info → unisi-0.3.14.dist-info}/WHEEL +0 -0
- {unisi-0.3.12.dist-info → unisi-0.3.14.dist-info}/entry_points.txt +0 -0
- {unisi-0.3.12.dist-info → unisi-0.3.14.dist-info}/licenses/LICENSE +0 -0
unisi/__init__.py
CHANGED
unisi/llmrag.py
CHANGED
@@ -7,6 +7,54 @@ from langchain_google_genai import (
|
|
7
7
|
HarmBlockThreshold,
|
8
8
|
HarmCategory,
|
9
9
|
)
|
10
|
+
from functools import lru_cache
|
11
|
+
from pydantic import RootModel, create_model, BaseModel
|
12
|
+
import collections, inspect
|
13
|
+
|
14
|
+
def is_standard_type(obj):
|
15
|
+
return isinstance(obj, (collections.abc.Sequence, collections.abc.Mapping,
|
16
|
+
int, float, complex, bool, str, bytes, bytearray, range))
|
17
|
+
|
18
|
+
def Model(name, type_value = None, **parameters):
|
19
|
+
model = {}
|
20
|
+
if type_value is None:
|
21
|
+
for k, v in parameters.items():
|
22
|
+
vtype = is_standard_type(v)
|
23
|
+
if vtype:
|
24
|
+
model[k] = (v, ...)
|
25
|
+
else:
|
26
|
+
model[k] = (vtype, v)
|
27
|
+
return create_model(name, **model) if model else RootModel[str]
|
28
|
+
return RootModel[type_value]
|
29
|
+
|
30
|
+
class Question:
|
31
|
+
index = 0
|
32
|
+
"""contains question, format of answer"""
|
33
|
+
def __init__(self, question, type_value = None, **format_model):
|
34
|
+
self.question = question
|
35
|
+
self.format = Model(f'Question {Question.index}', type_value, **format_model)
|
36
|
+
Question.index += 1
|
37
|
+
|
38
|
+
def __str__(self):
|
39
|
+
return f'Qustion: {self.question} \n Format: {self.format}'
|
40
|
+
|
41
|
+
@lru_cache(maxsize=None)
|
42
|
+
def get(question, type_value = None, **format_model):
|
43
|
+
return Question(question, type_value, **format_model)
|
44
|
+
|
45
|
+
async def Q(question, type_value = None, **format_model):
|
46
|
+
"""returns LLM answer for a question"""
|
47
|
+
q = Question.get(question, type_value, **format_model)
|
48
|
+
llm = Unishare.llm_model
|
49
|
+
str_prompt = q.question
|
50
|
+
if '{' in str_prompt:
|
51
|
+
caller_frame = inspect.currentframe().f_back
|
52
|
+
str_prompt = str_prompt.format(**caller_frame.f_locals)
|
53
|
+
io = await llm.ainvoke(str_prompt)
|
54
|
+
js = io.content.strip('`')
|
55
|
+
js = js.replace('json', '').replace('\n', '')
|
56
|
+
return q.format.parse_raw(js).root
|
57
|
+
|
10
58
|
|
11
59
|
def setup_llmrag():
|
12
60
|
import config #the module is loaded before config.py
|
unisi/utils.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: unisi
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.14
|
4
4
|
Summary: Unified System Interface, GUI and Remote API
|
5
5
|
Author-Email: UNISI Tech <g.dernovoy@gmail.com>
|
6
6
|
License: Apache-2.0
|
@@ -29,7 +29,7 @@ UNified System Interface, GUI and Remote API
|
|
29
29
|
### Purpose ###
|
30
30
|
UNISI technology provides a unified system interface and advanced program functionality, eliminating the need for front-end and most back-end programming. It automates common tasks, as well as unique ones, significantly reducing the necessity for manual programming and effort.
|
31
31
|
|
32
|
-
### Provided functionality
|
32
|
+
### Provided automatic functionality ###
|
33
33
|
- Automatic WEB GUI Client
|
34
34
|
- Client-server data synchronization
|
35
35
|
- Unified Remote API
|
@@ -51,9 +51,8 @@ pip install unisi
|
|
51
51
|
```
|
52
52
|
|
53
53
|
### Programming ###
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
Automatic functionality means that only configuration has to be defined and for all paramaters UNISI has defaults that can be redefined in config.py file.
|
55
|
+
UNISI is a universal data protocol and compact yet highly efficient framework designed for serving and proccessing data in UNISI format. The library includes the web version of Unisi and a comprehensive set of tools and resources for web application development. Supports Python 3.10+.
|
57
56
|
|
58
57
|
### High level - Screen ###
|
59
58
|
The program directory has to contain a screens folder which contains all screens which Unisi has to show.
|
@@ -100,7 +99,7 @@ Connect a browser to localhast:8000 which are by default and will see:
|
|
100
99
|
|
101
100
|

|
102
101
|
|
103
|
-
### 'The fastest way to create Web applications in Python.' is a free crash course video how to use UNISI ###
|
102
|
+
### 'The fastest way to create Web applications in Python.' is a free crash course 1-hour video how to use UNISI ###
|
104
103
|
https://www.unisi.tech/learn
|
105
104
|
|
106
105
|
### Handling events ###
|
@@ -177,7 +176,7 @@ concept_block = Block('Concept block',
|
|
177
176
|
Edit('Working folder','run_folder')
|
178
177
|
], result_table)
|
179
178
|
```
|
180
|
-
If some elements are enumerated inside an array,
|
179
|
+
If some elements are enumerated inside an array, UNISI will display them on a line one after another, otherwise everyone will be displayed on a new own line(s).
|
181
180
|
|
182
181
|
Using a shared block in some screen:
|
183
182
|
```
|
@@ -1,8 +1,8 @@
|
|
1
|
-
unisi-0.3.
|
2
|
-
unisi-0.3.
|
3
|
-
unisi-0.3.
|
4
|
-
unisi-0.3.
|
5
|
-
unisi/__init__.py,sha256=
|
1
|
+
unisi-0.3.14.dist-info/METADATA,sha256=dJlmgx4DW_-CzGkW4kUxEB1Te_Q34JFcKJLxbKZ347A,27231
|
2
|
+
unisi-0.3.14.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
+
unisi-0.3.14.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
4
|
+
unisi-0.3.14.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
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
|
8
8
|
unisi/containers.py,sha256=va4kyqYJ8g7un1hiKx21xXixMXOomXupFPxvS9vga9A,7280
|
@@ -14,7 +14,7 @@ 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=gspPfYcdqCkRLJh8L3J2SkRl-ywwcAsNV_BySjGli1c,5293
|
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
|
@@ -22,7 +22,7 @@ unisi/server.py,sha256=V0I3OAWcebttN1KXHd_-5Vx9tOZ_RzPfSg-3ZJVxWY0,6084
|
|
22
22
|
unisi/tables.py,sha256=tszF62VToSchILzPhJgA4U02MFjv44LopXgD5mYg7fg,13822
|
23
23
|
unisi/units.py,sha256=SCUZAOV0nu9khg6JE0lWwsKjiCVz29hiUCRXyZJffeA,11111
|
24
24
|
unisi/users.py,sha256=h4kjPAo8LkUG9mKSDthLoDC-XVFLlPxjUvXcJdXT47g,16145
|
25
|
-
unisi/utils.py,sha256=
|
25
|
+
unisi/utils.py,sha256=yNhDKCTjHL1H2Suk9DRQkXAZKYy6nqub-dNSdwPwl9I,2625
|
26
26
|
unisi/voicecom.py,sha256=QzS1gIrBeGLO5dEwiu7KIEdJIIVbPBZFGb5nY632Ws8,16707
|
27
27
|
unisi/web/css/885.703d8f36.css,sha256=9O3mFR661UJ_WySZjYt69TbPXhKwz9yEPE7seHR_3aY,3264
|
28
28
|
unisi/web/css/app.31d6cfe0.css,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -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.14.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|