Skip to content

Commit af3d1ee

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): OpenAPI spec update via Stainless API (#256)
1 parent ea55198 commit af3d1ee

37 files changed

+38
-2884
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
configured_endpoints: 6
1+
configured_endpoints: 2

README.md

Lines changed: 25 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,11 @@ client = Openlayer(
3232
api_key=os.environ.get("OPENLAYER_API_KEY"),
3333
)
3434

35-
data_stream_response = client.inference_pipelines.data.stream(
36-
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
37-
config={
38-
"input_variable_names": ["user_query"],
39-
"output_column_name": "output",
40-
"num_of_token_column_name": "tokens",
41-
"cost_column_name": "cost",
42-
"timestamp_column_name": "timestamp",
43-
},
44-
rows=[
45-
{
46-
"user_query": "what's the meaning of life?",
47-
"output": "42",
48-
"tokens": 7,
49-
"cost": 0.02,
50-
"timestamp": 1620000000,
51-
}
52-
],
35+
project_create_response = client.projects.create(
36+
name="My Project",
37+
task_type="llm-base",
5338
)
54-
print(data_stream_response.success)
39+
print(project_create_response.id)
5540
```
5641

5742
While you can provide an `api_key` keyword argument,
@@ -75,26 +60,11 @@ client = AsyncOpenlayer(
7560

7661

7762
async def main() -> None:
78-
data_stream_response = await client.inference_pipelines.data.stream(
79-
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
80-
config={
81-
"input_variable_names": ["user_query"],
82-
"output_column_name": "output",
83-
"num_of_token_column_name": "tokens",
84-
"cost_column_name": "cost",
85-
"timestamp_column_name": "timestamp",
86-
},
87-
rows=[
88-
{
89-
"user_query": "what's the meaning of life?",
90-
"output": "42",
91-
"tokens": 7,
92-
"cost": 0.02,
93-
"timestamp": 1620000000,
94-
}
95-
],
63+
project_create_response = await client.projects.create(
64+
name="My Project",
65+
task_type="llm-base",
9666
)
97-
print(data_stream_response.success)
67+
print(project_create_response.id)
9868

9969

10070
asyncio.run(main())
@@ -127,24 +97,9 @@ from openlayer import Openlayer
12797
client = Openlayer()
12898

12999
try:
130-
client.inference_pipelines.data.stream(
131-
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
132-
config={
133-
"input_variable_names": ["user_query"],
134-
"output_column_name": "output",
135-
"num_of_token_column_name": "tokens",
136-
"cost_column_name": "cost",
137-
"timestamp_column_name": "timestamp",
138-
},
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-
],
100+
client.projects.create(
101+
name="My Project",
102+
task_type="llm-base",
148103
)
149104
except openlayer.APIConnectionError as e:
150105
print("The server could not be reached")
@@ -188,24 +143,9 @@ client = Openlayer(
188143
)
189144

190145
# Or, configure per-request:
191-
client.with_options(max_retries=5).inference_pipelines.data.stream(
192-
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
193-
config={
194-
"input_variable_names": ["user_query"],
195-
"output_column_name": "output",
196-
"num_of_token_column_name": "tokens",
197-
"cost_column_name": "cost",
198-
"timestamp_column_name": "timestamp",
199-
},
200-
rows=[
201-
{
202-
"user_query": "what's the meaning of life?",
203-
"output": "42",
204-
"tokens": 7,
205-
"cost": 0.02,
206-
"timestamp": 1620000000,
207-
}
208-
],
146+
client.with_options(max_retries=5).projects.create(
147+
name="My Project",
148+
task_type="llm-base",
209149
)
210150
```
211151

@@ -229,24 +169,9 @@ client = Openlayer(
229169
)
230170

231171
# Override per-request:
232-
client.with_options(timeout=5.0).inference_pipelines.data.stream(
233-
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
234-
config={
235-
"input_variable_names": ["user_query"],
236-
"output_column_name": "output",
237-
"num_of_token_column_name": "tokens",
238-
"cost_column_name": "cost",
239-
"timestamp_column_name": "timestamp",
240-
},
241-
rows=[
242-
{
243-
"user_query": "what's the meaning of life?",
244-
"output": "42",
245-
"tokens": 7,
246-
"cost": 0.02,
247-
"timestamp": 1620000000,
248-
}
249-
],
172+
client.with_options(timeout=5.0).projects.create(
173+
name="My Project",
174+
task_type="llm-base",
250175
)
251176
```
252177

@@ -286,27 +211,14 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
286211
from openlayer import Openlayer
287212

288213
client = Openlayer()
289-
response = client.inference_pipelines.data.with_raw_response.stream(
290-
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
291-
config={
292-
"input_variable_names": ["user_query"],
293-
"output_column_name": "output",
294-
"num_of_token_column_name": "tokens",
295-
"cost_column_name": "cost",
296-
"timestamp_column_name": "timestamp",
297-
},
298-
rows=[{
299-
"user_query": "what's the meaning of life?",
300-
"output": "42",
301-
"tokens": 7,
302-
"cost": 0.02,
303-
"timestamp": 1620000000,
304-
}],
214+
response = client.projects.with_raw_response.create(
215+
name="My Project",
216+
task_type="llm-base",
305217
)
306218
print(response.headers.get('X-My-Header'))
307219

308-
data = response.parse() # get the object that `inference_pipelines.data.stream()` would have returned
309-
print(data.success)
220+
project = response.parse() # get the object that `projects.create()` would have returned
221+
print(project.id)
310222
```
311223

312224
These methods return an [`APIResponse`](https://github.com/openlayer-ai/openlayer-python/tree/main/src/openlayer/_response.py) object.
@@ -320,24 +232,9 @@ The above interface eagerly reads the full response body when you make the reque
320232
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
321233

322234
```python
323-
with client.inference_pipelines.data.with_streaming_response.stream(
324-
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
325-
config={
326-
"input_variable_names": ["user_query"],
327-
"output_column_name": "output",
328-
"num_of_token_column_name": "tokens",
329-
"cost_column_name": "cost",
330-
"timestamp_column_name": "timestamp",
331-
},
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-
],
235+
with client.projects.with_streaming_response.create(
236+
name="My Project",
237+
task_type="llm-base",
341238
) as response:
342239
print(response.headers.get("X-My-Header"))
343240

api.md

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,55 +10,3 @@ Methods:
1010

1111
- <code title="post /projects">client.projects.<a href="./src/openlayer/resources/projects/projects.py">create</a>(\*\*<a href="src/openlayer/types/project_create_params.py">params</a>) -> <a href="./src/openlayer/types/project_create_response.py">ProjectCreateResponse</a></code>
1212
- <code title="get /projects">client.projects.<a href="./src/openlayer/resources/projects/projects.py">list</a>(\*\*<a href="src/openlayer/types/project_list_params.py">params</a>) -> <a href="./src/openlayer/types/project_list_response.py">ProjectListResponse</a></code>
13-
14-
## Commits
15-
16-
Types:
17-
18-
```python
19-
from openlayer.types.projects import CommitListResponse
20-
```
21-
22-
Methods:
23-
24-
- <code title="get /projects/{id}/versions">client.projects.commits.<a href="./src/openlayer/resources/projects/commits.py">list</a>(id, \*\*<a href="src/openlayer/types/projects/commit_list_params.py">params</a>) -> <a href="./src/openlayer/types/projects/commit_list_response.py">CommitListResponse</a></code>
25-
26-
# Commits
27-
28-
## TestResults
29-
30-
Types:
31-
32-
```python
33-
from openlayer.types.commits import TestResultListResponse
34-
```
35-
36-
Methods:
37-
38-
- <code title="get /versions/{id}/results">client.commits.test_results.<a href="./src/openlayer/resources/commits/test_results.py">list</a>(id, \*\*<a href="src/openlayer/types/commits/test_result_list_params.py">params</a>) -> <a href="./src/openlayer/types/commits/test_result_list_response.py">TestResultListResponse</a></code>
39-
40-
# InferencePipelines
41-
42-
## Data
43-
44-
Types:
45-
46-
```python
47-
from openlayer.types.inference_pipelines import DataStreamResponse
48-
```
49-
50-
Methods:
51-
52-
- <code title="post /inference-pipelines/{id}/data-stream">client.inference_pipelines.data.<a href="./src/openlayer/resources/inference_pipelines/data.py">stream</a>(id, \*\*<a href="src/openlayer/types/inference_pipelines/data_stream_params.py">params</a>) -> <a href="./src/openlayer/types/inference_pipelines/data_stream_response.py">DataStreamResponse</a></code>
53-
54-
## TestResults
55-
56-
Types:
57-
58-
```python
59-
from openlayer.types.inference_pipelines import TestResultListResponse
60-
```
61-
62-
Methods:
63-
64-
- <code title="get /inference-pipelines/{id}/results">client.inference_pipelines.test_results.<a href="./src/openlayer/resources/inference_pipelines/test_results.py">list</a>(id, \*\*<a href="src/openlayer/types/inference_pipelines/test_result_list_params.py">params</a>) -> <a href="./src/openlayer/types/inference_pipelines/test_result_list_response.py">TestResultListResponse</a></code>

src/openlayer/_client.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848

4949
class Openlayer(SyncAPIClient):
5050
projects: resources.ProjectsResource
51-
commits: resources.CommitsResource
52-
inference_pipelines: resources.InferencePipelinesResource
5351
with_raw_response: OpenlayerWithRawResponse
5452
with_streaming_response: OpenlayerWithStreamedResponse
5553

@@ -104,8 +102,6 @@ def __init__(
104102
)
105103

106104
self.projects = resources.ProjectsResource(self)
107-
self.commits = resources.CommitsResource(self)
108-
self.inference_pipelines = resources.InferencePipelinesResource(self)
109105
self.with_raw_response = OpenlayerWithRawResponse(self)
110106
self.with_streaming_response = OpenlayerWithStreamedResponse(self)
111107

@@ -229,8 +225,6 @@ def _make_status_error(
229225

230226
class AsyncOpenlayer(AsyncAPIClient):
231227
projects: resources.AsyncProjectsResource
232-
commits: resources.AsyncCommitsResource
233-
inference_pipelines: resources.AsyncInferencePipelinesResource
234228
with_raw_response: AsyncOpenlayerWithRawResponse
235229
with_streaming_response: AsyncOpenlayerWithStreamedResponse
236230

@@ -285,8 +279,6 @@ def __init__(
285279
)
286280

287281
self.projects = resources.AsyncProjectsResource(self)
288-
self.commits = resources.AsyncCommitsResource(self)
289-
self.inference_pipelines = resources.AsyncInferencePipelinesResource(self)
290282
self.with_raw_response = AsyncOpenlayerWithRawResponse(self)
291283
self.with_streaming_response = AsyncOpenlayerWithStreamedResponse(self)
292284

@@ -411,31 +403,21 @@ def _make_status_error(
411403
class OpenlayerWithRawResponse:
412404
def __init__(self, client: Openlayer) -> None:
413405
self.projects = resources.ProjectsResourceWithRawResponse(client.projects)
414-
self.commits = resources.CommitsResourceWithRawResponse(client.commits)
415-
self.inference_pipelines = resources.InferencePipelinesResourceWithRawResponse(client.inference_pipelines)
416406

417407

418408
class AsyncOpenlayerWithRawResponse:
419409
def __init__(self, client: AsyncOpenlayer) -> None:
420410
self.projects = resources.AsyncProjectsResourceWithRawResponse(client.projects)
421-
self.commits = resources.AsyncCommitsResourceWithRawResponse(client.commits)
422-
self.inference_pipelines = resources.AsyncInferencePipelinesResourceWithRawResponse(client.inference_pipelines)
423411

424412

425413
class OpenlayerWithStreamedResponse:
426414
def __init__(self, client: Openlayer) -> None:
427415
self.projects = resources.ProjectsResourceWithStreamingResponse(client.projects)
428-
self.commits = resources.CommitsResourceWithStreamingResponse(client.commits)
429-
self.inference_pipelines = resources.InferencePipelinesResourceWithStreamingResponse(client.inference_pipelines)
430416

431417

432418
class AsyncOpenlayerWithStreamedResponse:
433419
def __init__(self, client: AsyncOpenlayer) -> None:
434420
self.projects = resources.AsyncProjectsResourceWithStreamingResponse(client.projects)
435-
self.commits = resources.AsyncCommitsResourceWithStreamingResponse(client.commits)
436-
self.inference_pipelines = resources.AsyncInferencePipelinesResourceWithStreamingResponse(
437-
client.inference_pipelines
438-
)
439421

440422

441423
Client = Openlayer

src/openlayer/resources/__init__.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from .commits import (
4-
CommitsResource,
5-
AsyncCommitsResource,
6-
CommitsResourceWithRawResponse,
7-
AsyncCommitsResourceWithRawResponse,
8-
CommitsResourceWithStreamingResponse,
9-
AsyncCommitsResourceWithStreamingResponse,
10-
)
113
from .projects import (
124
ProjectsResource,
135
AsyncProjectsResource,
@@ -16,14 +8,6 @@
168
ProjectsResourceWithStreamingResponse,
179
AsyncProjectsResourceWithStreamingResponse,
1810
)
19-
from .inference_pipelines import (
20-
InferencePipelinesResource,
21-
AsyncInferencePipelinesResource,
22-
InferencePipelinesResourceWithRawResponse,
23-
AsyncInferencePipelinesResourceWithRawResponse,
24-
InferencePipelinesResourceWithStreamingResponse,
25-
AsyncInferencePipelinesResourceWithStreamingResponse,
26-
)
2711

2812
__all__ = [
2913
"ProjectsResource",
@@ -32,16 +16,4 @@
3216
"AsyncProjectsResourceWithRawResponse",
3317
"ProjectsResourceWithStreamingResponse",
3418
"AsyncProjectsResourceWithStreamingResponse",
35-
"CommitsResource",
36-
"AsyncCommitsResource",
37-
"CommitsResourceWithRawResponse",
38-
"AsyncCommitsResourceWithRawResponse",
39-
"CommitsResourceWithStreamingResponse",
40-
"AsyncCommitsResourceWithStreamingResponse",
41-
"InferencePipelinesResource",
42-
"AsyncInferencePipelinesResource",
43-
"InferencePipelinesResourceWithRawResponse",
44-
"AsyncInferencePipelinesResourceWithRawResponse",
45-
"InferencePipelinesResourceWithStreamingResponse",
46-
"AsyncInferencePipelinesResourceWithStreamingResponse",
4719
]

0 commit comments

Comments
 (0)