Skip to content

feat(api): OpenAPI spec update via Stainless API #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2024
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-441451c27073e45d1bdc832c5b66c26d90bd185bd94bd461b91257fbf0987ef2.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prompt-foundry%2Fprompt-foundry-sdk-2203adbcfccbd119a54a1fe9a29de02b1993184022804cfa4bc32947c8c1eb06.yml
16 changes: 16 additions & 0 deletions src/prompt_foundry_python_sdk/resources/evaluation_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def create(
type: Literal[
"CONTAINS", "EXACT_MATCH", "JSON_CONTAINS", "JSON_EXACT_MATCH", "TOOL_CALLED", "TOOL_CALLED_WITH"
],
weight: float | NotGiven = NOT_GIVEN,
# 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 @@ -71,6 +72,8 @@ def create(

type: The type of evaluation matcher to use.

weight: How heavily to weigh the assertion within the evaluation.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -88,6 +91,7 @@ def create(
"target_value": target_value,
"tool_name": tool_name,
"type": type,
"weight": weight,
},
evaluation_assertion_create_params.EvaluationAssertionCreateParams,
),
Expand All @@ -108,6 +112,7 @@ def update(
type: Literal[
"CONTAINS", "EXACT_MATCH", "JSON_CONTAINS", "JSON_EXACT_MATCH", "TOOL_CALLED", "TOOL_CALLED_WITH"
],
weight: float | NotGiven = NOT_GIVEN,
# 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 @@ -127,6 +132,8 @@ def update(

type: The type of evaluation matcher to use.

weight: How heavily to weigh the assertion within the evaluation.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -146,6 +153,7 @@ def update(
"target_value": target_value,
"tool_name": tool_name,
"type": type,
"weight": weight,
},
evaluation_assertion_update_params.EvaluationAssertionUpdateParams,
),
Expand Down Expand Up @@ -280,6 +288,7 @@ async def create(
type: Literal[
"CONTAINS", "EXACT_MATCH", "JSON_CONTAINS", "JSON_EXACT_MATCH", "TOOL_CALLED", "TOOL_CALLED_WITH"
],
weight: float | NotGiven = NOT_GIVEN,
# 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 @@ -299,6 +308,8 @@ async def create(

type: The type of evaluation matcher to use.

weight: How heavily to weigh the assertion within the evaluation.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -316,6 +327,7 @@ async def create(
"target_value": target_value,
"tool_name": tool_name,
"type": type,
"weight": weight,
},
evaluation_assertion_create_params.EvaluationAssertionCreateParams,
),
Expand All @@ -336,6 +348,7 @@ async def update(
type: Literal[
"CONTAINS", "EXACT_MATCH", "JSON_CONTAINS", "JSON_EXACT_MATCH", "TOOL_CALLED", "TOOL_CALLED_WITH"
],
weight: float | NotGiven = NOT_GIVEN,
# 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 @@ -355,6 +368,8 @@ async def update(

type: The type of evaluation matcher to use.

weight: How heavily to weigh the assertion within the evaluation.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -374,6 +389,7 @@ async def update(
"target_value": target_value,
"tool_name": tool_name,
"type": type,
"weight": weight,
},
evaluation_assertion_update_params.EvaluationAssertionUpdateParams,
),
Expand Down
32 changes: 32 additions & 0 deletions src/prompt_foundry_python_sdk/resources/evaluations.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def create(
appended_messages: Iterable[evaluation_create_params.AppendedMessage],
prompt_id: str,
variables: Dict[str, Optional[str]],
threshold: float | NotGiven = NOT_GIVEN,
weight: float | NotGiven = NOT_GIVEN,
# 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 +60,10 @@ def create(

variables: The template variables added to the prompt when executing the prompt.

threshold: What percentage of assertions must pass for the evaluation to pass.

weight: How heavily to weigh the evaluation within the prompt.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -73,6 +79,8 @@ def create(
"appended_messages": appended_messages,
"prompt_id": prompt_id,
"variables": variables,
"threshold": threshold,
"weight": weight,
},
evaluation_create_params.EvaluationCreateParams,
),
Expand All @@ -89,6 +97,8 @@ def update(
appended_messages: Iterable[evaluation_update_params.AppendedMessage],
prompt_id: str,
variables: Dict[str, Optional[str]],
threshold: float | NotGiven = NOT_GIVEN,
weight: float | NotGiven = NOT_GIVEN,
# 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 @@ -104,6 +114,10 @@ def update(

variables: The template variables added to the prompt when executing the prompt.

threshold: What percentage of assertions must pass for the evaluation to pass.

weight: How heavily to weigh the evaluation within the prompt.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -121,6 +135,8 @@ def update(
"appended_messages": appended_messages,
"prompt_id": prompt_id,
"variables": variables,
"threshold": threshold,
"weight": weight,
},
evaluation_update_params.EvaluationUpdateParams,
),
Expand Down Expand Up @@ -231,6 +247,8 @@ async def create(
appended_messages: Iterable[evaluation_create_params.AppendedMessage],
prompt_id: str,
variables: Dict[str, Optional[str]],
threshold: float | NotGiven = NOT_GIVEN,
weight: float | NotGiven = NOT_GIVEN,
# 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 @@ -246,6 +264,10 @@ async def create(

variables: The template variables added to the prompt when executing the prompt.

threshold: What percentage of assertions must pass for the evaluation to pass.

weight: How heavily to weigh the evaluation within the prompt.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -261,6 +283,8 @@ async def create(
"appended_messages": appended_messages,
"prompt_id": prompt_id,
"variables": variables,
"threshold": threshold,
"weight": weight,
},
evaluation_create_params.EvaluationCreateParams,
),
Expand All @@ -277,6 +301,8 @@ async def update(
appended_messages: Iterable[evaluation_update_params.AppendedMessage],
prompt_id: str,
variables: Dict[str, Optional[str]],
threshold: float | NotGiven = NOT_GIVEN,
weight: float | NotGiven = NOT_GIVEN,
# 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 @@ -292,6 +318,10 @@ async def update(

variables: The template variables added to the prompt when executing the prompt.

threshold: What percentage of assertions must pass for the evaluation to pass.

weight: How heavily to weigh the evaluation within the prompt.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -309,6 +339,8 @@ async def update(
"appended_messages": appended_messages,
"prompt_id": prompt_id,
"variables": variables,
"threshold": threshold,
"weight": weight,
},
evaluation_update_params.EvaluationUpdateParams,
),
Expand Down
6 changes: 6 additions & 0 deletions src/prompt_foundry_python_sdk/types/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,9 @@ class Evaluation(BaseModel):

