Skip to content

Commit

Permalink
feat: DIA-1402: V1-Submit Prompt auto-refinement job (#322)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Bernstein <matt@humansignal.com>
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 1, 2024
1 parent 34b9124 commit 763a804
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .mock/definition/prompts/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ service:
audiences:
- public
refine_prompt:
path: /api/prompts/{id}/versions/{version_id}/refine-prompt
path: /api/prompts/{prompt_id}/versions/{version_id}/refine
method: POST
auth: true
docs: >
Refine a prompt version using a teacher model and save the refined
prompt as a new version.
path-parameters:
id:
prompt_id:
type: integer
docs: Prompt ID
version_id:
Expand All @@ -195,7 +195,7 @@ service:
type: root.PromptVersion
examples:
- path-parameters:
id: 1
prompt_id: 1
version_id: 1
request: {}
response:
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

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

4 changes: 2 additions & 2 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -15198,7 +15198,7 @@ client = LabelStudio(
api_key="YOUR_API_KEY",
)
client.prompts.versions.refine_prompt(
id=1,
prompt_id=1,
version_id=1,
)

Expand All @@ -15216,7 +15216,7 @@ client.prompts.versions.refine_prompt(
<dl>
<dd>

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

</dd>
</dl>
Expand Down
16 changes: 8 additions & 8 deletions src/label_studio_sdk/prompts/versions/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def update(

def refine_prompt(
self,
id: int,
prompt_id: int,
version_id: int,
*,
teacher_model_provider_connection_id: typing.Optional[int] = OMIT,
Expand All @@ -350,7 +350,7 @@ def refine_prompt(
Parameters
----------
id : int
prompt_id : int
Prompt ID
version_id : int
Expand Down Expand Up @@ -381,12 +381,12 @@ def refine_prompt(
api_key="YOUR_API_KEY",
)
client.prompts.versions.refine_prompt(
id=1,
prompt_id=1,
version_id=1,
)
"""
_response = self._client_wrapper.httpx_client.request(
f"api/prompts/{jsonable_encoder(id)}/versions/{jsonable_encoder(version_id)}/refine-prompt",
f"api/prompts/{jsonable_encoder(prompt_id)}/versions/{jsonable_encoder(version_id)}/refine",
method="POST",
json={
"teacher_model_provider_connection_id": teacher_model_provider_connection_id,
Expand Down Expand Up @@ -728,7 +728,7 @@ async def update(

async def refine_prompt(
self,
id: int,
prompt_id: int,
version_id: int,
*,
teacher_model_provider_connection_id: typing.Optional[int] = OMIT,
Expand All @@ -741,7 +741,7 @@ async def refine_prompt(
Parameters
----------
id : int
prompt_id : int
Prompt ID
version_id : int
Expand Down Expand Up @@ -772,12 +772,12 @@ async def refine_prompt(
api_key="YOUR_API_KEY",
)
await client.prompts.versions.refine_prompt(
id=1,
prompt_id=1,
version_id=1,
)
"""
_response = await self._client_wrapper.httpx_client.request(
f"api/prompts/{jsonable_encoder(id)}/versions/{jsonable_encoder(version_id)}/refine-prompt",
f"api/prompts/{jsonable_encoder(prompt_id)}/versions/{jsonable_encoder(version_id)}/refine",
method="POST",
json={
"teacher_model_provider_connection_id": teacher_model_provider_connection_id,
Expand Down
4 changes: 2 additions & 2 deletions tests/prompts/test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ async def test_refine_prompt(client: LabelStudio, async_client: AsyncLabelStudio
"updated_at": "datetime",
"organization": "integer",
}
response = client.prompts.versions.refine_prompt(id=1, version_id=1)
response = client.prompts.versions.refine_prompt(prompt_id=1, version_id=1)
validate_response(response, expected_response, expected_types)

async_response = await async_client.prompts.versions.refine_prompt(id=1, version_id=1)
async_response = await async_client.prompts.versions.refine_prompt(prompt_id=1, version_id=1)
validate_response(async_response, expected_response, expected_types)

0 comments on commit 763a804

Please sign in to comment.