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 CHANGED
@@ -1,4 +1,5 @@
1
1
  from .utils import *
2
+ from .llmrag import Q
2
3
  from .units import *
3
4
  from .users import User
4
5
  from .server import start, handle, context_user, context_screen
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
@@ -15,6 +15,9 @@ app_dir = os.getcwd()
15
15
  try:
16
16
  import config
17
17
  except:
18
+ if os.path.exists('config.py'):
19
+ print('Invalid script is started! It has to be in a working directory.')
20
+ exit()
18
21
  f = open('config.py', 'w')
19
22
  f.write("""port = 8000
20
23
  upload_dir = 'web'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unisi
3
- Version: 0.3.12
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 without programming ###
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
- UNISI tech provides a unified system interface and advanced program functionality, eliminating the need for front-end and most back-end programming. It automates common tasks by inner services, as well as unique ones, significantly reducing the necessity for manual programming and effort.
55
- This document serves as a comprehensive guide on utilizing Unisi with Python, along with a compact yet highly efficient framework specifically designed for this purpose. Additionally, the library includes the web version of Unisi, providing developers with a comprehensive set of tools and resources for web application development. Supports Python 3.10+.
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
  ![image](https://github.com/unisi-tech/unisi/assets/1247062/dafebd1f-ae48-4790-9282-dea83d986749)
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, Unisi will display them on a line one after another, otherwise everyone will be displayed on a new own line(s).
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.12.dist-info/METADATA,sha256=qBZmvnqKyPsJ18o5-XdazubDJRcXs11g0ptPMUeh5gk,27440
2
- unisi-0.3.12.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- unisi-0.3.12.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
- unisi-0.3.12.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
- unisi/__init__.py,sha256=JVioDSebhtmoYTldT6ChEayuRTHOgYsAflcxcBYWBTY,279
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=Wh9pQ8kBMlersKxbEDlZ3XeY2grH0_Rfg8I3E2W87hI,3481
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=Uh-BPd6a-i2gMQyJRwANxRN8VQXTtCSunmOAfPnjl9M,2493
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.12.dist-info/RECORD,,
49
+ unisi-0.3.14.dist-info/RECORD,,
File without changes