euriai 0.4__py3-none-any.whl → 1.0.1__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/n8n.py ADDED
@@ -0,0 +1,102 @@
1
+ import requests
2
+ from typing import Any, Dict, Optional
3
+
4
+ class EuriaiN8N:
5
+ """
6
+ Wrapper for n8n workflow automation integration in the EURI SDK.
7
+ Allows triggering n8n workflows and exchanging data via REST API.
8
+
9
+ Template Files:
10
+ - n8n_workflow_template.json: Complete workflow template for Euri API integration
11
+ - N8N_WORKFLOW_GUIDE.md: Comprehensive setup and usage guide
12
+ - n8n_example_usage.py: Python example for interacting with the workflow
13
+ """
14
+ def __init__(self, base_url: str, api_key: Optional[str] = None):
15
+ """
16
+ Initialize the n8n wrapper.
17
+ Args:
18
+ base_url: Base URL of the n8n instance (e.g., http://localhost:5678 or cloud URL)
19
+ api_key: Optional API key for authentication
20
+ """
21
+ self.base_url = base_url.rstrip('/')
22
+ self.api_key = api_key
23
+
24
+ def trigger_workflow(self, workflow_id: str, data: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
25
+ """
26
+ Trigger an n8n workflow by ID, optionally passing data.
27
+ Returns the workflow execution response.
28
+ """
29
+ url = f"{self.base_url}/webhook/{workflow_id}"
30
+ headers = {}
31
+ if self.api_key:
32
+ headers["Authorization"] = f"Bearer {self.api_key}"
33
+ response = requests.post(url, json=data or {}, headers=headers)
34
+ response.raise_for_status()
35
+ return response.json()
36
+
37
+ def chat_completion(
38
+ self,
39
+ webhook_id: str,
40
+ prompt: str,
41
+ euri_api_key: str,
42
+ model: str = "gpt-4.1-nano",
43
+ temperature: float = 0.7,
44
+ max_tokens: int = 500
45
+ ) -> Dict[str, Any]:
46
+ """
47
+ Convenient method to send chat completion requests to the Euri API workflow.
48
+
49
+ Args:
50
+ webhook_id: The webhook ID or path for the Euri chat workflow
51
+ prompt: The message to send to the AI
52
+ euri_api_key: Your Euri API key
53
+ model: The model to use (default: gpt-4.1-nano)
54
+ temperature: Controls randomness (0.0-1.0)
55
+ max_tokens: Maximum tokens in response
56
+
57
+ Returns:
58
+ Dictionary containing the API response
59
+ """
60
+ data = {
61
+ "api_key": euri_api_key,
62
+ "prompt": prompt,
63
+ "model": model,
64
+ "temperature": temperature,
65
+ "max_tokens": max_tokens
66
+ }
67
+
68
+ return self.trigger_workflow(webhook_id, data)
69
+
70
+ def get_workflow_status(self, execution_id: str) -> Dict[str, Any]:
71
+ """
72
+ Get the status of a workflow execution.
73
+
74
+ Args:
75
+ execution_id: The execution ID returned from trigger_workflow
76
+
77
+ Returns:
78
+ Dictionary containing execution status
79
+ """
80
+ url = f"{self.base_url}/api/v1/executions/{execution_id}"
81
+ headers = {}
82
+ if self.api_key:
83
+ headers["Authorization"] = f"Bearer {self.api_key}"
84
+
85
+ response = requests.get(url, headers=headers)
86
+ response.raise_for_status()
87
+ return response.json()
88
+
89
+ @staticmethod
90
+ def get_template_info() -> Dict[str, str]:
91
+ """
92
+ Get information about available template files.
93
+
94
+ Returns:
95
+ Dictionary with template file descriptions
96
+ """
97
+ return {
98
+ "workflow_template": "n8n_workflow_template.json - Complete n8n workflow for Euri API integration",
99
+ "setup_guide": "N8N_WORKFLOW_GUIDE.md - Comprehensive setup and usage documentation",
100
+ "python_example": "n8n_example_usage.py - Python client example for workflow interaction",
101
+ "description": "Ready-to-use n8n workflow template for Euri AI chat completions with any supported model"
102
+ }