fere-sdk 0.7.0.dev53__tar.gz → 1.0.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.
- {fere_sdk-0.7.0.dev53 → fere_sdk-1.0.0}/.gitignore +3 -0
- {fere_sdk-0.7.0.dev53 → fere_sdk-1.0.0}/PKG-INFO +10 -1
- fere_sdk-1.0.0/README.md +28 -0
- {fere_sdk-0.7.0.dev53 → fere_sdk-1.0.0}/pyproject.toml +1 -1
- {fere_sdk-0.7.0.dev53 → fere_sdk-1.0.0}/src/fere_sdk/client.py +0 -51
- {fere_sdk-0.7.0.dev53 → fere_sdk-1.0.0}/src/fere_sdk/low_level.py +3 -65
- {fere_sdk-0.7.0.dev53 → fere_sdk-1.0.0}/src/fere_sdk/models.py +4 -2
- fere_sdk-0.7.0.dev53/README.md +0 -19
- {fere_sdk-0.7.0.dev53 → fere_sdk-1.0.0}/src/fere_sdk/__init__.py +0 -0
- {fere_sdk-0.7.0.dev53 → fere_sdk-1.0.0}/src/fere_sdk/auth.py +0 -0
- {fere_sdk-0.7.0.dev53 → fere_sdk-1.0.0}/src/fere_sdk/perp_models.py +0 -0
- {fere_sdk-0.7.0.dev53 → fere_sdk-1.0.0}/src/fere_sdk/spot_models.py +0 -0
- {fere_sdk-0.7.0.dev53 → fere_sdk-1.0.0}/src/fere_sdk/timeouts.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: fere-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: Python SDK for the FereAI Gateway API
|
|
5
5
|
Author-email: Fere AI <hello@fereai.xyz>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -32,3 +32,12 @@ client = FereClient(api_key="your-api-key", base_url="https://api.fereai.xyz")
|
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
See the [FereAI docs](https://api.fereai.xyz) for full API reference.
|
|
35
|
+
|
|
36
|
+
## 1.0.0 — breaking changes
|
|
37
|
+
|
|
38
|
+
- Removed chat: `FereClient.chat`, `FereClient.chat_stream`,
|
|
39
|
+
`FereClient.get_threads`, `FereAPI.chat`, `FereAPI.get_threads` and
|
|
40
|
+
`FereAPI.get_thread`. Chat, chat threads and scheduled chats are no longer
|
|
41
|
+
part of the public FereAI API.
|
|
42
|
+
- `ChatEvent` is renamed to `StreamEvent` (still yielded by
|
|
43
|
+
`FereAPI.notification_stream`).
|
fere_sdk-1.0.0/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# fere-sdk
|
|
2
|
+
|
|
3
|
+
Python SDK for the FereAI Gateway API.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install fere-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from fere_sdk import FereClient
|
|
15
|
+
|
|
16
|
+
client = FereClient(api_key="your-api-key", base_url="https://api.fereai.xyz")
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
See the [FereAI docs](https://api.fereai.xyz) for full API reference.
|
|
20
|
+
|
|
21
|
+
## 1.0.0 — breaking changes
|
|
22
|
+
|
|
23
|
+
- Removed chat: `FereClient.chat`, `FereClient.chat_stream`,
|
|
24
|
+
`FereClient.get_threads`, `FereAPI.chat`, `FereAPI.get_threads` and
|
|
25
|
+
`FereAPI.get_thread`. Chat, chat threads and scheduled chats are no longer
|
|
26
|
+
part of the public FereAI API.
|
|
27
|
+
- `ChatEvent` is renamed to `StreamEvent` (still yielded by
|
|
28
|
+
`FereAPI.notification_stream`).
|
|
@@ -107,54 +107,6 @@ class FereClient:
|
|
|
107
107
|
async def __aexit__(self, *exc):
|
|
108
108
|
await self.close()
|
|
109
109
|
|
|
110
|
-
# ----------------------------------------------------------
|
|
111
|
-
# Chat
|
|
112
|
-
# ----------------------------------------------------------
|
|
113
|
-
|
|
114
|
-
async def chat(
|
|
115
|
-
self,
|
|
116
|
-
query: str,
|
|
117
|
-
thread_id: str | None = None,
|
|
118
|
-
agent: str = "ProAgent",
|
|
119
|
-
) -> dict:
|
|
120
|
-
"""Send a chat query and return the final answer.
|
|
121
|
-
|
|
122
|
-
Returns dict with ``answer``, ``chat_id``, and
|
|
123
|
-
optionally ``tool_responses``.
|
|
124
|
-
"""
|
|
125
|
-
result: dict[str, Any] = {}
|
|
126
|
-
tool_responses: list[dict] = []
|
|
127
|
-
|
|
128
|
-
async for event in self._api.chat(
|
|
129
|
-
query, thread_id=thread_id, agent=agent
|
|
130
|
-
):
|
|
131
|
-
if event.event == "meta":
|
|
132
|
-
result["chat_id"] = event.data.get("chat_id")
|
|
133
|
-
elif event.event == "tool_response":
|
|
134
|
-
tool_responses.append(event.data)
|
|
135
|
-
elif event.event == "answer":
|
|
136
|
-
result["answer"] = event.data.get("text", "")
|
|
137
|
-
elif event.event == "done":
|
|
138
|
-
result["done"] = event.data
|
|
139
|
-
elif event.event == "error":
|
|
140
|
-
raise RuntimeError(event.data.get("message", str(event.data)))
|
|
141
|
-
|
|
142
|
-
if tool_responses:
|
|
143
|
-
result["tool_responses"] = tool_responses
|
|
144
|
-
return result
|
|
145
|
-
|
|
146
|
-
async def chat_stream(
|
|
147
|
-
self,
|
|
148
|
-
query: str,
|
|
149
|
-
thread_id: str | None = None,
|
|
150
|
-
agent: str = "ProAgent",
|
|
151
|
-
):
|
|
152
|
-
"""Stream chat events. Yields ChatEvent objects."""
|
|
153
|
-
async for event in self._api.chat(
|
|
154
|
-
query, thread_id=thread_id, agent=agent
|
|
155
|
-
):
|
|
156
|
-
yield event
|
|
157
|
-
|
|
158
110
|
# ----------------------------------------------------------
|
|
159
111
|
# Trading (blocks until complete)
|
|
160
112
|
# ----------------------------------------------------------
|
|
@@ -497,9 +449,6 @@ class FereClient:
|
|
|
497
449
|
async def get_positions(self) -> Any:
|
|
498
450
|
return await self._api.get_positions()
|
|
499
451
|
|
|
500
|
-
async def get_threads(self, skip: int = 0, limit: int = 10) -> list[dict]:
|
|
501
|
-
return await self._api.get_threads(skip=skip, limit=limit)
|
|
502
|
-
|
|
503
452
|
async def get_limit_orders(self, status: str | None = None) -> list[dict]:
|
|
504
453
|
return await self._api.get_limit_orders(status=status)
|
|
505
454
|
|
|
@@ -11,7 +11,6 @@ import httpx
|
|
|
11
11
|
|
|
12
12
|
from .auth import AuthManager, StaticTokenAuthManager
|
|
13
13
|
from .models import (
|
|
14
|
-
ChatEvent,
|
|
15
14
|
CreditsInfo,
|
|
16
15
|
DepositRequest,
|
|
17
16
|
HooksRequest,
|
|
@@ -25,6 +24,7 @@ from .models import (
|
|
|
25
24
|
SpotCancelRequest,
|
|
26
25
|
SpotSellRequest,
|
|
27
26
|
SpotTpSlRequest,
|
|
27
|
+
StreamEvent,
|
|
28
28
|
SwapRequest,
|
|
29
29
|
TaskResponse,
|
|
30
30
|
TaskStatusResponse,
|
|
@@ -161,68 +161,6 @@ class FereAPI:
|
|
|
161
161
|
resp.raise_for_status()
|
|
162
162
|
return resp.json()
|
|
163
163
|
|
|
164
|
-
# ----------------------------------------------------------
|
|
165
|
-
# Chat
|
|
166
|
-
# ----------------------------------------------------------
|
|
167
|
-
|
|
168
|
-
async def chat(
|
|
169
|
-
self,
|
|
170
|
-
query: str,
|
|
171
|
-
thread_id: str | None = None,
|
|
172
|
-
agent: str = "ProAgent",
|
|
173
|
-
) -> AsyncIterator[ChatEvent]:
|
|
174
|
-
"""POST /v1/chat — returns an async iterator of SSE events.
|
|
175
|
-
|
|
176
|
-
Uses a 1200s read timeout because research queries (especially
|
|
177
|
-
ProDeepResearchAgent) can take up to 20 minutes with long gaps
|
|
178
|
-
between SSE events while the server plans and researches.
|
|
179
|
-
"""
|
|
180
|
-
headers = await self._headers()
|
|
181
|
-
body: dict[str, Any] = {
|
|
182
|
-
"query": query,
|
|
183
|
-
"stream": True,
|
|
184
|
-
"agent": agent,
|
|
185
|
-
}
|
|
186
|
-
if thread_id:
|
|
187
|
-
body["thread_id"] = thread_id
|
|
188
|
-
|
|
189
|
-
chat_timeout = httpx.Timeout(
|
|
190
|
-
connect=30.0, read=1200.0, write=30.0, pool=30.0
|
|
191
|
-
)
|
|
192
|
-
async with self._client.stream(
|
|
193
|
-
"POST",
|
|
194
|
-
f"{self.base_url}/v1/chat",
|
|
195
|
-
json=body,
|
|
196
|
-
headers=headers,
|
|
197
|
-
timeout=chat_timeout,
|
|
198
|
-
) as resp:
|
|
199
|
-
resp.raise_for_status()
|
|
200
|
-
event_type = ""
|
|
201
|
-
async for line in resp.aiter_lines():
|
|
202
|
-
if line.startswith("event:"):
|
|
203
|
-
event_type = line[6:].strip()
|
|
204
|
-
elif line.startswith("data:"):
|
|
205
|
-
raw = line[5:].strip()
|
|
206
|
-
if not raw:
|
|
207
|
-
continue
|
|
208
|
-
try:
|
|
209
|
-
data = json.loads(raw)
|
|
210
|
-
except (json.JSONDecodeError, ValueError):
|
|
211
|
-
logger.debug("Unparseable SSE data: %r", raw)
|
|
212
|
-
continue
|
|
213
|
-
yield ChatEvent(event=event_type, data=data)
|
|
214
|
-
|
|
215
|
-
async def get_threads(self, skip: int = 0, limit: int = 10) -> list[dict]:
|
|
216
|
-
"""GET /v1/chat/threads"""
|
|
217
|
-
return await self._authed_get(
|
|
218
|
-
"/v1/chat/threads",
|
|
219
|
-
params={"skip": skip, "limit": limit},
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
async def get_thread(self, thread_id: str) -> list[dict]:
|
|
223
|
-
"""GET /v1/chat/threads/{thread_id}"""
|
|
224
|
-
return await self._authed_get(f"/v1/chat/threads/{thread_id}")
|
|
225
|
-
|
|
226
164
|
# ----------------------------------------------------------
|
|
227
165
|
# Tools
|
|
228
166
|
# ----------------------------------------------------------
|
|
@@ -580,7 +518,7 @@ class FereAPI:
|
|
|
580
518
|
|
|
581
519
|
async def notification_stream(
|
|
582
520
|
self,
|
|
583
|
-
) -> AsyncIterator[
|
|
521
|
+
) -> AsyncIterator[StreamEvent]:
|
|
584
522
|
"""GET /v1/notifications/stream — SSE stream."""
|
|
585
523
|
headers = await self._headers()
|
|
586
524
|
async with self._client.stream(
|
|
@@ -602,7 +540,7 @@ class FereAPI:
|
|
|
602
540
|
except (json.JSONDecodeError, ValueError):
|
|
603
541
|
logger.debug("Unparseable SSE data: %r", raw)
|
|
604
542
|
continue
|
|
605
|
-
yield
|
|
543
|
+
yield StreamEvent(event=event_type, data=data)
|
|
606
544
|
|
|
607
545
|
# ----------------------------------------------------------
|
|
608
546
|
# Credits / User / Chains
|
|
@@ -25,7 +25,7 @@ from .spot_models import ( # noqa: E402,F401
|
|
|
25
25
|
__all__ = [
|
|
26
26
|
"TaskResponse",
|
|
27
27
|
"TaskStatusResponse",
|
|
28
|
-
"
|
|
28
|
+
"StreamEvent",
|
|
29
29
|
"TokenInfo",
|
|
30
30
|
"RegisterInfo",
|
|
31
31
|
"WalletInfo",
|
|
@@ -64,7 +64,9 @@ class TaskStatusResponse:
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
@dataclass
|
|
67
|
-
class
|
|
67
|
+
class StreamEvent:
|
|
68
|
+
"""One server-sent event (``event:`` name + JSON ``data:`` payload)."""
|
|
69
|
+
|
|
68
70
|
event: str
|
|
69
71
|
data: dict[str, Any]
|
|
70
72
|
|
fere_sdk-0.7.0.dev53/README.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# fere-sdk
|
|
2
|
-
|
|
3
|
-
Python SDK for the FereAI Gateway API.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pip install fere-sdk
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```python
|
|
14
|
-
from fere_sdk import FereClient
|
|
15
|
-
|
|
16
|
-
client = FereClient(api_key="your-api-key", base_url="https://api.fereai.xyz")
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
See the [FereAI docs](https://api.fereai.xyz) for full API reference.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|