euriai 1.0.16__py3-none-any.whl → 1.0.18__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.
- euriai/__init__.py +1 -1
- euriai/langgraph.py +98 -1
- {euriai-1.0.16.dist-info → euriai-1.0.18.dist-info}/METADATA +1 -1
- {euriai-1.0.16.dist-info → euriai-1.0.18.dist-info}/RECORD +7 -7
- {euriai-1.0.16.dist-info → euriai-1.0.18.dist-info}/WHEEL +0 -0
- {euriai-1.0.16.dist-info → euriai-1.0.18.dist-info}/entry_points.txt +0 -0
- {euriai-1.0.16.dist-info → euriai-1.0.18.dist-info}/top_level.txt +0 -0
euriai/__init__.py
CHANGED
euriai/langgraph.py
CHANGED
@@ -248,6 +248,7 @@ class EuriaiLangGraph:
|
|
248
248
|
default_temperature: float = 0.7,
|
249
249
|
default_max_tokens: int = 1000,
|
250
250
|
enable_checkpointing: bool = True,
|
251
|
+
enable_usage_tracking: bool = True,
|
251
252
|
verbose: bool = True
|
252
253
|
):
|
253
254
|
"""
|
@@ -260,6 +261,7 @@ class EuriaiLangGraph:
|
|
260
261
|
default_temperature: Default temperature
|
261
262
|
default_max_tokens: Default max tokens
|
262
263
|
enable_checkpointing: Enable workflow checkpointing
|
264
|
+
enable_usage_tracking: Enable usage statistics tracking
|
263
265
|
verbose: Enable verbose logging
|
264
266
|
"""
|
265
267
|
if not LANGGRAPH_AVAILABLE:
|
@@ -273,6 +275,7 @@ class EuriaiLangGraph:
|
|
273
275
|
self.default_model = default_model
|
274
276
|
self.default_temperature = default_temperature
|
275
277
|
self.default_max_tokens = default_max_tokens
|
278
|
+
self.enable_usage_tracking = enable_usage_tracking
|
276
279
|
self.verbose = verbose
|
277
280
|
|
278
281
|
# Initialize graph
|
@@ -297,8 +300,10 @@ class EuriaiLangGraph:
|
|
297
300
|
"total_runs": 0,
|
298
301
|
"total_nodes_executed": 0,
|
299
302
|
"avg_execution_time": 0.0,
|
303
|
+
"total_api_calls": 0,
|
300
304
|
"errors": 0,
|
301
|
-
"successful_runs": 0
|
305
|
+
"successful_runs": 0,
|
306
|
+
"ai_nodes": {} # Node-specific statistics
|
302
307
|
}
|
303
308
|
|
304
309
|
# Thread pool for async operations
|
@@ -344,6 +349,15 @@ class EuriaiLangGraph:
|
|
344
349
|
self.nodes[name] = ai_node
|
345
350
|
self.graph.add_node(name, ai_node)
|
346
351
|
|
352
|
+
# Initialize node-specific statistics
|
353
|
+
if self.enable_usage_tracking:
|
354
|
+
self.usage_stats["ai_nodes"][name] = {
|
355
|
+
"total_calls": 0,
|
356
|
+
"total_tokens": 0,
|
357
|
+
"errors": 0,
|
358
|
+
"avg_response_time": 0.0
|
359
|
+
}
|
360
|
+
|
347
361
|
if self.verbose:
|
348
362
|
print(f"Added AI node: {name} (model: {ai_node.model})")
|
349
363
|
|
@@ -399,6 +413,24 @@ class EuriaiLangGraph:
|
|
399
413
|
if self.verbose:
|
400
414
|
print(f"Added condition node: {name} with routes: {routes}")
|
401
415
|
|
416
|
+
def add_conditional_node(
|
417
|
+
self,
|
418
|
+
name: str,
|
419
|
+
condition_func: Callable[[Dict[str, Any]], str],
|
420
|
+
routes: Dict[str, str]
|
421
|
+
) -> None:
|
422
|
+
"""
|
423
|
+
Alias for add_condition_node for more intuitive naming.
|
424
|
+
|
425
|
+
Add a conditional node that routes based on state.
|
426
|
+
|
427
|
+
Args:
|
428
|
+
name: Node name
|
429
|
+
condition_func: Function that returns route key based on state
|
430
|
+
routes: Mapping of route keys to target nodes
|
431
|
+
"""
|
432
|
+
return self.add_condition_node(name, condition_func, routes)
|
433
|
+
|
402
434
|
def add_embedding_node(
|
403
435
|
self,
|
404
436
|
name: str,
|
@@ -704,6 +736,71 @@ class EuriaiLangGraph:
|
|
704
736
|
|
705
737
|
return results
|
706
738
|
|
739
|
+
def get_usage_stats(self) -> Dict[str, Any]:
|
740
|
+
"""
|
741
|
+
Get comprehensive usage statistics for the workflow.
|
742
|
+
|
743
|
+
Returns:
|
744
|
+
Dictionary containing usage statistics including:
|
745
|
+
- total_runs: Total number of workflow runs
|
746
|
+
- successful_runs: Number of successful runs
|
747
|
+
- errors: Number of errors
|
748
|
+
- avg_execution_time: Average execution time per run
|
749
|
+
- total_api_calls: Total API calls made
|
750
|
+
- ai_nodes: Node-specific statistics
|
751
|
+
"""
|
752
|
+
if not self.enable_usage_tracking:
|
753
|
+
return {"message": "Usage tracking is disabled"}
|
754
|
+
|
755
|
+
# Update AI node statistics from individual nodes
|
756
|
+
for node_name, ai_node in self.ai_nodes.items():
|
757
|
+
if node_name in self.usage_stats["ai_nodes"]:
|
758
|
+
node_stats = ai_node.usage_stats
|
759
|
+
self.usage_stats["ai_nodes"][node_name].update({
|
760
|
+
"total_calls": node_stats["total_calls"],
|
761
|
+
"total_tokens": node_stats["total_tokens"],
|
762
|
+
"errors": node_stats["errors"],
|
763
|
+
"avg_response_time": node_stats["avg_response_time"]
|
764
|
+
})
|
765
|
+
|
766
|
+
# Add to total API calls
|
767
|
+
self.usage_stats["total_api_calls"] += node_stats["total_calls"]
|
768
|
+
|
769
|
+
return self.usage_stats.copy()
|
770
|
+
|
771
|
+
def reset_usage_stats(self) -> None:
|
772
|
+
"""Reset all usage statistics."""
|
773
|
+
if not self.enable_usage_tracking:
|
774
|
+
return
|
775
|
+
|
776
|
+
self.usage_stats = {
|
777
|
+
"total_runs": 0,
|
778
|
+
"total_nodes_executed": 0,
|
779
|
+
"avg_execution_time": 0.0,
|
780
|
+
"total_api_calls": 0,
|
781
|
+
"errors": 0,
|
782
|
+
"successful_runs": 0,
|
783
|
+
"ai_nodes": {}
|
784
|
+
}
|
785
|
+
|
786
|
+
# Reset individual AI node stats
|
787
|
+
for ai_node in self.ai_nodes.values():
|
788
|
+
ai_node.usage_stats = {
|
789
|
+
"total_calls": 0,
|
790
|
+
"total_tokens": 0,
|
791
|
+
"errors": 0,
|
792
|
+
"avg_response_time": 0.0
|
793
|
+
}
|
794
|
+
|
795
|
+
# Reinitialize AI node stats
|
796
|
+
for name in self.ai_nodes.keys():
|
797
|
+
self.usage_stats["ai_nodes"][name] = {
|
798
|
+
"total_calls": 0,
|
799
|
+
"total_tokens": 0,
|
800
|
+
"errors": 0,
|
801
|
+
"avg_response_time": 0.0
|
802
|
+
}
|
803
|
+
|
707
804
|
def create_workflow_pattern(self, pattern_type: WorkflowType, **kwargs) -> None:
|
708
805
|
"""
|
709
806
|
Create a pre-defined workflow pattern.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
euriai/__init__.py,sha256=
|
1
|
+
euriai/__init__.py,sha256=7HAeI4LEAaq9UPyxXxt5iV3HBOIn4lGBnJ3VFCGfbBU,6427
|
2
2
|
euriai/autogen.py,sha256=z1WHftUgu3_Sn8zDXmf31onikS0p8TwH5JE4llL7ogk,21144
|
3
3
|
euriai/cli.py,sha256=hF1wiiL2QQSfWf8WlLQyNVDBd4YkbiwmMSoPxVbyPTM,3290
|
4
4
|
euriai/client.py,sha256=L-o6hv9N3md-l-hz-kz5nYVaaZqnrREZlo_0jguhF7E,4066
|
@@ -8,12 +8,12 @@ euriai/embedding.py,sha256=uP66Ph1k9Ou6J5RAkztJxlfyj0S0MESOvZ4ulhnVo-o,1270
|
|
8
8
|
euriai/euri_chat.py,sha256=DEAiet1ReRwB4ljkPYaTl1Nb5uc20-JF-3PQjGQZXk4,3567
|
9
9
|
euriai/euri_embed.py,sha256=g7zs1G-ZBDJjOGJtkkfIcV4LPtRcm9wpVWmrfMGn5EM,2919
|
10
10
|
euriai/langchain.py,sha256=gVF9eh21RC1WtDn7SQoEREUDqOObm5IRx6BFZtB5xcc,34968
|
11
|
-
euriai/langgraph.py,sha256=
|
11
|
+
euriai/langgraph.py,sha256=XfOLj5J5KXIPG_BnXV2MzjbloLNOl0wIf0MbnovoznY,40503
|
12
12
|
euriai/llamaindex.py,sha256=c-ujod2bjL6QIvfAyuIxm1SvSCS00URFElYybKQ5Ew0,26551
|
13
13
|
euriai/n8n.py,sha256=hjkckqyW_hZNL78UkBCof1WvKCKCIjwdvZdAgx6NrB8,3764
|
14
14
|
euriai/smolagents.py,sha256=xlixGx2IWzAPTpSJGsYIK2L-SHGY9Mw1-8GbwVsEYtU,28507
|
15
|
-
euriai-1.0.
|
16
|
-
euriai-1.0.
|
17
|
-
euriai-1.0.
|
18
|
-
euriai-1.0.
|
19
|
-
euriai-1.0.
|
15
|
+
euriai-1.0.18.dist-info/METADATA,sha256=iDxnmLXiPmv3BaMVQlGCThABooMqKAQd13e_xUv4SJo,6807
|
16
|
+
euriai-1.0.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
17
|
+
euriai-1.0.18.dist-info/entry_points.txt,sha256=9OkET8KIGcsjQn8UlnpPKRT75s2KW34jq1__1SXtpMA,43
|
18
|
+
euriai-1.0.18.dist-info/top_level.txt,sha256=TG1htJ8cuD62MXn-NJ7DVF21QHY16w6M_QgfF_Er_EQ,7
|
19
|
+
euriai-1.0.18.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|