unisi 0.3.22__py3-none-any.whl → 0.3.23__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 CHANGED
@@ -138,7 +138,7 @@ def Q(str_prompt, type_value = str, blank = True, **format_model):
138
138
  if not re.search(r'json', str_prompt, re.IGNORECASE):
139
139
  jtype = jstype(type_value)
140
140
  format = " dd/mm/yyyy string" if type_value == 'date' else f'a JSON {jtype}' if jtype != 'string' else jtype
141
- str_prompt = f"System: You are an intelligent and extremely smart assistant. Output STRONGLY {format}. DO NOT OUTPUT ANY COMMENTARY." + str_prompt
141
+ str_prompt = f"System: You are an intelligent and extremely smart assistant. Output STRONGLY in format {format}. DO NOT OUTPUT ANY COMMENTARY." + str_prompt
142
142
  async def f():
143
143
  if Unishare.llm_cache:
144
144
  if content := Unishare.llm_cache.get(str_prompt):
@@ -183,9 +183,12 @@ def setup_llmrag():
183
183
  import config #the module is loaded before config analysis
184
184
  temperature = getattr(config, 'temperature', 0.0)
185
185
  if config.llm:
186
+ api_key_config = None
187
+ model = None
186
188
  match config.llm:
187
- case ['host', address]:
188
- model = None
189
+ case ['host', address]:
190
+ type = 'host' #provider type is openai for local llms
191
+ case ['host', address, api_key_config, model]:
189
192
  type = 'host' #provider type is openai for local llms
190
193
  case [type, model, address]: ...
191
194
  case [type, model]: address = None
@@ -195,11 +198,14 @@ def setup_llmrag():
195
198
 
196
199
  type = type.lower()
197
200
  match type:
198
- case 'host':
201
+ case 'host':
202
+ api_key_from_config = os.environ.get(api_key_config) if api_key_config else None
203
+ api_key = api_key_from_config if api_key_from_config else 'llm-studio'
199
204
  Unishare.llm_model = ChatOpenAI(
200
- api_key = 'llm-studio',
205
+ api_key = api_key,
201
206
  temperature = temperature,
202
- openai_api_base = address
207
+ openai_api_base = address,
208
+ model = model
203
209
  )
204
210
  case 'openai':
205
211
  Unishare.llm_model = ChatOpenAI(temperature = temperature)
@@ -238,7 +244,7 @@ async def get_property(name, context = '', type = str, options = None):
238
244
  if type == str and re.search(r'date', name, re.IGNORECASE):
239
245
  type = 'date'
240
246
  limits = f', which possible options are {",".join(opt for opt in options)},' if options else ''
241
- prompt = """Context: {context} . Output ONLY "{name}" explicit value{limits} based on the context. """
247
+ prompt = """Output ONLY explicit value{limits} based on the context. Example: Context: Animal: Byrd. Query: Has beak: True. Context: {context}. Query: {name}:"""
242
248
  try:
243
249
  value = await Q(prompt, type)
244
250
  except Exception as e:
unisi/units.py CHANGED
@@ -139,6 +139,11 @@ class Unit:
139
139
  """reduce for external (llm) using if required"""
140
140
  return f'{self.name} : {self.value}'
141
141
 
142
+ @property
143
+ def type_value(self):
144
+ """return python system type if value not 'date' type"""
145
+ return type(self.value) if self.type != 'date' else 'date'
146
+
142
147
  async def emit(self, *_ ):
143
148
  """calcute value by system llm, can be used as a handler"""
144
149
  if Unishare.llm_model and (exactly := getattr(self, 'llm', None)) is not None:
@@ -146,7 +151,7 @@ class Unit:
146
151
  #exactly is requirment that all elements have to have valid value
147
152
  if not exactly or len(elems) == len(self._llm_dependencies):
148
153
  context = ','.join(elems)
149
- self.value = await get_property(self.name, context, self.type, options = getattr(self, 'options', None))
154
+ self.value = await get_property(self.name, context, self.type_value, options = getattr(self, 'options', None))
150
155
  return self