variables: Dict[str, Optional[str]]
"""The template variables added to the prompt when executing the prompt."""

threshold: Optional[float] = None
"""What percentage of assertions must pass for the evaluation to pass."""

weight: Optional[float] = None
"""How heavily to weigh the evaluation within the prompt."""
3 changes: 3 additions & 0 deletions src/prompt_foundry_python_sdk/types/evaluation_assertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ class EvaluationAssertion(BaseModel):

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

weight: Optional[float] = None
"""How heavily to weigh the assertion within the evaluation."""
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ class EvaluationAssertionCreateParams(TypedDict, total=False):
Literal["CONTAINS", "EXACT_MATCH", "JSON_CONTAINS", "JSON_EXACT_MATCH", "TOOL_CALLED", "TOOL_CALLED_WITH"]
]
"""The type of evaluation matcher to use."""

weight: float
"""How heavily to weigh the assertion within the evaluation."""
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ class EvaluationAssertionUpdateParams(TypedDict, total=False):
Literal["CONTAINS", "EXACT_MATCH", "JSON_CONTAINS", "JSON_EXACT_MATCH", "TOOL_CALLED", "TOOL_CALLED_WITH"]
]
"""The type of evaluation matcher to use."""

weight: float
"""How heavily to weigh the assertion within the evaluation."""
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class EvaluationCreateParams(TypedDict, total=False):
variables: Required[Dict[str, Optional[str]]]
"""The template variables added to the prompt when executing the prompt."""

