euriai 1.0.16__tar.gz → 1.0.18__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: euriai
3
- Version: 1.0.16
3
+ Version: 1.0.18
4
4
  Summary: Python client for Euri API (euron.one) with CLI, LangChain, and LlamaIndex integration
5
5
  Author: Euri
6
6
  Author-email: tech@euron.one
@@ -4,7 +4,7 @@ Euri AI Python SDK
4
4
  A comprehensive Python SDK for the Euri AI API with integrations for popular frameworks.
5
5
  """
6
6
 
7
- __version__ = "1.0.16"
7
+ __version__ = "1.0.18"
8
8
 
9
9
  # Core imports that should always work
10
10
  try:
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: euriai
3
- Version: 1.0.16
3
+ Version: 1.0.18
4
4
  Summary: Python client for Euri API (euron.one) with CLI, LangChain, and LlamaIndex integration
5
5
  Author: Euri
6
6
  Author-email: tech@euron.one
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="euriai",
5
- version="1.0.16",
5
+ version="1.0.18",
6
6
  description="Python client for Euri API (euron.one) with CLI, LangChain, and LlamaIndex integration",
7
7
  long_description=open("README.md", encoding="utf-8").read(),
8
8
  long_description_content_type="text/markdown",
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
File without changes
File without changes
File without changes
File without changes
File without changes