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
@@ -107,16 +113,16 @@ Typed requests and responses provide autocomplete and documentation within your
107
113
108
114
## Handling errors
109
115
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.
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.
111
117
112
118
When the API returns a non-success status code (that is, 4xx or 5xx
113
-
response), a subclass of `openlayer-test.APIStatusError` is raised, containing `status_code` and `response` properties.
119
+
response), a subclass of `openlayer.APIStatusError` is raised, containing `status_code` and `response` properties.
114
120
115
-
All errors inherit from `openlayer-test.APIError`.
121
+
All errors inherit from `openlayer.APIError`.
116
122
117
123
```python
118
-
import openlayer-test
119
-
from openlayer-testimport Openlayer
124
+
import openlayer
125
+
from openlayer import Openlayer
120
126
121
127
client = Openlayer()
122
128
@@ -130,20 +136,22 @@ try:
130
136
"cost_column_name": "cost",
131
137
"timestamp_column_name": "timestamp",
132
138
},
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
-
}],
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
+
],
140
148
)
141
-
except openlayer-test.APIConnectionError as e:
149
+
except openlayer.APIConnectionError as e:
142
150
print("The server could not be reached")
143
-
print(e.__cause__) # an underlying Exception, likely raised within httpx.
144
-
except openlayer-test.RateLimitError as e:
151
+
print(e.__cause__) # an underlying Exception, likely raised within httpx.
152
+
except openlayer.RateLimitError as e:
145
153
print("A 429 status code was received; we should back off a bit.")
146
-
except openlayer-test.APIStatusError as e:
154
+
except openlayer.APIStatusError as e:
147
155
print("Another non-200-range status code was received")
148
156
print(e.status_code)
149
157
print(e.response)
@@ -171,7 +179,7 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
171
179
You can use the `max_retries` option to configure or disable retry settings:
@@ -297,9 +309,9 @@ data = response.parse() # get the object that `inference_pipelines.data.stream(
297
309
print(data.success)
298
310
```
299
311
300
-
These methods return an [`APIResponse`](https://github.com/openlayer-ai/openlayer-python/tree/main/src/openlayer-test/_response.py) object.
312
+
These methods return an [`APIResponse`](https://github.com/openlayer-ai/openlayer-python/tree/main/src/openlayer/_response.py) object.
301
313
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.
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.
303
315
304
316
#### `.with_streaming_response`
305
317
@@ -317,18 +329,20 @@ with client.inference_pipelines.data.with_streaming_response.stream(
317
329
"cost_column_name": "cost",
318
330
"timestamp_column_name": "timestamp",
319
331
},
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'))
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"))
329
343
330
344
for line in response.iter_lines():
331
-
print(line)
345
+
print(line)
332
346
```
333
347
334
348
The context manager is required so that the response will reliably be closed.
@@ -377,12 +391,15 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
0 commit comments