Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Oct 3, 2024
1 parent 763a804 commit d9fdbc7
Show file tree
Hide file tree
Showing 5 changed files with 282 additions and 7 deletions.
42 changes: 42 additions & 0 deletions .mock/definition/prompts/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,48 @@ service:
organization: 1
audiences:
- public
cost_estimate:
path: /api/prompts/{prompt_id}/versions/{version_id}/cost-estimate
method: POST
auth: true
docs: >
Get cost estimate for running a prompt version on a particular
project/subset
path-parameters:
prompt_id:
type: integer
docs: Prompt ID
version_id:
type: integer
docs: Prompt Version ID
display-name: >-
Get cost estimate for running a prompt version on a particular
project/subset
request:
name: VersionsCostEstimateRequest
query-parameters:
project_id:
type: integer
docs: ID of the project to get an estimate for running on
project_subset:
type: integer
docs: >-
Subset of the project to get an estimate for running on (e.g.
'All', 'Sample', or 'HasGT')
response:
docs: ''
type: float
examples:
- path-parameters:
prompt_id: 1
version_id: 1
query-parameters:
project_id: 1
project_subset: 1
response:
body: 1.1
audiences:
- public
refine_prompt:
path: /api/prompts/{prompt_id}/versions/{version_id}/refine
method: POST
Expand Down
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 97 additions & 0 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -15161,6 +15161,103 @@ client.prompts.versions.update(
</dl>


</dd>
</dl>
</details>

<details><summary><code>client.prompts.versions.<a href="src/label_studio_sdk/prompts/versions/client.py">cost_estimate</a>(...)</code></summary>
<dl>
<dd>

#### 📝 Description

<dl>
<dd>

<dl>
<dd>

Get cost estimate for running a prompt version on a particular project/subset
</dd>
</dl>
</dd>
</dl>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```python
from label_studio_sdk.client import LabelStudio

client = LabelStudio(
api_key="YOUR_API_KEY",
)
client.prompts.versions.cost_estimate(
prompt_id=1,
version_id=1,
project_id=1,
project_subset=1,
)

```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**prompt_id:** `int` — Prompt ID

</dd>
</dl>

<dl>
<dd>

**version_id:** `int` — Prompt Version ID

</dd>
</dl>

<dl>
<dd>

**project_id:** `int` — ID of the project to get an estimate for running on

</dd>
</dl>

<dl>
<dd>

**project_subset:** `int` — Subset of the project to get an estimate for running on (e.g. 'All', 'Sample', or 'HasGT')

</dd>
</dl>

<dl>
<dd>

**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.

</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>
Expand Down
124 changes: 124 additions & 0 deletions src/label_studio_sdk/prompts/versions/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,68 @@ def update(
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

def cost_estimate(
self,
prompt_id: int,
version_id: int,
*,
project_id: int,
project_subset: int,
request_options: typing.Optional[RequestOptions] = None,
) -> float:
"""
Get cost estimate for running a prompt version on a particular project/subset
Parameters
----------
prompt_id : int
Prompt ID
version_id : int
Prompt Version ID
project_id : int
ID of the project to get an estimate for running on
project_subset : int
Subset of the project to get an estimate for running on (e.g. 'All', 'Sample', or 'HasGT')
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
float
Examples
--------
from label_studio_sdk.client import LabelStudio
client = LabelStudio(
api_key="YOUR_API_KEY",
)
client.prompts.versions.cost_estimate(
prompt_id=1,
version_id=1,
project_id=1,
project_subset=1,
)
"""
_response = self._client_wrapper.httpx_client.request(
f"api/prompts/{jsonable_encoder(prompt_id)}/versions/{jsonable_encoder(version_id)}/cost-estimate",
method="POST",
params={"project_id": project_id, "project_subset": project_subset},
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return pydantic_v1.parse_obj_as(float, _response.json()) # type: ignore
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

def refine_prompt(
self,
prompt_id: int,
Expand Down Expand Up @@ -726,6 +788,68 @@ async def update(
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

async def cost_estimate(
self,
prompt_id: int,
version_id: int,
*,
project_id: int,
project_subset: int,
request_options: typing.Optional[RequestOptions] = None,
) -> float:
"""
Get cost estimate for running a prompt version on a particular project/subset
Parameters
----------
prompt_id : int
Prompt ID
version_id : int
Prompt Version ID
project_id : int
ID of the project to get an estimate for running on
project_subset : int
Subset of the project to get an estimate for running on (e.g. 'All', 'Sample', or 'HasGT')
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
float
Examples
--------
from label_studio_sdk.client import AsyncLabelStudio
client = AsyncLabelStudio(
api_key="YOUR_API_KEY",
)
await client.prompts.versions.cost_estimate(
prompt_id=1,
version_id=1,
project_id=1,
project_subset=1,
)
"""
_response = await self._client_wrapper.httpx_client.request(
f"api/prompts/{jsonable_encoder(prompt_id)}/versions/{jsonable_encoder(version_id)}/cost-estimate",
method="POST",
params={"project_id": project_id, "project_subset": project_subset},
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return pydantic_v1.parse_obj_as(float, _response.json()) # type: ignore
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

async def refine_prompt(
self,
prompt_id: int,
Expand Down
12 changes: 12 additions & 0 deletions tests/prompts/test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ async def test_update(client: LabelStudio, async_client: AsyncLabelStudio) -> No
validate_response(async_response, expected_response, expected_types)


async def test_cost_estimate(client: LabelStudio, async_client: AsyncLabelStudio) -> None:
expected_response: typing.Any = 1.1
expected_types: typing.Any = None
response = client.prompts.versions.cost_estimate(prompt_id=1, version_id=1, project_id=1, project_subset=1)
validate_response(response, expected_response, expected_types)

async_response = await async_client.prompts.versions.cost_estimate(
prompt_id=1, version_id=1, project_id=1, project_subset=1
)
validate_response(async_response, expected_response, expected_types)


async def test_refine_prompt(client: LabelStudio, async_client: AsyncLabelStudio) -> None:
expected_response: typing.Any = {
"title": "title",
Expand Down

0 comments on commit d9fdbc7

Please sign in to comment.