edge-network-agent 0.1.0__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.
- edge_network_agent-0.1.0/PKG-INFO +66 -0
- edge_network_agent-0.1.0/README.md +57 -0
- edge_network_agent-0.1.0/pyproject.toml +18 -0
- edge_network_agent-0.1.0/setup.cfg +4 -0
- edge_network_agent-0.1.0/src/edge_network_agent/__init__.py +254 -0
- edge_network_agent-0.1.0/src/edge_network_agent/__main__.py +5 -0
- edge_network_agent-0.1.0/src/edge_network_agent/cli.py +87 -0
- edge_network_agent-0.1.0/src/edge_network_agent.egg-info/PKG-INFO +66 -0
- edge_network_agent-0.1.0/src/edge_network_agent.egg-info/SOURCES.txt +10 -0
- edge_network_agent-0.1.0/src/edge_network_agent.egg-info/dependency_links.txt +1 -0
- edge_network_agent-0.1.0/src/edge_network_agent.egg-info/entry_points.txt +2 -0
- edge_network_agent-0.1.0/src/edge_network_agent.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: edge-network-agent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for running and orchestrating AI agents at the edge on the Edge Network.
|
|
5
|
+
Author:
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# edge-network-agent
|
|
11
|
+
|
|
12
|
+
`edge-network-agent` is the Python SDK for running and orchestrating AI agents at the edge on the [Edge Network](https://edge.network). It gives framework-native helpers for LangChain, LlamaIndex, and CrewAI so you can deploy an agent to an edge region, route requests by latency or cost, and call it from your existing code with minimal changes.
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- Deploy agents to edge regions and route by latency, cost, or geography.
|
|
17
|
+
- Drop-in helpers for LangChain, LlamaIndex, and CrewAI runtimes.
|
|
18
|
+
- Cold-start-aware scheduling with warm-pool hints and locality affinity.
|
|
19
|
+
- Streaming and tool-call passthrough that preserves framework semantics.
|
|
20
|
+
- Per-request observability: region, cold-start, tokens, and latency.
|
|
21
|
+
- Failover across regions and provider backends.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install edge-network-agent
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
For a specific framework:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install "edge-network-agent[langchain]"
|
|
33
|
+
pip install "edge-network-agent[crewai]"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick start
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from edge_network_agent import EdgeAgent
|
|
40
|
+
|
|
41
|
+
agent = EdgeAgent(
|
|
42
|
+
name="router",
|
|
43
|
+
region="eu-west", # preferred edge region
|
|
44
|
+
runtime="langchain",
|
|
45
|
+
definition=my_langchain_agent, # a Runnable or agent spec
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
endpoint = agent.deploy(api_key="en_live_...")
|
|
49
|
+
reply = endpoint.invoke({"input": "What is the status of order 99?"})
|
|
50
|
+
print(reply["output"])
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## API
|
|
54
|
+
|
|
55
|
+
- `EdgeAgent(name, region, runtime, definition)` — agent bound to an edge region.
|
|
56
|
+
- `agent.deploy(api_key=...)` — ship the agent and return an `EdgeEndpoint`.
|
|
57
|
+
- `endpoint.invoke(...)` / `endpoint.stream(...)` — call the deployed agent.
|
|
58
|
+
- `EdgeClient(api_key=...).regions.list()` — list available edge regions.
|
|
59
|
+
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
Set `EDGE_NETWORK_API_KEY`. Set `EDGE_NETWORK_PREFERRED_REGION` to default the region.
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# edge-network-agent
|
|
2
|
+
|
|
3
|
+
`edge-network-agent` is the Python SDK for running and orchestrating AI agents at the edge on the [Edge Network](https://edge.network). It gives framework-native helpers for LangChain, LlamaIndex, and CrewAI so you can deploy an agent to an edge region, route requests by latency or cost, and call it from your existing code with minimal changes.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Deploy agents to edge regions and route by latency, cost, or geography.
|
|
8
|
+
- Drop-in helpers for LangChain, LlamaIndex, and CrewAI runtimes.
|
|
9
|
+
- Cold-start-aware scheduling with warm-pool hints and locality affinity.
|
|
10
|
+
- Streaming and tool-call passthrough that preserves framework semantics.
|
|
11
|
+
- Per-request observability: region, cold-start, tokens, and latency.
|
|
12
|
+
- Failover across regions and provider backends.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install edge-network-agent
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
For a specific framework:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install "edge-network-agent[langchain]"
|
|
24
|
+
pip install "edge-network-agent[crewai]"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick start
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from edge_network_agent import EdgeAgent
|
|
31
|
+
|
|
32
|
+
agent = EdgeAgent(
|
|
33
|
+
name="router",
|
|
34
|
+
region="eu-west", # preferred edge region
|
|
35
|
+
runtime="langchain",
|
|
36
|
+
definition=my_langchain_agent, # a Runnable or agent spec
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
endpoint = agent.deploy(api_key="en_live_...")
|
|
40
|
+
reply = endpoint.invoke({"input": "What is the status of order 99?"})
|
|
41
|
+
print(reply["output"])
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
- `EdgeAgent(name, region, runtime, definition)` — agent bound to an edge region.
|
|
47
|
+
- `agent.deploy(api_key=...)` — ship the agent and return an `EdgeEndpoint`.
|
|
48
|
+
- `endpoint.invoke(...)` / `endpoint.stream(...)` — call the deployed agent.
|
|
49
|
+
- `EdgeClient(api_key=...).regions.list()` — list available edge regions.
|
|
50
|
+
|
|
51
|
+
## Configuration
|
|
52
|
+
|
|
53
|
+
Set `EDGE_NETWORK_API_KEY`. Set `EDGE_NETWORK_PREFERRED_REGION` to default the region.
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "edge-network-agent"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python SDK for running and orchestrating AI agents at the edge on the Edge Network."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [{name = ""}]
|
|
13
|
+
|
|
14
|
+
[project.scripts]
|
|
15
|
+
edge-network-agent = "edge_network_agent.cli:main"
|
|
16
|
+
|
|
17
|
+
[tool.setuptools.packages.find]
|
|
18
|
+
where = ["src"]
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"""edge-network-agent — Python SDK for running AI agents at the edge on the Edge Network.
|
|
2
|
+
|
|
3
|
+
Gives framework-native helpers (LangChain, LlamaIndex, CrewAI) so you can
|
|
4
|
+
deploy an agent to an edge region, route requests by latency or cost, and
|
|
5
|
+
call it from your existing code with minimal changes.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import dataclasses
|
|
11
|
+
import json
|
|
12
|
+
import os
|
|
13
|
+
import urllib.error
|
|
14
|
+
import urllib.request
|
|
15
|
+
from typing import Any, Iterator, Protocol, Sequence
|
|
16
|
+
|
|
17
|
+
__version__ = "0.1.0"
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"EdgeAgent",
|
|
21
|
+
"EdgeEndpoint",
|
|
22
|
+
"EdgeClient",
|
|
23
|
+
"Region",
|
|
24
|
+
"InvocationResponse",
|
|
25
|
+
"EdgeNetworkError",
|
|
26
|
+
"AuthError",
|
|
27
|
+
"DeploymentError",
|
|
28
|
+
"Runtime",
|
|
29
|
+
"Transport",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class EdgeNetworkError(Exception):
|
|
34
|
+
"""Base class for edge-network-agent errors."""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class AuthError(EdgeNetworkError):
|
|
38
|
+
"""Raised when the API key is rejected."""
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class DeploymentError(EdgeNetworkError):
|
|
42
|
+
"""Raised when a deployment fails."""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclasses.dataclass
|
|
46
|
+
class Region:
|
|
47
|
+
name: str
|
|
48
|
+
latency_ms: float | None = None
|
|
49
|
+
cost_per_1k_tokens: float | None = None
|
|
50
|
+
available: bool = True
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@dataclasses.dataclass
|
|
54
|
+
class InvocationResponse:
|
|
55
|
+
output: str
|
|
56
|
+
region: str
|
|
57
|
+
cold_start: bool
|
|
58
|
+
tokens: int
|
|
59
|
+
latency_ms: float
|
|
60
|
+
raw: dict[str, Any] = dataclasses.field(default_factory=dict)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@dataclasses.dataclass
|
|
64
|
+
class EdgeEndpoint:
|
|
65
|
+
"""A handle to a deployed agent.
|
|
66
|
+
|
|
67
|
+
Attributes:
|
|
68
|
+
agent_name: The deployed agent's name.
|
|
69
|
+
region: The edge region it lives in.
|
|
70
|
+
endpoint_url: The invocation URL.
|
|
71
|
+
runtime: The framework runtime (langchain, llamaindex, crewai).
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
agent_name: str
|
|
75
|
+
region: str
|
|
76
|
+
endpoint_url: str
|
|
77
|
+
runtime: str
|
|
78
|
+
_client: "EdgeClient | None" = None
|
|
79
|
+
|
|
80
|
+
def invoke(self, payload: dict[str, Any]) -> InvocationResponse:
|
|
81
|
+
if self._client is None:
|
|
82
|
+
raise EdgeNetworkError("endpoint is not bound to a client")
|
|
83
|
+
return self._client._invoke(self.endpoint_url, payload)
|
|
84
|
+
|
|
85
|
+
def stream(self, payload: dict[str, Any]) -> Iterator[InvocationResponse]:
|
|
86
|
+
"""Yield incremental responses.
|
|
87
|
+
|
|
88
|
+
The default implementation yields a single response; a transport that
|
|
89
|
+
streams ``text/event-stream`` would yield per-chunk responses.
|
|
90
|
+
"""
|
|
91
|
+
yield self.invoke(payload)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class Transport(Protocol):
|
|
95
|
+
def request(self, method: str, url: str, headers: dict[str, str], body: bytes | None) -> tuple[int, bytes]:
|
|
96
|
+
...
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class _UrllibTransport:
|
|
100
|
+
def request(self, method: str, url: str, headers: dict[str, str], body: bytes | None) -> tuple[int, bytes]:
|
|
101
|
+
req = urllib.request.Request(url, data=body, method=method, headers=headers)
|
|
102
|
+
try:
|
|
103
|
+
with urllib.request.urlopen(req) as resp:
|
|
104
|
+
return resp.status, resp.read()
|
|
105
|
+
except urllib.error.HTTPError as exc:
|
|
106
|
+
return exc.code, exc.read()
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class EdgeClient:
|
|
110
|
+
"""Top-level client for the Edge Network platform.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
api_key: Defaults to ``EDGE_NETWORK_API_KEY``.
|
|
114
|
+
base_url: Edge Network API base URL.
|
|
115
|
+
transport: Pluggable transport for tests.
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
def __init__(
|
|
119
|
+
self,
|
|
120
|
+
api_key: str | None = None,
|
|
121
|
+
*,
|
|
122
|
+
base_url: str | None = None,
|
|
123
|
+
transport: Transport | None = None,
|
|
124
|
+
) -> None:
|
|
125
|
+
self.api_key = api_key or os.environ.get("EDGE_NETWORK_API_KEY")
|
|
126
|
+
if not self.api_key:
|
|
127
|
+
raise AuthError("api_key required (pass one or set EDGE_NETWORK_API_KEY)")
|
|
128
|
+
self.base_url = (base_url or "https://api.edge.network").rstrip("/")
|
|
129
|
+
self._transport = transport or _UrllibTransport()
|
|
130
|
+
self.regions = _RegionsNamespace(self)
|
|
131
|
+
|
|
132
|
+
def _headers(self) -> dict[str, str]:
|
|
133
|
+
return {
|
|
134
|
+
"Authorization": f"Bearer {self.api_key}",
|
|
135
|
+
"Content-Type": "application/json",
|
|
136
|
+
"Accept": "application/json",
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
def _request(self, method: str, path: str, body: dict[str, Any] | None = None) -> Any:
|
|
140
|
+
url = self.base_url + path
|
|
141
|
+
data = json.dumps(body).encode("utf-8") if body is not None else None
|
|
142
|
+
status, payload = self._transport.request(method, url, self._headers(), data)
|
|
143
|
+
if status == 401:
|
|
144
|
+
raise AuthError(f"unauthorized: HTTP 401 from {path}")
|
|
145
|
+
if status >= 400:
|
|
146
|
+
raise EdgeNetworkError(f"{method} {path} failed: HTTP {status}")
|
|
147
|
+
if not payload:
|
|
148
|
+
return None
|
|
149
|
+
return json.loads(payload.decode("utf-8"))
|
|
150
|
+
|
|
151
|
+
def _invoke(self, endpoint_url: str, payload: dict[str, Any]) -> InvocationResponse:
|
|
152
|
+
data = json.dumps(payload).encode("utf-8")
|
|
153
|
+
status, raw = self._transport.request("POST", endpoint_url, self._headers(), data)
|
|
154
|
+
if status == 401:
|
|
155
|
+
raise AuthError("unauthorized to invoke endpoint")
|
|
156
|
+
if status >= 400:
|
|
157
|
+
raise EdgeNetworkError(f"invoke failed: HTTP {status}")
|
|
158
|
+
body = json.loads(raw.decode("utf-8")) if raw else {}
|
|
159
|
+
return InvocationResponse(
|
|
160
|
+
output=body.get("output", ""),
|
|
161
|
+
region=body.get("region", ""),
|
|
162
|
+
cold_start=bool(body.get("cold_start", False)),
|
|
163
|
+
tokens=int(body.get("tokens", 0)),
|
|
164
|
+
latency_ms=float(body.get("latency_ms", 0.0)),
|
|
165
|
+
raw=body,
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class _RegionsNamespace:
|
|
170
|
+
def __init__(self, client: EdgeClient) -> None:
|
|
171
|
+
self._client = client
|
|
172
|
+
|
|
173
|
+
def list(self) -> list[Region]:
|
|
174
|
+
data = self._client._request("GET", "/v1/regions")
|
|
175
|
+
return [
|
|
176
|
+
Region(
|
|
177
|
+
name=r.get("name", ""),
|
|
178
|
+
latency_ms=r.get("latency_ms"),
|
|
179
|
+
cost_per_1k_tokens=r.get("cost_per_1k_tokens"),
|
|
180
|
+
available=bool(r.get("available", True)),
|
|
181
|
+
)
|
|
182
|
+
for r in data
|
|
183
|
+
]
|
|
184
|
+
|
|
185
|
+
def recommend(self, *, by: str = "latency") -> Region | None:
|
|
186
|
+
regions = [r for r in self.list() if r.available]
|
|
187
|
+
if not regions:
|
|
188
|
+
return None
|
|
189
|
+
if by == "cost":
|
|
190
|
+
return min(regions, key=lambda r: r.cost_per_1k_tokens or float("inf"))
|
|
191
|
+
# default: latency
|
|
192
|
+
return min(regions, key=lambda r: r.latency_ms or float("inf"))
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class EdgeAgent:
|
|
196
|
+
"""An agent definition bound to an edge region.
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
name: A short identifier for the agent.
|
|
200
|
+
region: Preferred edge region (e.g. ``"eu-west"``).
|
|
201
|
+
runtime: One of ``"langchain"``, ``"llamaindex"``, ``"crewai"``.
|
|
202
|
+
definition: The framework-specific agent spec (Runnable, agent dict,
|
|
203
|
+
etc.). Stored opaquely and shipped to the platform on deploy.
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
SUPPORTED_RUNTIMES = ("langchain", "llamaindex", "crewai")
|
|
207
|
+
|
|
208
|
+
def __init__(self, name: str, region: str, runtime: str, definition: Any) -> None:
|
|
209
|
+
if not name:
|
|
210
|
+
raise ValueError("name is required")
|
|
211
|
+
if runtime not in self.SUPPORTED_RUNTIMES:
|
|
212
|
+
raise ValueError(
|
|
213
|
+
f"unsupported runtime {runtime!r}; supported: {', '.join(self.SUPPORTED_RUNTIMES)}"
|
|
214
|
+
)
|
|
215
|
+
if definition is None:
|
|
216
|
+
raise ValueError("definition is required")
|
|
217
|
+
self.name = name
|
|
218
|
+
self.region = region
|
|
219
|
+
self.runtime = runtime
|
|
220
|
+
self.definition = definition
|
|
221
|
+
|
|
222
|
+
def deploy(self, api_key: str | None = None, *, client: EdgeClient | None = None) -> EdgeEndpoint:
|
|
223
|
+
"""Ship the agent to the platform and return an :class:`EdgeEndpoint`."""
|
|
224
|
+
c = client or EdgeClient(api_key=api_key)
|
|
225
|
+
body = {
|
|
226
|
+
"name": self.name,
|
|
227
|
+
"region": self.region,
|
|
228
|
+
"runtime": self.runtime,
|
|
229
|
+
"definition": _serialize_definition(self.definition),
|
|
230
|
+
}
|
|
231
|
+
try:
|
|
232
|
+
data = c._request("POST", "/v1/agents/deploy", body)
|
|
233
|
+
except EdgeNetworkError as exc:
|
|
234
|
+
raise DeploymentError(f"deploy failed: {exc}") from exc
|
|
235
|
+
endpoint = EdgeEndpoint(
|
|
236
|
+
agent_name=data.get("name", self.name),
|
|
237
|
+
region=data.get("region", self.region),
|
|
238
|
+
endpoint_url=data.get("endpoint_url", ""),
|
|
239
|
+
runtime=data.get("runtime", self.runtime),
|
|
240
|
+
_client=c,
|
|
241
|
+
)
|
|
242
|
+
return endpoint
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def _serialize_definition(definition: Any) -> dict[str, Any]:
|
|
246
|
+
"""Best-effort serialization of a framework agent definition."""
|
|
247
|
+
if isinstance(definition, dict):
|
|
248
|
+
return definition
|
|
249
|
+
if hasattr(definition, "to_dict") and callable(definition.to_dict):
|
|
250
|
+
return definition.to_dict()
|
|
251
|
+
if hasattr(definition, "dict") and callable(definition.dict):
|
|
252
|
+
return definition.dict()
|
|
253
|
+
# Fall back to a string repr so the deploy payload is always JSON-serialisable.
|
|
254
|
+
return {"_repr": repr(definition)}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""CLI for edge-network-agent.
|
|
2
|
+
|
|
3
|
+
edge-network regions list
|
|
4
|
+
edge-network deploy --name router --region eu-west --runtime langchain
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import argparse
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
from . import EdgeAgent, EdgeClient, EdgeNetworkError
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _cmd_regions(args: argparse.Namespace) -> int:
|
|
18
|
+
client = EdgeClient(api_key=args.api_key, base_url=args.base_url)
|
|
19
|
+
regions = client.regions.list()
|
|
20
|
+
for r in regions:
|
|
21
|
+
print(f"{r.name}\tlat={r.latency_ms}\tcost={r.cost_per_1k_tokens}\tavailable={r.available}")
|
|
22
|
+
return 0
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _cmd_deploy(args: argparse.Namespace) -> int:
|
|
26
|
+
# The CLI cannot serialize an arbitrary framework definition; it ships a
|
|
27
|
+
# placeholder spec. Real callers use the SDK in-process with a real
|
|
28
|
+
# definition object.
|
|
29
|
+
agent = EdgeAgent(
|
|
30
|
+
name=args.name,
|
|
31
|
+
region=args.region,
|
|
32
|
+
runtime=args.runtime,
|
|
33
|
+
definition={"_cli_placeholder": True, "spec": args.spec or {}},
|
|
34
|
+
)
|
|
35
|
+
try:
|
|
36
|
+
endpoint = agent.deploy(api_key=args.api_key)
|
|
37
|
+
except EdgeNetworkError as exc:
|
|
38
|
+
print(f"error: {exc}", file=sys.stderr)
|
|
39
|
+
return 2
|
|
40
|
+
print(json.dumps({
|
|
41
|
+
"agent": endpoint.agent_name,
|
|
42
|
+
"region": endpoint.region,
|
|
43
|
+
"endpoint_url": endpoint.endpoint_url,
|
|
44
|
+
"runtime": endpoint.runtime,
|
|
45
|
+
}, indent=2))
|
|
46
|
+
return 0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
50
|
+
p = argparse.ArgumentParser(prog="edge-network", description="Edge Network agent CLI")
|
|
51
|
+
p.add_argument("--api-key", default=os.environ.get("EDGE_NETWORK_API_KEY"))
|
|
52
|
+
p.add_argument("--base-url", default=None)
|
|
53
|
+
sub = p.add_subparsers(dest="command", required=True)
|
|
54
|
+
|
|
55
|
+
r = sub.add_parser("regions", help="list/recommend edge regions")
|
|
56
|
+
rs = r.add_subparsers(dest="regions_command", required=True)
|
|
57
|
+
rl = rs.add_parser("list")
|
|
58
|
+
rl.set_defaults(func=_cmd_regions)
|
|
59
|
+
|
|
60
|
+
d = sub.add_parser("deploy", help="deploy an agent to the edge")
|
|
61
|
+
d.add_argument("--name", required=True)
|
|
62
|
+
d.add_argument("--region", required=True)
|
|
63
|
+
d.add_argument("--runtime", required=True, choices=EdgeAgent.SUPPORTED_RUNTIMES)
|
|
64
|
+
d.add_argument("--spec", default=None, help="JSON spec blob")
|
|
65
|
+
d.set_defaults(func=_cmd_deploy)
|
|
66
|
+
|
|
67
|
+
return p
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def main(argv: list[str] | None = None) -> int:
|
|
71
|
+
parser = build_parser()
|
|
72
|
+
args = parser.parse_args(argv)
|
|
73
|
+
func = getattr(args, "func", None)
|
|
74
|
+
if func is None: # pragma: no cover
|
|
75
|
+
parser.print_help()
|
|
76
|
+
return 1
|
|
77
|
+
if hasattr(args, "spec") and isinstance(args.spec, str):
|
|
78
|
+
args.spec = json.loads(args.spec)
|
|
79
|
+
try:
|
|
80
|
+
return int(func(args))
|
|
81
|
+
except EdgeNetworkError as exc:
|
|
82
|
+
print(f"error: {exc}", file=sys.stderr)
|
|
83
|
+
return 2
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
if __name__ == "__main__": # pragma: no cover
|
|
87
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: edge-network-agent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for running and orchestrating AI agents at the edge on the Edge Network.
|
|
5
|
+
Author:
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# edge-network-agent
|
|
11
|
+
|
|
12
|
+
`edge-network-agent` is the Python SDK for running and orchestrating AI agents at the edge on the [Edge Network](https://edge.network). It gives framework-native helpers for LangChain, LlamaIndex, and CrewAI so you can deploy an agent to an edge region, route requests by latency or cost, and call it from your existing code with minimal changes.
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- Deploy agents to edge regions and route by latency, cost, or geography.
|
|
17
|
+
- Drop-in helpers for LangChain, LlamaIndex, and CrewAI runtimes.
|
|
18
|
+
- Cold-start-aware scheduling with warm-pool hints and locality affinity.
|
|
19
|
+
- Streaming and tool-call passthrough that preserves framework semantics.
|
|
20
|
+
- Per-request observability: region, cold-start, tokens, and latency.
|
|
21
|
+
- Failover across regions and provider backends.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install edge-network-agent
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
For a specific framework:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install "edge-network-agent[langchain]"
|
|
33
|
+
pip install "edge-network-agent[crewai]"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick start
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from edge_network_agent import EdgeAgent
|
|
40
|
+
|
|
41
|
+
agent = EdgeAgent(
|
|
42
|
+
name="router",
|
|
43
|
+
region="eu-west", # preferred edge region
|
|
44
|
+
runtime="langchain",
|
|
45
|
+
definition=my_langchain_agent, # a Runnable or agent spec
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
endpoint = agent.deploy(api_key="en_live_...")
|
|
49
|
+
reply = endpoint.invoke({"input": "What is the status of order 99?"})
|
|
50
|
+
print(reply["output"])
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## API
|
|
54
|
+
|
|
55
|
+
- `EdgeAgent(name, region, runtime, definition)` — agent bound to an edge region.
|
|
56
|
+
- `agent.deploy(api_key=...)` — ship the agent and return an `EdgeEndpoint`.
|
|
57
|
+
- `endpoint.invoke(...)` / `endpoint.stream(...)` — call the deployed agent.
|
|
58
|
+
- `EdgeClient(api_key=...).regions.list()` — list available edge regions.
|
|
59
|
+
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
Set `EDGE_NETWORK_API_KEY`. Set `EDGE_NETWORK_PREFERRED_REGION` to default the region.
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/edge_network_agent/__init__.py
|
|
4
|
+
src/edge_network_agent/__main__.py
|
|
5
|
+
src/edge_network_agent/cli.py
|
|
6
|
+
src/edge_network_agent.egg-info/PKG-INFO
|
|
7
|
+
src/edge_network_agent.egg-info/SOURCES.txt
|
|
8
|
+
src/edge_network_agent.egg-info/dependency_links.txt
|
|
9
|
+
src/edge_network_agent.egg-info/entry_points.txt
|
|
10
|
+
src/edge_network_agent.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
edge_network_agent
|