threshold: float
"""What percentage of assertions must pass for the evaluation to pass."""

weight: float
"""How heavily to weigh the evaluation within the prompt."""


class AppendedMessageContentTextContentBlockSchema(TypedDict, total=False):
text: Required[str]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class EvaluationUpdateParams(TypedDict, total=False):
variables: Required[Dict[str, Optional[str]]]
"""The template variables added to the prompt when executing the prompt."""

threshold: float
"""What percentage of assertions must pass for the evaluation to pass."""

weight: float
"""How heavily to weigh the evaluation within the prompt."""


class AppendedMessageContentTextContentBlockSchema(TypedDict, total=False):
text: Required[str]
Expand Down
50 changes: 50 additions & 0 deletions tests/api_resources/test_evaluation_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ def test_method_create(self, client: PromptFoundry) -> None:
)
assert_matches_type(EvaluationAssertion, evaluation_assertion, path=["response"])

@parametrize
def test_method_create_with_all_params(self, client: PromptFoundry) -> None:
evaluation_assertion = client.evaluation_assertions.create(
evaluation_id="evaluationId",
json_path="jsonPath",
target_value="targetValue",
tool_name="toolName",
type="CONTAINS",
weight=0,
)
assert_matches_type(EvaluationAssertion, evaluation_assertion, path=["response"])

@parametrize
def test_raw_response_create(self, client: PromptFoundry) -> None:
response = client.evaluation_assertions.with_raw_response.create(
Expand Down Expand Up @@ -76,6 +88,19 @@ def test_method_update(self, client: PromptFoundry) -> None:
)
assert_matches_type(EvaluationAssertion, evaluation_assertion, path=["response"])

@parametrize
def test_method_update_with_all_params(self, client: PromptFoundry) -> None:
evaluation_assertion = client.evaluation_assertions.update(
id="1212121",
evaluation_id="evaluationId",
json_path="jsonPath",
target_value="targetValue",
tool_name="toolName",
type="CONTAINS",
weight=0,
)
assert_matches_type(EvaluationAssertion, evaluation_assertion, path=["response"])

@parametrize
def test_raw_response_update(self, client: PromptFoundry) -> None:
response = client.evaluation_assertions.with_raw_response.update(
Expand Down Expand Up @@ -245,6 +270,18 @@ async def test_method_create(self, async_client: AsyncPromptFoundry) -> None:
)
assert_matches_type(EvaluationAssertion, evaluation_assertion, path=["response"])

@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncPromptFoundry) -> None:
evaluation_assertion = await async_client.evaluation_assertions.create(
evaluation_id="evaluationId",
json_path="jsonPath",
target_value="targetValue",
tool_name="toolName",
type="CONTAINS",
weight=0,
)
assert_matches_type(EvaluationAssertion, evaluation_assertion, path=["response"])

@parametrize
async def test_raw_response_create(self, async_client: AsyncPromptFoundry) -> None:
response = await async_client.evaluation_assertions.with_raw_response.create(
Expand Down Expand Up @@ -289,6 +326,19 @@ async def test_method_update(self, async_client: AsyncPromptFoundry) -> None:
)
assert_matches_type(EvaluationAssertion, evaluation_assertion, path=["response"])

@parametrize
async def test_method_update_with_all_params(self, async_client: AsyncPromptFoundry) -> None:
evaluation_assertion = await async_client.evaluation_assertions.update(
id="1212121",
evaluation_id="evaluationId",
json_path="jsonPath",
target_value="targetValue",
tool_name="toolName",
type="CONTAINS",
weight=0,
)
assert_matches_type(EvaluationAssertion, evaluation_assertion, path=["response"])

@parametrize
async def test_raw_response_update(self, async_client: AsyncPromptFoundry) -> None:
response = await async_client.evaluation_assertions.with_raw_response.update(
Expand Down
Loading