fere-sdk 0.1.0.dev9__tar.gz → 0.1.0.dev12__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: fere-sdk
3
- Version: 0.1.0.dev9
3
+ Version: 0.1.0.dev12
4
4
  Summary: Python SDK for the FereAI Gateway API
5
5
  Author-email: Fere AI <info@fere.ai>
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fere-sdk"
3
- version = "0.1.0.dev9"
3
+ version = "0.1.0.dev12"
4
4
  description = "Python SDK for the FereAI Gateway API"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -98,7 +98,9 @@ class FereClient:
98
98
  elif event.event == "done":
99
99
  result["done"] = event.data
100
100
  elif event.event == "error":
101
- raise RuntimeError(event.data.get("message", str(event.data)))
101
+ raise RuntimeError(
102
+ event.data.get("message", str(event.data))
103
+ )
102
104
 
103
105
  if tool_responses:
104
106
  result["tool_responses"] = tool_responses
@@ -84,7 +84,6 @@ class FereAPI:
84
84
  params=params,
85
85
  )
86
86
  if resp.status_code == 401:
87
- # Token expired — refresh and retry
88
87
  self._auth.clear_token()
89
88
  headers = await self._headers()
90
89
  resp = await self._client.get(
@@ -144,9 +143,14 @@ class FereAPI:
144
143
  thread_id: str | None = None,
145
144
  agent: str = "ProAgent",
146
145
  ) -> AsyncIterator[ChatEvent]:
147
- """POST /v1/chat — returns an async iterator of SSE events."""
146
+ """POST /v1/chat — returns an async iterator of SSE events.
147
+
148
+ Uses a 1200s read timeout because research queries (especially
149
+ ProDeepResearchAgent) can take up to 20 minutes with long gaps
150
+ between SSE events while the server plans and researches.
151
+ """
148
152
  headers = await self._headers()
149
- body = {
153
+ body: dict[str, Any] = {
150
154
  "query": query,
151
155
  "stream": True,
152
156
  "agent": agent,
@@ -154,11 +158,15 @@ class FereAPI:
154
158
  if thread_id:
155
159
  body["thread_id"] = thread_id
156
160
 
161
+ chat_timeout = httpx.Timeout(
162
+ connect=30.0, read=1200.0, write=30.0, pool=30.0
163
+ )
157
164
  async with self._client.stream(
158
165
  "POST",
159
166
  f"{self.base_url}/v1/chat",
160
167
  json=body,
161
168
  headers=headers,
169
+ timeout=chat_timeout,
162
170
  ) as resp:
163
171
  resp.raise_for_status()
164
172
  event_type = ""
@@ -172,9 +180,13 @@ class FereAPI:
172
180
  try:
173
181
  data = json.loads(raw)
174
182
  except (json.JSONDecodeError, ValueError):
175
- logger.debug("Unparseable SSE data: %r", raw)
183
+ logger.debug(
184
+ "Unparseable SSE data: %r", raw
185
+ )
176
186
  continue
177
- yield ChatEvent(event=event_type, data=data)
187
+ yield ChatEvent(
188
+ event=event_type, data=data
189
+ )
178
190
 
179
191
  async def get_threads(self, skip: int = 0, limit: int = 10) -> list[dict]:
180
192
  """GET /v1/chat/threads"""
File without changes
File without changes