Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 21
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prompt-foundry%2Fprompt-foundry-sdk-d41bc488242c386f09b168a0bf060dba4a5e33e7a724fe5772e150bb62523028.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prompt-foundry%2Fprompt-foundry-sdk-5099b2b6ce467e4cae4520a778d3149d96ddf1331960860509028e7e2ac4b3f7.yml
8 changes: 7 additions & 1 deletion src/prompt_foundry_python_sdk/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def _build_request(
raise RuntimeError(f"Unexpected JSON data type, {type(json_data)}, cannot merge with `extra_body`")

headers = self._build_headers(options)
params = _merge_mappings(self._custom_query, options.params)
params = _merge_mappings(self.default_query, options.params)
content_type = headers.get("Content-Type")

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

@property
def default_query(self) -> dict[str, object]:
return {
**self._custom_query,
}

def _validate_headers(
self,
headers: Headers, # noqa: ARG002
Expand Down
91 changes: 75 additions & 16 deletions src/prompt_foundry_python_sdk/resources/evaluation_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

from __future__ import annotations

from typing import Optional
from typing_extensions import Literal

import httpx

from ..types import (
Expand Down Expand Up @@ -45,8 +48,12 @@ def create(
self,
*,
evaluation_id: str,
matcher: evaluation_assertion_create_params.Matcher,
target: str,
json_path: Optional[str],
target_value: str,
tool_name: Optional[str],
type: Literal[
"EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"
],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -58,6 +65,14 @@ def create(
Creates a new evaluation assertion

Args:
json_path: A JSON path to use when matching the response. Only required when type is
`JSON_EXACT_MATCH` or `JSON_CONTAINS`.

tool_name: The name of the tool to match. Only required when type is `TOOL_CALLED` or
`TOOL_CALLED_WITH`.

type: The type of evaluation matcher to use.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -71,8 +86,10 @@ def create(
body=maybe_transform(
{
"evaluation_id": evaluation_id,
"matcher": matcher,
"target": target,
"json_path": json_path,
"target_value": target_value,
"tool_name": tool_name,
"type": type,
},
evaluation_assertion_create_params.EvaluationAssertionCreateParams,
),
Expand All @@ -87,8 +104,12 @@ def update(
id: str,
*,
evaluation_id: str,
matcher: evaluation_assertion_update_params.Matcher,
target: str,
json_path: Optional[str],
target_value: str,
tool_name: Optional[str],
type: Literal[
"EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"
],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -100,6 +121,14 @@ def update(
Update an existing evaluation assertion by providing its ID and new data.

Args:
json_path: A JSON path to use when matching the response. Only required when type is
`JSON_EXACT_MATCH` or `JSON_CONTAINS`.

tool_name: The name of the tool to match. Only required when type is `TOOL_CALLED` or
`TOOL_CALLED_WITH`.

type: The type of evaluation matcher to use.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -115,8 +144,10 @@ def update(
body=maybe_transform(
{
"evaluation_id": evaluation_id,
"matcher": matcher,
"target": target,
"json_path": json_path,
"target_value": target_value,
"tool_name": tool_name,
"type": type,
},
evaluation_assertion_update_params.EvaluationAssertionUpdateParams,
),
Expand Down Expand Up @@ -245,8 +276,12 @@ async def create(
self,
*,
evaluation_id: str,
matcher: evaluation_assertion_create_params.Matcher,
target: str,
json_path: Optional[str],
target_value: str,
tool_name: Optional[str],
type: Literal[
"EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"
],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -258,6 +293,14 @@ async def create(
Creates a new evaluation assertion

Args:
json_path: A JSON path to use when matching the response. Only required when type is
`JSON_EXACT_MATCH` or `JSON_CONTAINS`.

tool_name: The name of the tool to match. Only required when type is `TOOL_CALLED` or
`TOOL_CALLED_WITH`.

type: The type of evaluation matcher to use.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -271,8 +314,10 @@ async def create(
body=await async_maybe_transform(
{
"evaluation_id": evaluation_id,
"matcher": matcher,
"target": target,
"json_path": json_path,
"target_value": target_value,
"tool_name": tool_name,
"type": type,
},
evaluation_assertion_create_params.EvaluationAssertionCreateParams,
),
Expand All @@ -287,8 +332,12 @@ async def update(
id: str,
*,
evaluation_id: str,
matcher: evaluation_assertion_update_params.Matcher,
target: str,
json_path: Optional[str],
target_value: str,
tool_name: Optional[str],
type: Literal[
"EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"
],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -300,6 +349,14 @@ async def update(
Update an existing evaluation assertion by providing its ID and new data.

Args:
json_path: A JSON path to use when matching the response. Only required when type is
`JSON_EXACT_MATCH` or `JSON_CONTAINS`.

tool_name: The name of the tool to match. Only required when type is `TOOL_CALLED` or
`TOOL_CALLED_WITH`.

type: The type of evaluation matcher to use.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -315,8 +372,10 @@ async def update(
body=await async_maybe_transform(
{
"evaluation_id": evaluation_id,
"matcher": matcher,
"target": target,
"json_path": json_path,
"target_value": target_value,
"tool_name": tool_name,
"type": type,
},
evaluation_assertion_update_params.EvaluationAssertionUpdateParams,
),
Expand Down
26 changes: 14 additions & 12 deletions src/prompt_foundry_python_sdk/types/evaluation_assertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@

from .._models import BaseModel

__all__ = ["EvaluationAssertion", "Matcher"]
__all__ = ["EvaluationAssertion"]


class Matcher(BaseModel):
class EvaluationAssertion(BaseModel):
id: str

evaluation_id: str = FieldInfo(alias="evaluationId")

json_path: Optional[str] = FieldInfo(alias="jsonPath", default=None)
"""A JSON path to use when matching the response.

Only required when type is `jsonPath`.
Only required when type is `JSON_EXACT_MATCH` or `JSON_CONTAINS`.
"""

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

tool_name: Optional[str] = FieldInfo(alias="toolName", default=None)
"""The name of the tool to match.

class EvaluationAssertion(BaseModel):
id: str

evaluation_id: str = FieldInfo(alias="evaluationId")

matcher: Matcher
Only required when type is `TOOL_CALLED` or `TOOL_CALLED_WITH`.
"""

target: str
type: Literal["EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"]
"""The type of evaluation matcher to use."""
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,27 @@

from .._utils import PropertyInfo

__all__ = ["EvaluationAssertionCreateParams", "Matcher"]
__all__ = ["EvaluationAssertionCreateParams"]


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

matcher: Required[Matcher]
json_path: Required[Annotated[Optional[str], PropertyInfo(alias="jsonPath")]]
"""A JSON path to use when matching the response.

target: Required[str]
Only required when type is `JSON_EXACT_MATCH` or `JSON_CONTAINS`.
"""

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

class Matcher(TypedDict, total=False):
json_path: Required[Annotated[Optional[str], PropertyInfo(alias="jsonPath")]]
"""A JSON path to use when matching the response.
tool_name: Required[Annotated[Optional[str], PropertyInfo(alias="toolName")]]
"""The name of the tool to match.

Only required when type is `jsonPath`.
Only required when type is `TOOL_CALLED` or `TOOL_CALLED_WITH`.
"""

type: Required[Literal["CONTAINS", "EQUALS", "JSON"]]
type: Required[
Literal["EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"]
]
"""The type of evaluation matcher to use."""
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,27 @@

from .._utils import PropertyInfo

__all__ = ["EvaluationAssertionUpdateParams", "Matcher"]
__all__ = ["EvaluationAssertionUpdateParams"]


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

matcher: Required[Matcher]
json_path: Required[Annotated[Optional[str], PropertyInfo(alias="jsonPath")]]
"""A JSON path to use when matching the response.

target: Required[str]
Only required when type is `JSON_EXACT_MATCH` or `JSON_CONTAINS`.
"""

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

class Matcher(TypedDict, total=False):
json_path: Required[Annotated[Optional[str], PropertyInfo(alias="jsonPath")]]
"""A JSON path to use when matching the response.
tool_name: Required[Annotated[Optional[str], PropertyInfo(alias="toolName")]]
"""The name of the tool to match.

Only required when type is `jsonPath`.
Only required when type is `TOOL_CALLED` or `TOOL_CALLED_WITH`.
"""

type: Required[Literal["CONTAINS", "EQUALS", "JSON"]]
type: Required[
Literal["EXACT_MATCH", "CONTAINS", "JSON_EXACT_MATCH", "JSON_CONTAINS", "TOOL_CALLED", "TOOL_CALLED_WITH"]
]
"""The type of evaluation matcher to use."""
Loading