splox 0.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.
splox/__init__.py ADDED
@@ -0,0 +1,86 @@
1
+ """Splox Python SDK — Run workflows, manage chats, and monitor execution."""
2
+
3
+ from splox._client import AsyncSploxClient, SploxClient
4
+ from splox._models import (
5
+ Chat,
6
+ ChatHistoryResponse,
7
+ ChatListResponse,
8
+ ChatMessage,
9
+ ChatMessageContent,
10
+ ChildExecution,
11
+ Edge,
12
+ EventResponse,
13
+ ExecutionNode,
14
+ ExecutionTree,
15
+ ExecutionTreeResponse,
16
+ HistoryResponse,
17
+ MemoryActionResponse,
18
+ MemoryGetResponse,
19
+ MemoryInstance,
20
+ MemoryListResponse,
21
+ MemoryMessage,
22
+ Node,
23
+ NodeExecution,
24
+ Pagination,
25
+ RunResponse,
26
+ SSEEvent,
27
+ StartNodesResponse,
28
+ Workflow,
29
+ WorkflowFull,
30
+ WorkflowListResponse,
31
+ WorkflowRequest,
32
+ WorkflowRequestFile,
33
+ WorkflowVersion,
34
+ WorkflowVersionListResponse,
35
+ UserBalance,
36
+ BalanceTransaction,
37
+ TransactionPagination,
38
+ TransactionHistoryResponse,
39
+ ActivityStats,
40
+ DailyActivity,
41
+ DailyActivityResponse,
42
+ )
43
+
44
+ __all__ = [
45
+ "SploxClient",
46
+ "AsyncSploxClient",
47
+ "Chat",
48
+ "ChatHistoryResponse",
49
+ "ChatListResponse",
50
+ "ChatMessage",
51
+ "ChatMessageContent",
52
+ "ChildExecution",
53
+ "Edge",
54
+ "EventResponse",
55
+ "ExecutionNode",
56
+ "ExecutionTree",
57
+ "ExecutionTreeResponse",
58
+ "HistoryResponse",
59
+ "MemoryActionResponse",
60
+ "MemoryGetResponse",
61
+ "MemoryInstance",
62
+ "MemoryListResponse",
63
+ "MemoryMessage",
64
+ "Node",
65
+ "NodeExecution",
66
+ "Pagination",
67
+ "RunResponse",
68
+ "SSEEvent",
69
+ "StartNodesResponse",
70
+ "Workflow",
71
+ "WorkflowFull",
72
+ "WorkflowListResponse",
73
+ "WorkflowRequest",
74
+ "WorkflowRequestFile",
75
+ "WorkflowVersion",
76
+ "WorkflowVersionListResponse",
77
+ "UserBalance",
78
+ "BalanceTransaction",
79
+ "TransactionPagination",
80
+ "TransactionHistoryResponse",
81
+ "ActivityStats",
82
+ "DailyActivity",
83
+ "DailyActivityResponse",
84
+ ]
85
+
86
+ __version__ = "0.1.0"
splox/_client.py ADDED
@@ -0,0 +1,128 @@
1
+ """Splox client — sync and async flavors."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from typing import Optional
7
+
8
+ from splox._resources import (
9
+ AsyncChats,
10
+ AsyncEvents,
11
+ AsyncMemory,
12
+ AsyncWorkflows,
13
+ AsyncBilling,
14
+ Billing,
15
+ Chats,
16
+ Events,
17
+ Memory,
18
+ Workflows,
19
+ )
20
+ from splox._transport import DEFAULT_BASE_URL, DEFAULT_TIMEOUT, AsyncTransport, SyncTransport
21
+
22
+
23
+ class SploxClient:
24
+ """Synchronous Splox API client.
25
+
26
+ Usage::
27
+
28
+ from splox import SploxClient
29
+
30
+ client = SploxClient(api_key="your-api-key")
31
+ chat = client.chats.create(name="Session", resource_id="wf-id")
32
+ result = client.workflows.run(
33
+ workflow_version_id="ver-id",
34
+ chat_id=chat.id,
35
+ start_node_id="node-id",
36
+ query="Hello",
37
+ )
38
+ """
39
+
40
+ def __init__(
41
+ self,
42
+ api_key: Optional[str] = None,
43
+ *,
44
+ base_url: str = DEFAULT_BASE_URL,
45
+ timeout: float = DEFAULT_TIMEOUT,
46
+ ) -> None:
47
+ """Initialize the Splox client.
48
+
49
+ Args:
50
+ api_key: API token. Falls back to ``SPLOX_API_KEY`` env var.
51
+ base_url: API base URL (default: ``https://app.splox.io/api/v1``).
52
+ timeout: Request timeout in seconds (default: 30).
53
+ """
54
+ resolved_key = api_key or os.environ.get("SPLOX_API_KEY")
55
+ self._transport = SyncTransport(
56
+ base_url=base_url,
57
+ api_key=resolved_key,
58
+ timeout=timeout,
59
+ )
60
+ self.workflows = Workflows(self._transport)
61
+ self.chats = Chats(self._transport)
62
+ self.events = Events(self._transport)
63
+ self.billing = Billing(self._transport)
64
+ self.memory = Memory(self._transport)
65
+
66
+ def close(self) -> None:
67
+ """Close the underlying HTTP connection pool."""
68
+ self._transport.close()
69
+
70
+ def __enter__(self) -> SploxClient:
71
+ return self
72
+
73
+ def __exit__(self, *args: object) -> None:
74
+ self.close()
75
+
76
+
77
+ class AsyncSploxClient:
78
+ """Asynchronous Splox API client.
79
+
80
+ Usage::
81
+
82
+ from splox import AsyncSploxClient
83
+
84
+ async with AsyncSploxClient(api_key="your-api-key") as client:
85
+ chat = await client.chats.create(name="Session", resource_id="wf-id")
86
+ result = await client.workflows.run(
87
+ workflow_version_id="ver-id",
88
+ chat_id=chat.id,
89
+ start_node_id="node-id",
90
+ query="Hello",
91
+ )
92
+ """
93
+
94
+ def __init__(
95
+ self,
96
+ api_key: Optional[str] = None,
97
+ *,
98
+ base_url: str = DEFAULT_BASE_URL,
99
+ timeout: float = DEFAULT_TIMEOUT,
100
+ ) -> None:
101
+ """Initialize the async Splox client.
102
+
103
+ Args:
104
+ api_key: API token. Falls back to ``SPLOX_API_KEY`` env var.
105
+ base_url: API base URL (default: ``https://app.splox.io/api/v1``).
106
+ timeout: Request timeout in seconds (default: 30).
107
+ """
108
+ resolved_key = api_key or os.environ.get("SPLOX_API_KEY")
109
+ self._transport = AsyncTransport(
110
+ base_url=base_url,
111
+ api_key=resolved_key,
112
+ timeout=timeout,
113
+ )
114
+ self.workflows = AsyncWorkflows(self._transport)
115
+ self.chats = AsyncChats(self._transport)
116
+ self.events = AsyncEvents(self._transport)
117
+ self.billing = AsyncBilling(self._transport)
118
+ self.memory = AsyncMemory(self._transport)
119
+
120
+ async def close(self) -> None:
121
+ """Close the underlying HTTP connection pool."""
122
+ await self._transport.close()
123
+
124
+ async def __aenter__(self) -> AsyncSploxClient:
125
+ return self
126
+
127
+ async def __aexit__(self, *args: object) -> None:
128
+ await self.close()