Skip to content

Commit a2c45c9

Browse files
feat(api): OpenAPI spec update via Stainless API (#31)
1 parent 0241f0f commit a2c45c9

File tree

7 files changed

+177
-116
lines changed

7 files changed

+177
-116
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 21
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prompt-foundry%2Fprompt-foundry-sdk-d41bc488242c386f09b168a0bf060dba4a5e33e7a724fe5772e150bb62523028.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prompt-foundry%2Fprompt-foundry-sdk-5099b2b6ce467e4cae4520a778d3149d96ddf1331960860509028e7e2ac4b3f7.yml

src/prompt_foundry_python_sdk/_base_client.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def _build_request(
456456
raise RuntimeError(f"Unexpected JSON data type, {type(json_data)}, cannot merge with `extra_body`")
457457

458458
headers = self._build_headers(options)
459-
params = _merge_mappings(self._custom_query, options.params)
459+
params = _merge_mappings(self.default_query, options.params)
460460
content_type = headers.get("Content-Type")
461461

462462
# If the given Content-Type header is multipart/form-data then it
@@ -592,6 +592,12 @@ def default_headers(self) -> dict[str, str | Omit]:
592592
**self._custom_headers,
593593
}
594594

595+
@property
596+
def default_query(self) -> dict[str, object]:
597+
return {
598+
**self._custom_query,
599+
}
600+
595601
def _validate_headers(
596602
self,
597603
headers: Headers, # noqa: ARG002

src/prompt_foundry_python_sdk/resources/evaluation_assertions.py

+75-16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
from __future__ import annotations
44

5+
from typing import Optional
6+
from typing_extensions import Literal
7+
58
import httpx
69

710
from ..types import (
@@ -45,8 +48,12 @@ def create(
4548
self,
4649
*,
4750
evaluation_id: str,
48-
matcher: evaluation_assertion_create_params.Matcher,
49-
target: str,
51+
json_path: Optional[str],
52+
target_value: str,
53+
tool_name: Optional[str],
54+
type: Literal[
55+
"EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"
56+
],
5057
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5158
# The extra values given here take precedence over values defined on the client or passed to this method.
5259
extra_headers: Headers | None = None,
@@ -58,6 +65,14 @@ def create(
5865
Creates a new evaluation assertion
5966
6067
Args:
68+
json_path: A JSON path to use when matching the response. Only required when type is
69+
`JSON_EXACT_MATCH` or `JSON_CONTAINS`.
70+
71+
tool_name: The name of the tool to match. Only required when type is `TOOL_CALLED` or
72+
`TOOL_CALLED_WITH`.
73+
74+
type: The type of evaluation matcher to use.
75+
6176
extra_headers: Send extra headers
6277
6378
extra_query: Add additional query parameters to the request
@@ -71,8 +86,10 @@ def create(
7186
body=maybe_transform(
7287
{
7388
"evaluation_id": evaluation_id,
74-
"matcher": matcher,
75-
"target": target,
89+
"json_path": json_path,
90+
"target_value": target_value,
91+
"tool_name": tool_name,
92+
"type": type,
7693
},
7794
evaluation_assertion_create_params.EvaluationAssertionCreateParams,
7895
),
@@ -87,8 +104,12 @@ def update(
87104
id: str,
88105
*,
89106
evaluation_id: str,
90-
matcher: evaluation_assertion_update_params.Matcher,
91-
target: str,
107+
json_path: Optional[str],
108+
target_value: str,
109+
tool_name: Optional[str],
110+
type: Literal[
111+
"EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"
112+
],
92113
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
93114
# The extra values given here take precedence over values defined on the client or passed to this method.
94115
extra_headers: Headers | None = None,
@@ -100,6 +121,14 @@ def update(
100121
Update an existing evaluation assertion by providing its ID and new data.
101122
102123
Args:
124+
json_path: A JSON path to use when matching the response. Only required when type is
125+
`JSON_EXACT_MATCH` or `JSON_CONTAINS`.
126+
127+
tool_name: The name of the tool to match. Only required when type is `TOOL_CALLED` or
128+
`TOOL_CALLED_WITH`.
129+
130+
type: The type of evaluation matcher to use.
131+
103132
extra_headers: Send extra headers
104133
105134
extra_query: Add additional query parameters to the request
@@ -115,8 +144,10 @@ def update(
115144
body=maybe_transform(
116145
{
117146
"evaluation_id": evaluation_id,
118-
"matcher": matcher,
119-
"target": target,
147+
"json_path": json_path,
148+
"target_value": target_value,
149+
"tool_name": tool_name,
150+
"type": type,
120151
},
121152
evaluation_assertion_update_params.EvaluationAssertionUpdateParams,
122153
),
@@ -245,8 +276,12 @@ async def create(
245276
self,
246277
*,
247278
evaluation_id: str,
248-
matcher: evaluation_assertion_create_params.Matcher,
249-
target: str,
279+
json_path: Optional[str],
280+
target_value: str,
281+
tool_name: Optional[str],
282+
type: Literal[
283+
"EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"
284+
],
250285
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
251286
# The extra values given here take precedence over values defined on the client or passed to this method.
252287
extra_headers: Headers | None = None,
@@ -258,6 +293,14 @@ async def create(
258293
Creates a new evaluation assertion
259294
260295
Args:
296+
json_path: A JSON path to use when matching the response. Only required when type is
297+
`JSON_EXACT_MATCH` or `JSON_CONTAINS`.
298+
299+
tool_name: The name of the tool to match. Only required when type is `TOOL_CALLED` or
300+
`TOOL_CALLED_WITH`.
301+
302+
type: The type of evaluation matcher to use.
303+
261304
extra_headers: Send extra headers
262305
263306
extra_query: Add additional query parameters to the request
@@ -271,8 +314,10 @@ async def create(
271314
body=await async_maybe_transform(
272315
{
273316
"evaluation_id": evaluation_id,
274-
"matcher": matcher,
275-
"target": target,
317+
"json_path": json_path,
318+
"target_value": target_value,
319+
"tool_name": tool_name,
320+
"type": type,
276321
},
277322
evaluation_assertion_create_params.EvaluationAssertionCreateParams,
278323
),
@@ -287,8 +332,12 @@ async def update(
287332
id: str,
288333
*,
289334
evaluation_id: str,
290-
matcher: evaluation_assertion_update_params.Matcher,
291-
target: str,
335+
json_path: Optional[str],
336+
target_value: str,
337+
tool_name: Optional[str],
338+
type: Literal[
339+
"EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"
340+
],
292341
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
293342
# The extra values given here take precedence over values defined on the client or passed to this method.
294343
extra_headers: Headers | None = None,
@@ -300,6 +349,14 @@ async def update(
300349
Update an existing evaluation assertion by providing its ID and new data.
301350
302351
Args:
352+
json_path: A JSON path to use when matching the response. Only required when type is
353+
`JSON_EXACT_MATCH` or `JSON_CONTAINS`.
354+
355+
tool_name: The name of the tool to match. Only required when type is `TOOL_CALLED` or
356+
`TOOL_CALLED_WITH`.
357+
358+
type: The type of evaluation matcher to use.
359+
303360
extra_headers: Send extra headers
304361
305362
extra_query: Add additional query parameters to the request
@@ -315,8 +372,10 @@ async def update(
315372
body=await async_maybe_transform(
316373
{
317374
"evaluation_id": evaluation_id,
318-
"matcher": matcher,
319-
"target": target,
375+
"json_path": json_path,
376+
"target_value": target_value,
377+
"tool_name": tool_name,
378+
"type": type,
320379
},
321380
evaluation_assertion_update_params.EvaluationAssertionUpdateParams,
322381
),

src/prompt_foundry_python_sdk/types/evaluation_assertion.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,27 @@
77

88
from .._models import BaseModel
99

10-
__all__ = ["EvaluationAssertion", "Matcher"]
10+
__all__ = ["EvaluationAssertion"]
1111

1212

13-
class Matcher(BaseModel):
13+
class EvaluationAssertion(BaseModel):
14+
id: str
15+
16+
evaluation_id: str = FieldInfo(alias="evaluationId")
17+
1418
json_path: Optional[str] = FieldInfo(alias="jsonPath", default=None)
1519
"""A JSON path to use when matching the response.
1620
17-
Only required when type is `jsonPath`.
21+
Only required when type is `JSON_EXACT_MATCH` or `JSON_CONTAINS`.
1822
"""
1923

20-
type: Literal["CONTAINS", "EQUALS", "JSON"]
21-
"""The type of evaluation matcher to use."""
24+
target_value: str = FieldInfo(alias="targetValue")
2225

26+
tool_name: Optional[str] = FieldInfo(alias="toolName", default=None)
27+
"""The name of the tool to match.
2328
24-
class EvaluationAssertion(BaseModel):
25-
id: str
26-
27-
evaluation_id: str = FieldInfo(alias="evaluationId")
28-
29-
matcher: Matcher
29+
Only required when type is `TOOL_CALLED` or `TOOL_CALLED_WITH`.
30+
"""
3031

31-
target: str
32+
type: Literal["EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"]
33+
"""The type of evaluation matcher to use."""

src/prompt_foundry_python_sdk/types/evaluation_assertion_create_params.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,27 @@
77

88
from .._utils import PropertyInfo
99

10-
__all__ = ["EvaluationAssertionCreateParams", "Matcher"]
10+
__all__ = ["EvaluationAssertionCreateParams"]
1111

1212

1313
class EvaluationAssertionCreateParams(TypedDict, total=False):
1414
evaluation_id: Required[Annotated[str, PropertyInfo(alias="evaluationId")]]
1515

16-
matcher: Required[Matcher]
16+
json_path: Required[Annotated[Optional[str], PropertyInfo(alias="jsonPath")]]
17+
"""A JSON path to use when matching the response.
1718
18-
target: Required[str]
19+
Only required when type is `JSON_EXACT_MATCH` or `JSON_CONTAINS`.
20+
"""
1921

22+
target_value: Required[Annotated[str, PropertyInfo(alias="targetValue")]]
2023

21-
class Matcher(TypedDict, total=False):
22-
json_path: Required[Annotated[Optional[str], PropertyInfo(alias="jsonPath")]]
23-
"""A JSON path to use when matching the response.
24+
tool_name: Required[Annotated[Optional[str], PropertyInfo(alias="toolName")]]
25+
"""The name of the tool to match.
2426
25-
Only required when type is `jsonPath`.
27+
Only required when type is `TOOL_CALLED` or `TOOL_CALLED_WITH`.
2628
"""
2729

28-
type: Required[Literal["CONTAINS", "EQUALS", "JSON"]]
30+
type: Required[
31+
Literal["EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"]
32+
]
2933
"""The type of evaluation matcher to use."""

src/prompt_foundry_python_sdk/types/evaluation_assertion_update_params.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,27 @@
77

88
from .._utils import PropertyInfo
99

10-
__all__ = ["EvaluationAssertionUpdateParams", "Matcher"]
10+
__all__ = ["EvaluationAssertionUpdateParams"]
1111

1212

1313
class EvaluationAssertionUpdateParams(TypedDict, total=False):
1414
evaluation_id: Required[Annotated[str, PropertyInfo(alias="evaluationId")]]
1515

16-
matcher: Required[Matcher]
16+
json_path: Required[Annotated[Optional[str], PropertyInfo(alias="jsonPath")]]
17+
"""A JSON path to use when matching the response.
1718
18-
target: Required[str]
19+
Only required when type is `JSON_EXACT_MATCH` or `JSON_CONTAINS`.
20+
"""
1921

22+
target_value: Required[Annotated[str, PropertyInfo(alias="targetValue")]]
2023

21-
class Matcher(TypedDict, total=False):
22-
json_path: Required[Annotated[Optional[str], PropertyInfo(alias="jsonPath")]]
23-
"""A JSON path to use when matching the response.
24+
tool_name: Required[Annotated[Optional[str], PropertyInfo(alias="toolName")]]
25+
"""The name of the tool to match.
2426
25-
Only required when type is `jsonPath`.
27+
Only required when type is `TOOL_CALLED` or `TOOL_CALLED_WITH`.
2628
"""
2729

28-
type: Required[Literal["CONTAINS", "EQUALS", "JSON"]]
30+
type: Required[
31+
Literal["EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"]
32+
]
2933
"""The type of evaluation matcher to use."""

0 commit comments

Comments
 (0)