You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -113,16 +107,16 @@ Typed requests and responses provide autocomplete and documentation within your
113
107
114
108
## Handling errors
115
109
116
-
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `openlayer.APIConnectionError` is raised.
110
+
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `openlayer-test.APIConnectionError` is raised.
117
111
118
112
When the API returns a non-success status code (that is, 4xx or 5xx
119
-
response), a subclass of `openlayer.APIStatusError` is raised, containing `status_code` and `response` properties.
113
+
response), a subclass of `openlayer-test.APIStatusError` is raised, containing `status_code` and `response` properties.
120
114
121
-
All errors inherit from `openlayer.APIError`.
115
+
All errors inherit from `openlayer-test.APIError`.
122
116
123
117
```python
124
-
import openlayer
125
-
from openlayer import Openlayer
118
+
import openlayer-test
119
+
from openlayer-testimport Openlayer
126
120
127
121
client = Openlayer()
128
122
@@ -136,22 +130,20 @@ try:
136
130
"cost_column_name": "cost",
137
131
"timestamp_column_name": "timestamp",
138
132
},
139
-
rows=[
140
-
{
141
-
"user_query": "what's the meaning of life?",
142
-
"output": "42",
143
-
"tokens": 7,
144
-
"cost": 0.02,
145
-
"timestamp": 1620000000,
146
-
}
147
-
],
133
+
rows=[{
134
+
"user_query": "what's the meaning of life?",
135
+
"output": "42",
136
+
"tokens": 7,
137
+
"cost": 0.02,
138
+
"timestamp": 1620000000,
139
+
}],
148
140
)
149
-
except openlayer.APIConnectionError as e:
141
+
except openlayer-test.APIConnectionError as e:
150
142
print("The server could not be reached")
151
-
print(e.__cause__) # an underlying Exception, likely raised within httpx.
152
-
except openlayer.RateLimitError as e:
143
+
print(e.__cause__) # an underlying Exception, likely raised within httpx.
144
+
except openlayer-test.RateLimitError as e:
153
145
print("A 429 status code was received; we should back off a bit.")
154
-
except openlayer.APIStatusError as e:
146
+
except openlayer-test.APIStatusError as e:
155
147
print("Another non-200-range status code was received")
156
148
print(e.status_code)
157
149
print(e.response)
@@ -179,7 +171,7 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
179
171
You can use the `max_retries` option to configure or disable retry settings:
@@ -309,9 +297,9 @@ data = response.parse() # get the object that `inference_pipelines.data.stream(
309
297
print(data.success)
310
298
```
311
299
312
-
These methods return an [`APIResponse`](https://github.com/openlayer-ai/openlayer-python/tree/main/src/openlayer/_response.py) object.
300
+
These methods return an [`APIResponse`](https://github.com/openlayer-ai/openlayer-python/tree/main/src/openlayer-test/_response.py) object.
313
301
314
-
The async client returns an [`AsyncAPIResponse`](https://github.com/openlayer-ai/openlayer-python/tree/main/src/openlayer/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
302
+
The async client returns an [`AsyncAPIResponse`](https://github.com/openlayer-ai/openlayer-python/tree/main/src/openlayer-test/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
315
303
316
304
#### `.with_streaming_response`
317
305
@@ -329,20 +317,18 @@ with client.inference_pipelines.data.with_streaming_response.stream(
329
317
"cost_column_name": "cost",
330
318
"timestamp_column_name": "timestamp",
331
319
},
332
-
rows=[
333
-
{
334
-
"user_query": "what's the meaning of life?",
335
-
"output": "42",
336
-
"tokens": 7,
337
-
"cost": 0.02,
338
-
"timestamp": 1620000000,
339
-
}
340
-
],
341
-
) as response:
342
-
print(response.headers.get("X-My-Header"))
320
+
rows=[{
321
+
"user_query": "what's the meaning of life?",
322
+
"output": "42",
323
+
"tokens": 7,
324
+
"cost": 0.02,
325
+
"timestamp": 1620000000,
326
+
}],
327
+
) as response :
328
+
print(response.headers.get('X-My-Header'))
343
329
344
330
for line in response.iter_lines():
345
-
print(line)
331
+
print(line)
346
332
```
347
333
348
334
The context manager is required so that the response will reliably be closed.
@@ -391,15 +377,12 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
0 commit comments