151
156
 
152
157
  def add_changed_handler(self, handler):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unisi
3
- Version: 0.3.22
3
+ Version: 0.3.23
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
@@ -1,7 +1,7 @@
1
- unisi-0.3.22.dist-info/METADATA,sha256=kCucMp5tiBVVORmTkqdhLJ3dV4M-GwVVav9D1zUmx7o,27266
2
- unisi-0.3.22.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- unisi-0.3.22.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
- unisi-0.3.22.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
1
+ unisi-0.3.23.dist-info/METADATA,sha256=Ep_TT9GSF_oRgXAGi_DClaKG-fVaroxN9dP0QglK3pE,27266
2
+ unisi-0.3.23.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ unisi-0.3.23.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
+ unisi-0.3.23.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
5
5
  unisi/__init__.py,sha256=prG4FwJzpNJRX1trto0x_4Bne3kkpEX1dUxcRnIxWVw,301
6
6
  unisi/autotest.py,sha256=DFhGPbXwNjN0dZByLTns0voBEsKccU1DfetfEIhmK6U,8753
7
7
  unisi/common.py,sha256=QHSS-pQDtLZxeZls0eDl8-EmYJZuaRmYO1M9izCly-Y,5791
@@ -14,13 +14,13 @@ 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=Ra462DhayMtcFg-QnF8HdZQGQL3mplzUu7Y9WZTjssM,9413
17
+ unisi/llmrag.py,sha256=nSU1IHrsZG4h7kQCbBk8LOg828HeA1jHJs8FtNJMVZs,9895
18
18
  unisi/multimon.py,sha256=YKwCuvMsMfdgOGkJoqiqh_9wywXMeo9bUhHmbAIUeSE,4060
19
19
  unisi/proxy.py,sha256=QMHSSFJtmVZIexIMAsuFNlF5JpnYNG90rkTM3PYJhY4,7750
20
20
  unisi/reloader.py,sha256=t7z0NgaeJX52044ue_LxITa99WMuE5Jra9qkMEeGhTg,6941
21
21
  unisi/server.py,sha256=owUV_siimohV-PZwMkkIRTnynY0wxpia2la3Vjqy9g8,6658
22
22
  unisi/tables.py,sha256=IBuN9f4AF0SkN9uRPf2WWwdXgAzDnj46y0_C09iC2h4,13809
23
- unisi/units.py,sha256=egOpf1I6ckAtBR9Lj2ot-RVyecIVmmuc5Rkwffl3y6A,11159
23
+ unisi/units.py,sha256=p-3Mg1piS6ZITWEvJylZygWTDqUqInZtjjVq0Cj32ko,11342
24
24
  unisi/users.py,sha256=H5_3n9C-Uhxs_bEPh6_UpfWp7GOh3D9Jhkl2yBbkWqM,16365
25
25
  unisi/utils.py,sha256=yNhDKCTjHL1H2Suk9DRQkXAZKYy6nqub-dNSdwPwl9I,2625
26
26
  unisi/voicecom.py,sha256=QzS1gIrBeGLO5dEwiu7KIEdJIIVbPBZFGb5nY632Ws8,16707
@@ -55,4 +55,4 @@ unisi/web/js/sigma.ce21336a.js,sha256=ngST-065XWOdnR_Xn7U6oGNHTL8fyiOEI9V8-BWRvl
55
55
  unisi/web/js/sigma.ce21336a.js.gz,sha256=zv6oToZZFCfmrZ4G4fw0sOncVe8-dyYNWh2v5QLKZp4,51965
56
56
  unisi/web/js/vendor.6a64dcc5.js,sha256=OSNK2nadU2DnSOEYQQcAmelybITOFZXMxnRyaDoT3yU,747104
57
57
  unisi/web/js/vendor.6a64dcc5.js.gz,sha256=nmtqRzQRWaToxgHxI9hfJd3UrUCg2-fd-0Fjc4H4wu8,245827
58
- unisi-0.3.22.dist-info/RECORD,,
58
+ unisi-0.3.23.dist-info/RECORD,,
File without changes