Skip to content

Commit e6e949f

Browse files
committed
feat(api): update via SDK Studio
1 parent 81e9e2b commit e6e949f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4247
-3982
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ $ pip install -r requirements-dev.lock
3232
## Modifying/Adding code
3333

3434
Most of the SDK is generated code, and any modified code will be overridden on the next generation. The
35-
`src/prompt-foundry-python-sdk/lib/` and `examples/` directories are exceptions and will never be overridden.
35+
`src/prompt_foundry_python_sdk/lib/` and `examples/` directories are exceptions and will never be overridden.
3636

3737
## Adding and running examples
3838

README.md

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Prompt Foundry Python API library
22

3-
[![PyPI version](https://img.shields.io/pypi/v/prompt-foundry-python-sdk.svg)](https://pypi.org/project/prompt-foundry-python-sdk/)
3+
[![PyPI version](https://img.shields.io/pypi/v/prompt_foundry_python_sdk.svg)](https://pypi.org/project/prompt_foundry_python_sdk/)
44

55
The Prompt Foundry Python library provides convenient access to the Prompt Foundry REST API from any Python 3.7+
66
application. The library includes type definitions for all request params and response fields,
@@ -16,7 +16,7 @@ The REST API documentation can be found [on docs.promptfoundry.ai](https://docs.
1616

1717
```sh
1818
# install from PyPI
19-
pip install --pre prompt-foundry-python-sdk
19+
pip install --pre prompt_foundry_python_sdk
2020
```
2121

2222
## Usage
@@ -25,7 +25,7 @@ The full API of this library can be found in [api.md](api.md).
2525

2626
```python
2727
import os
28-
from prompt-foundry-python-sdk import PromptFoundry
28+
from prompt_foundry_python_sdk import PromptFoundry
2929

3030
client = PromptFoundry(
3131
# This is the default and can be omitted
@@ -50,18 +50,20 @@ Simply import `AsyncPromptFoundry` instead of `PromptFoundry` and use `await` wi
5050
```python
5151
import os
5252
import asyncio
53-
from prompt-foundry-python-sdk import AsyncPromptFoundry
53+
from prompt_foundry_python_sdk import AsyncPromptFoundry
5454

5555
client = AsyncPromptFoundry(
5656
# This is the default and can be omitted
5757
api_key=os.environ.get("PROMPT_FOUNDRY_API_KEY"),
5858
)
5959

60+
6061
async def main() -> None:
61-
model_parameters = await client.prompts.get_parameters(
62-
"1212121",
63-
)
64-
print(model_parameters.parameters)
62+
model_parameters = await client.prompts.get_parameters(
63+
"1212121",
64+
)
65+
print(model_parameters.parameters)
66+
6567

6668
asyncio.run(main())
6769
```
@@ -79,29 +81,29 @@ Typed requests and responses provide autocomplete and documentation within your
7981

8082
## Handling errors
8183

82-
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `prompt-foundry-python-sdk.APIConnectionError` is raised.
84+
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `prompt_foundry_python_sdk.APIConnectionError` is raised.
8385

8486
When the API returns a non-success status code (that is, 4xx or 5xx
85-
response), a subclass of `prompt-foundry-python-sdk.APIStatusError` is raised, containing `status_code` and `response` properties.
87+
response), a subclass of `prompt_foundry_python_sdk.APIStatusError` is raised, containing `status_code` and `response` properties.
8688

87-
All errors inherit from `prompt-foundry-python-sdk.APIError`.
89+
All errors inherit from `prompt_foundry_python_sdk.APIError`.
8890

8991
```python
90-
import prompt-foundry-python-sdk
91-
from prompt-foundry-python-sdk import PromptFoundry
92+
import prompt_foundry_python_sdk
93+
from prompt_foundry_python_sdk import PromptFoundry
9294

9395
client = PromptFoundry()
9496

9597
try:
9698
client.prompts.get_parameters(
9799
"1212121",
98100
)
99-
except prompt-foundry-python-sdk.APIConnectionError as e:
101+
except prompt_foundry_python_sdk.APIConnectionError as e:
100102
print("The server could not be reached")
101-
print(e.__cause__) # an underlying Exception, likely raised within httpx.
102-
except prompt-foundry-python-sdk.RateLimitError as e:
103+
print(e.__cause__) # an underlying Exception, likely raised within httpx.
104+
except prompt_foundry_python_sdk.RateLimitError as e:
103105
print("A 429 status code was received; we should back off a bit.")
104-
except prompt-foundry-python-sdk.APIStatusError as e:
106+
except prompt_foundry_python_sdk.APIStatusError as e:
105107
print("Another non-200-range status code was received")
106108
print(e.status_code)
107109
print(e.response)
@@ -129,7 +131,7 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
129131
You can use the `max_retries` option to configure or disable retry settings:
130132

131133
```python
132-
from prompt-foundry-python-sdk import PromptFoundry
134+
from prompt_foundry_python_sdk import PromptFoundry
133135

134136
# Configure the default for all requests:
135137
client = PromptFoundry(
@@ -138,7 +140,7 @@ client = PromptFoundry(
138140
)
139141

140142
# Or, configure per-request:
141-
client.with_options(max_retries = 5).prompts.get_parameters(
143+
client.with_options(max_retries=5).prompts.get_parameters(
142144
"1212121",
143145
)
144146
```
@@ -149,7 +151,7 @@ By default requests time out after 1 minute. You can configure this with a `time
149151
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
150152

151153
```python
152-
from prompt-foundry-python-sdk import PromptFoundry
154+
from prompt_foundry_python_sdk import PromptFoundry
153155

154156
# Configure the default for all requests:
155157
client = PromptFoundry(
@@ -163,7 +165,7 @@ client = PromptFoundry(
163165
)
164166

165167
# Override per-request:
166-
client.with_options(timeout = 5.0).prompts.get_parameters(
168+
client.with_options(timeout=5.0).prompts.get_parameters(
167169
"1212121",
168170
)
169171
```
@@ -201,7 +203,7 @@ if response.my_field is None:
201203
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,
202204

203205
```py
204-
from prompt-foundry-python-sdk import PromptFoundry
206+
from prompt_foundry_python_sdk import PromptFoundry
205207

206208
client = PromptFoundry()
207209
response = client.prompts.with_raw_response.get_parameters(
@@ -213,9 +215,9 @@ prompt = response.parse() # get the object that `prompts.get_parameters()` woul
213215
print(prompt.provider)
214216
```
215217

216-
These methods return an [`APIResponse`](https://github.com/prompt-foundry/python-sdk/tree/main/src/prompt-foundry-python-sdk/_response.py) object.
218+
These methods return an [`APIResponse`](https://github.com/prompt-foundry/python-sdk/tree/main/src/prompt_foundry_python_sdk/_response.py) object.
217219

218-
The async client returns an [`AsyncAPIResponse`](https://github.com/prompt-foundry/python-sdk/tree/main/src/prompt-foundry-python-sdk/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
220+
The async client returns an [`AsyncAPIResponse`](https://github.com/prompt-foundry/python-sdk/tree/main/src/prompt_foundry_python_sdk/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
219221

220222
#### `.with_streaming_response`
221223

@@ -226,11 +228,11 @@ To stream the response body, use `.with_streaming_response` instead, which requi
226228
```python
227229
with client.prompts.with_streaming_response.get_parameters(
228230
"1212121",
229-
) as response :
230-
print(response.headers.get('X-My-Header'))
231+
) as response:
232+
print(response.headers.get("X-My-Header"))
231233

232234
for line in response.iter_lines():
233-
print(line)
235+
print(line)
234236
```
235237

236238
The context manager is required so that the response will reliably be closed.
@@ -279,12 +281,15 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
279281
- Additional [advanced](https://www.python-httpx.org/advanced/#client-instances) functionality
280282

281283
```python
282-
from prompt-foundry-python-sdk import PromptFoundry, DefaultHttpxClient
284+
from prompt_foundry_python_sdk import PromptFoundry, DefaultHttpxClient
283285

284286
client = PromptFoundry(
285287
# Or use the `PROMPT_FOUNDRY_BASE_URL` env var
286288
base_url="http://my.test.server.example.com:8083",
287-
http_client=DefaultHttpxClient(proxies="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),
289+
http_client=DefaultHttpxClient(
290+
proxies="http://my.test.proxy.example.com",
291+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
292+
),
288293
)
289294
```
290295

0 commit comments

Comments
 (0)