From c6f1ca5d4101b6c1b62326a1bf4d7bd090461595 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 21 Mar 2025 16:35:17 +0000 Subject: [PATCH 1/2] feat(api): api update (#575) --- .stats.yml | 2 +- .../types/scoring_function.py | 106 +++++++++++++++++- .../types/scoring_function_param.py | 48 ++++---- tests/api_resources/test_scenarios.py | 36 +++--- 4 files changed, 147 insertions(+), 45 deletions(-) diff --git a/.stats.yml b/.stats.yml index 4dd4711f3..0805f23e6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 78 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-1c6045460c43f65b30ffcef9f707e8d71dca568bf8d208347a6046a6f03ff239.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-4ac5f2286270f1f2c2b41e7f57fcc0527f602ce8d9383c790ed40ce21236e0cf.yml diff --git a/src/runloop_api_client/types/scoring_function.py b/src/runloop_api_client/types/scoring_function.py index e3eddf554..d3035fe0f 100644 --- a/src/runloop_api_client/types/scoring_function.py +++ b/src/runloop_api_client/types/scoring_function.py @@ -1,16 +1,118 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from typing import List, Union, Optional +from typing_extensions import Literal, Annotated, TypeAlias +from .._utils import PropertyInfo from .._models import BaseModel -__all__ = ["ScoringFunction"] +__all__ = [ + "ScoringFunction", + "Scorer", + "ScorerAstGrepScoringFunction", + "ScorerBashScriptScoringFunction", + "ScorerCommandScoringFunction", + "ScorerCustomScoringFunction", + "ScorerPythonScriptScoringFunction", + "ScorerTestBasedScoringFunction", + "ScorerTestBasedScoringFunctionTestFile", +] + + +class ScorerAstGrepScoringFunction(BaseModel): + pattern: str + """AST pattern to match.""" + + search_directory: str + """The path to search.""" + + type: Literal["ast_grep_scorer"] + + lang: Optional[str] = None + """The language of the pattern.""" + + +class ScorerBashScriptScoringFunction(BaseModel): + type: Literal["bash_script_scorer"] + + bash_script: Optional[str] = None + """ + A single bash script that sets up the environment, scores, and prints the final + score to standard out. Score should be a float between 0.0 and 1.0, and look + like "score=[0.0..1.0]. + """ + + +class ScorerCommandScoringFunction(BaseModel): + type: Literal["command_scorer"] + + command: Optional[str] = None + """The command to execute.""" + + +class ScorerCustomScoringFunction(BaseModel): + type: Literal["custom_scorer"] + + scorer_params: Optional[object] = None + """Additional JSON structured context to pass to the scoring function.""" + + +class ScorerPythonScriptScoringFunction(BaseModel): + python_script: str + """Python script to be run. + + The script should output the score to standard out as a float between 0.0 and + 1.0. + """ + + type: Literal["python_script_scorer"] + + requirements_contents: Optional[str] = None + """Package dependencies to be installed. + + The requirements should be a valid requirements.txt file. + """ + + +class ScorerTestBasedScoringFunctionTestFile(BaseModel): + file_contents: Optional[str] = None + """Content of the test file""" + + file_path: Optional[str] = None + """ + Path to write content of the test file, relative to your environment's working + directory + """ + + +class ScorerTestBasedScoringFunction(BaseModel): + type: Literal["test_based_scorer"] + + test_command: Optional[str] = None + """The command to execute for running the tests""" + + test_files: Optional[List[ScorerTestBasedScoringFunctionTestFile]] = None + """List of test files to create""" + + +Scorer: TypeAlias = Annotated[ + Union[ + ScorerAstGrepScoringFunction, + ScorerBashScriptScoringFunction, + ScorerCommandScoringFunction, + ScorerCustomScoringFunction, + ScorerPythonScriptScoringFunction, + ScorerTestBasedScoringFunction, + ], + PropertyInfo(discriminator="type"), +] class ScoringFunction(BaseModel): name: str """Name of scoring function. Names must only contain [a-zA-Z0-9_-].""" - scoring_function: ScoringFunction + scorer: Scorer """The scoring function to use for evaluating this scenario. The type field determines which built-in function to use. diff --git a/src/runloop_api_client/types/scoring_function_param.py b/src/runloop_api_client/types/scoring_function_param.py index 264bf612c..7488a9707 100644 --- a/src/runloop_api_client/types/scoring_function_param.py +++ b/src/runloop_api_client/types/scoring_function_param.py @@ -7,18 +7,18 @@ __all__ = [ "ScoringFunctionParam", - "ScoringFunction", - "ScoringFunctionAstGrepScoringFunction", - "ScoringFunctionBashScriptScoringFunction", - "ScoringFunctionCommandScoringFunction", - "ScoringFunctionCustomScoringFunction", - "ScoringFunctionPythonScriptScoringFunction", - "ScoringFunctionTestBasedScoringFunction", - "ScoringFunctionTestBasedScoringFunctionTestFile", + "Scorer", + "ScorerAstGrepScoringFunction", + "ScorerBashScriptScoringFunction", + "ScorerCommandScoringFunction", + "ScorerCustomScoringFunction", + "ScorerPythonScriptScoringFunction", + "ScorerTestBasedScoringFunction", + "ScorerTestBasedScoringFunctionTestFile", ] -class ScoringFunctionAstGrepScoringFunction(TypedDict, total=False): +class ScorerAstGrepScoringFunction(TypedDict, total=False): pattern: Required[str] """AST pattern to match.""" @@ -31,7 +31,7 @@ class ScoringFunctionAstGrepScoringFunction(TypedDict, total=False): """The language of the pattern.""" -class ScoringFunctionBashScriptScoringFunction(TypedDict, total=False): +class ScorerBashScriptScoringFunction(TypedDict, total=False): type: Required[Literal["bash_script_scorer"]] bash_script: str @@ -42,21 +42,21 @@ class ScoringFunctionBashScriptScoringFunction(TypedDict, total=False): """ -class ScoringFunctionCommandScoringFunction(TypedDict, total=False): +class ScorerCommandScoringFunction(TypedDict, total=False): type: Required[Literal["command_scorer"]] command: str """The command to execute.""" -class ScoringFunctionCustomScoringFunction(TypedDict, total=False): +class ScorerCustomScoringFunction(TypedDict, total=False): type: Required[Literal["custom_scorer"]] scorer_params: Optional[object] """Additional JSON structured context to pass to the scoring function.""" -class ScoringFunctionPythonScriptScoringFunction(TypedDict, total=False): +class ScorerPythonScriptScoringFunction(TypedDict, total=False): python_script: Required[str] """Python script to be run. @@ -73,7 +73,7 @@ class ScoringFunctionPythonScriptScoringFunction(TypedDict, total=False): """ -class ScoringFunctionTestBasedScoringFunctionTestFile(TypedDict, total=False): +class ScorerTestBasedScoringFunctionTestFile(TypedDict, total=False): file_contents: str """Content of the test file""" @@ -84,23 +84,23 @@ class ScoringFunctionTestBasedScoringFunctionTestFile(TypedDict, total=False): """ -class ScoringFunctionTestBasedScoringFunction(TypedDict, total=False): +class ScorerTestBasedScoringFunction(TypedDict, total=False): type: Required[Literal["test_based_scorer"]] test_command: str """The command to execute for running the tests""" - test_files: Iterable[ScoringFunctionTestBasedScoringFunctionTestFile] + test_files: Iterable[ScorerTestBasedScoringFunctionTestFile] """List of test files to create""" -ScoringFunction: TypeAlias = Union[ - ScoringFunctionAstGrepScoringFunction, - ScoringFunctionBashScriptScoringFunction, - ScoringFunctionCommandScoringFunction, - ScoringFunctionCustomScoringFunction, - ScoringFunctionPythonScriptScoringFunction, - ScoringFunctionTestBasedScoringFunction, +Scorer: TypeAlias = Union[ + ScorerAstGrepScoringFunction, + ScorerBashScriptScoringFunction, + ScorerCommandScoringFunction, + ScorerCustomScoringFunction, + ScorerPythonScriptScoringFunction, + ScorerTestBasedScoringFunction, ] @@ -108,7 +108,7 @@ class ScoringFunctionParam(TypedDict, total=False): name: Required[str] """Name of scoring function. Names must only contain [a-zA-Z0-9_-].""" - scoring_function: Required[ScoringFunction] + scorer: Required[Scorer] """The scoring function to use for evaluating this scenario. The type field determines which built-in function to use. diff --git a/tests/api_resources/test_scenarios.py b/tests/api_resources/test_scenarios.py index 8977f886b..a19110235 100644 --- a/tests/api_resources/test_scenarios.py +++ b/tests/api_resources/test_scenarios.py @@ -30,7 +30,7 @@ def test_method_create(self, client: Runloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -54,7 +54,7 @@ def test_method_create_with_all_params(self, client: Runloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -96,7 +96,7 @@ def test_raw_response_create(self, client: Runloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -121,7 +121,7 @@ def test_streaming_response_create(self, client: Runloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -187,7 +187,7 @@ def test_method_update(self, client: Runloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -212,7 +212,7 @@ def test_method_update_with_all_params(self, client: Runloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -255,7 +255,7 @@ def test_raw_response_update(self, client: Runloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -281,7 +281,7 @@ def test_streaming_response_update(self, client: Runloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -310,7 +310,7 @@ def test_path_params_update(self, client: Runloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -443,7 +443,7 @@ async def test_method_create(self, async_client: AsyncRunloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -467,7 +467,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncRunloop) - "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -509,7 +509,7 @@ async def test_raw_response_create(self, async_client: AsyncRunloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -534,7 +534,7 @@ async def test_streaming_response_create(self, async_client: AsyncRunloop) -> No "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -600,7 +600,7 @@ async def test_method_update(self, async_client: AsyncRunloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -625,7 +625,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncRunloop) - "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -668,7 +668,7 @@ async def test_raw_response_update(self, async_client: AsyncRunloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -694,7 +694,7 @@ async def test_streaming_response_update(self, async_client: AsyncRunloop) -> No "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", @@ -723,7 +723,7 @@ async def test_path_params_update(self, async_client: AsyncRunloop) -> None: "scoring_function_parameters": [ { "name": "name", - "scoring_function": { + "scorer": { "pattern": "pattern", "search_directory": "search_directory", "type": "ast_grep_scorer", From ff8b8fd154aa3f8ca79bc15938badd9f5e2d0f6c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 21 Mar 2025 16:35:39 +0000 Subject: [PATCH 2/2] release: 0.28.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ pyproject.toml | 2 +- src/runloop_api_client/_version.py | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 59acac471..8935e9328 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.27.0" + ".": "0.28.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index f6ac326d3..3c78a8ec5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.28.0 (2025-03-21) + +Full Changelog: [v0.27.0...v0.28.0](https://github.com/runloopai/api-client-python/compare/v0.27.0...v0.28.0) + +### Features + +* **api:** api update ([#575](https://github.com/runloopai/api-client-python/issues/575)) ([c6f1ca5](https://github.com/runloopai/api-client-python/commit/c6f1ca5d4101b6c1b62326a1bf4d7bd090461595)) + ## 0.27.0 (2025-03-21) Full Changelog: [v0.26.0...v0.27.0](https://github.com/runloopai/api-client-python/compare/v0.26.0...v0.27.0) diff --git a/pyproject.toml b/pyproject.toml index 103cd4f9c..597cbb494 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "runloop_api_client" -version = "0.27.0" +version = "0.28.0" description = "The official Python library for the runloop API" dynamic = ["readme"] license = "MIT" diff --git a/src/runloop_api_client/_version.py b/src/runloop_api_client/_version.py index 798803838..c111395ef 100644 --- a/src/runloop_api_client/_version.py +++ b/src/runloop_api_client/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "runloop_api_client" -__version__ = "0.27.0" # x-release-please-version +__version__ = "0.28.0" # x-release-please-version