jvserve 2.0.1__tar.gz → 2.0.2__tar.gz

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.

Potentially problematic release.


This version of jvserve might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jvserve
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: FastAPI webserver for loading and interaction with JIVAS agents.
5
5
  Home-page: https://github.com/TrueSelph/jvserve
6
6
  Author: TrueSelph Inc.
@@ -4,5 +4,5 @@ jvserve package initialization.
4
4
  This package provides the webserver for loading and interacting with JIVAS agents.
5
5
  """
6
6
 
7
- __version__ = "2.0.1"
7
+ __version__ = "2.0.2"
8
8
  __supported__jivas__versions__ = ["2.0.0"]
@@ -35,7 +35,7 @@ class AgentInterface:
35
35
  PORT = 8000
36
36
  ROOT_ID = ""
37
37
  TOKEN = ""
38
- EXPIRATION = ""
38
+ EXPIRATION = None
39
39
  LOGGER = logging.getLogger(__name__)
40
40
 
41
41
  @staticmethod
@@ -43,7 +43,42 @@ class AgentInterface:
43
43
  walker_name: str, module_name: str, attributes: dict
44
44
  ) -> _Jac.Walker:
45
45
  """Spawn any walker by name, located in module"""
46
- return JacMachine.get().spawn_walker(walker_name, attributes, module_name)
46
+ # Get the list of modules
47
+ modules = JacMachine.get().list_modules()
48
+
49
+ # Search for the exact module name in the list of modules
50
+ for mod in modules:
51
+ if mod.endswith(module_name):
52
+ module_name = mod
53
+ break
54
+
55
+ try:
56
+ walker = JacMachine.get().spawn_walker(walker_name, attributes, module_name)
57
+ return walker
58
+ except Exception as e:
59
+ raise ValueError(
60
+ f"Unable to spawn walker {walker_name} in module {module_name}: {e}"
61
+ )
62
+
63
+ @staticmethod
64
+ def spawn_node(node_name: str, module_name: str, attributes: dict) -> _Jac.Node:
65
+ """Spawn any node by name, located in module"""
66
+ # Get the list of modules
67
+ modules = JacMachine.get().list_modules()
68
+
69
+ # Search for the exact module name in the list of modules
70
+ for mod in modules:
71
+ if mod.endswith(module_name):
72
+ module_name = mod
73
+ break
74
+
75
+ try:
76
+ node = JacMachine.get().spawn_node(node_name, attributes, module_name)
77
+ return node
78
+ except Exception as e:
79
+ raise ValueError(
80
+ f"Unable to spawn node {node_name} in module {module_name}: {e}"
81
+ )
47
82
 
48
83
  @staticmethod
49
84
  async def webhook_exec(key: str, request: Request) -> JSONResponse:
@@ -110,7 +145,7 @@ class AgentInterface:
110
145
  )
111
146
 
112
147
  except Exception as e:
113
- AgentInterface.EXPIRATION = ""
148
+ AgentInterface.EXPIRATION = None
114
149
  AgentInterface.LOGGER.error(
115
150
  f"an exception occurred: {e}, {traceback.format_exc()}"
116
151
  )
@@ -183,7 +218,7 @@ class AgentInterface:
183
218
  ).response
184
219
 
185
220
  except Exception as e:
186
- AgentInterface.EXPIRATION = ""
221
+ AgentInterface.EXPIRATION = None
187
222
  AgentInterface.LOGGER.error(
188
223
  f"an exception occurred: {e}, {traceback.format_exc()}"
189
224
  )
@@ -231,11 +266,11 @@ class AgentInterface:
231
266
  "verbose": payload.verbose,
232
267
  "reporting": False,
233
268
  },
234
- module_name="agent.action.interact",
269
+ module_name="jivas.agent.action.interact",
235
270
  ),
236
271
  ).response
237
272
  except Exception as e:
238
- AgentInterface.EXPIRATION = ""
273
+ AgentInterface.EXPIRATION = None
239
274
  AgentInterface.LOGGER.error(
240
275
  f"an exception occurred: {e}, {traceback.format_exc()}"
241
276
  )
@@ -277,7 +312,7 @@ class AgentInterface:
277
312
  ),
278
313
  ).response
279
314
  except Exception as e:
280
- AgentInterface.EXPIRATION = ""
315
+ AgentInterface.EXPIRATION = None
281
316
  AgentInterface.LOGGER.error(
282
317
  f"an exception occurred: {e}, {traceback.format_exc()}"
283
318
  )
@@ -318,11 +353,11 @@ class AgentInterface:
318
353
  return result.get("reports", {})
319
354
 
320
355
  if response.status_code == 401:
321
- AgentInterface.EXPIRATION = ""
356
+ AgentInterface.EXPIRATION = None
322
357
  return {}
323
358
 
324
359
  except Exception as e:
325
- AgentInterface.EXPIRATION = ""
360
+ AgentInterface.EXPIRATION = None
326
361
  AgentInterface.LOGGER.error(
327
362
  f"an exception occurred: {e}, {traceback.format_exc()}"
328
363
  )
@@ -362,11 +397,11 @@ class AgentInterface:
362
397
  return result["reports"]
363
398
 
364
399
  if response.status_code == 401:
365
- AgentInterface.EXPIRATION = ""
400
+ AgentInterface.EXPIRATION = None
366
401
  return {}
367
402
 
368
403
  except Exception as e:
369
- AgentInterface.EXPIRATION = ""
404
+ AgentInterface.EXPIRATION = None
370
405
  AgentInterface.LOGGER.error(
371
406
  f"an exception occurred: {e}, {traceback.format_exc()}"
372
407
  )
@@ -444,11 +479,7 @@ class AgentInterface:
444
479
 
445
480
  # if user context still active, return it
446
481
  now = int(time.time())
447
- if (
448
- AgentInterface.EXPIRATION
449
- and AgentInterface.EXPIRATION.isdigit()
450
- and int(AgentInterface.EXPIRATION) > now
451
- ):
482
+ if AgentInterface.EXPIRATION and AgentInterface.EXPIRATION > now:
452
483
  return {
453
484
  "root_id": AgentInterface.ROOT_ID,
454
485
  "token": AgentInterface.TOKEN,
@@ -517,7 +548,7 @@ class AgentInterface:
517
548
  )
518
549
 
519
550
  except Exception as e:
520
- AgentInterface.EXPIRATION = ""
551
+ AgentInterface.EXPIRATION = None
521
552
  AgentInterface.LOGGER.error(
522
553
  f"an exception occurred: {e}, {traceback.format_exc()}"
523
554
  )
@@ -609,7 +640,7 @@ class AgentInterface:
609
640
  )
610
641
 
611
642
  except Exception as e:
612
- AgentInterface.EXPIRATION = ""
643
+ AgentInterface.EXPIRATION = None
613
644
  AgentInterface.LOGGER.error(
614
645
  f"an exception occurred: {e}, {traceback.format_exc()}"
615
646
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jvserve
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: FastAPI webserver for loading and interaction with JIVAS agents.
5
5
  Home-page: https://github.com/TrueSelph/jvserve
6
6
  Author: TrueSelph Inc.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes