Source code for aymara_ai.resources.reports

# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import List, Optional

import httpx

from ..types import report_get_params, report_list_params, report_create_params, report_delete_params
from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
from .._utils import maybe_transform, async_maybe_transform
from .._compat import cached_property
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import (
    to_raw_response_wrapper,
    to_streamed_response_wrapper,
    async_to_raw_response_wrapper,
    async_to_streamed_response_wrapper,
)
from ..pagination import SyncOffsetPage, AsyncOffsetPage
from .._base_client import AsyncPaginator, make_request_options
from ..types.eval_suite_report import EvalSuiteReport

__all__ = ["ReportsResource", "AsyncReportsResource"]


[docs] class ReportsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> ReportsResourceWithRawResponse: """ This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/aymara-ai/aymara-sdk-python#accessing-raw-response-data-eg-headers """ return ReportsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> ReportsResourceWithStreamingResponse: """ An alternative to `.with_raw_response` that doesn't eagerly read the response body. For more information, see https://www.github.com/aymara-ai/aymara-sdk-python#with_streaming_response """ return ReportsResourceWithStreamingResponse(self)
[docs] def create( self, *, eval_run_uuids: List[str], is_sandbox: Optional[bool] | NotGiven = NOT_GIVEN, workspace_uuid: str | 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, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> EvalSuiteReport: """ Create a summary for a suite of eval runs. Args: eval_run_uuids: List of eval run UUIDs to include in the suite summary. extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ return self._post( "/v2/eval-reports", body=maybe_transform({"eval_run_uuids": eval_run_uuids}, report_create_params.ReportCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, query=maybe_transform( { "is_sandbox": is_sandbox, "workspace_uuid": workspace_uuid, }, report_create_params.ReportCreateParams, ), ), cast_to=EvalSuiteReport, )
[docs] def list( self, *, limit: int | NotGiven = NOT_GIVEN, offset: int | NotGiven = NOT_GIVEN, workspace_uuid: str | 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, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> SyncOffsetPage[EvalSuiteReport]: """ List all eval run suite summaries, with optional filtering. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( "/v2/eval-reports", page=SyncOffsetPage[EvalSuiteReport], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, query=maybe_transform( { "limit": limit, "offset": offset, "workspace_uuid": workspace_uuid, }, report_list_params.ReportListParams, ), ), model=EvalSuiteReport, )
[docs] def delete( self, report_uuid: str, *, workspace_uuid: str | 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, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> None: """ Delete an eval run suite report. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ if not report_uuid: raise ValueError(f"Expected a non-empty value for `report_uuid` but received {report_uuid!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( f"/v2/eval-reports/{report_uuid}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, query=maybe_transform({"workspace_uuid": workspace_uuid}, report_delete_params.ReportDeleteParams), ), cast_to=NoneType, )
[docs] def get( self, report_uuid: str, *, workspace_uuid: str | 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, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> EvalSuiteReport: """ Get a specific eval run suite report by UUID. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ if not report_uuid: raise ValueError(f"Expected a non-empty value for `report_uuid` but received {report_uuid!r}") return self._get( f"/v2/eval-reports/{report_uuid}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, query=maybe_transform({"workspace_uuid": workspace_uuid}, report_get_params.ReportGetParams), ), cast_to=EvalSuiteReport, )
[docs] class AsyncReportsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncReportsResourceWithRawResponse: """ This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/aymara-ai/aymara-sdk-python#accessing-raw-response-data-eg-headers """ return AsyncReportsResourceWithRawResponse(self) @cached_property def with_streaming_response(self) -> AsyncReportsResourceWithStreamingResponse: """ An alternative to `.with_raw_response` that doesn't eagerly read the response body. For more information, see https://www.github.com/aymara-ai/aymara-sdk-python#with_streaming_response """ return AsyncReportsResourceWithStreamingResponse(self)
[docs] async def create( self, *, eval_run_uuids: List[str], is_sandbox: Optional[bool] | NotGiven = NOT_GIVEN, workspace_uuid: str | 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, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> EvalSuiteReport: """ Create a summary for a suite of eval runs. Args: eval_run_uuids: List of eval run UUIDs to include in the suite summary. extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( "/v2/eval-reports", body=await async_maybe_transform( {"eval_run_uuids": eval_run_uuids}, report_create_params.ReportCreateParams ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, query=await async_maybe_transform( { "is_sandbox": is_sandbox, "workspace_uuid": workspace_uuid, }, report_create_params.ReportCreateParams, ), ), cast_to=EvalSuiteReport, )
[docs] def list( self, *, limit: int | NotGiven = NOT_GIVEN, offset: int | NotGiven = NOT_GIVEN, workspace_uuid: str | 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, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> AsyncPaginator[EvalSuiteReport, AsyncOffsetPage[EvalSuiteReport]]: """ List all eval run suite summaries, with optional filtering. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( "/v2/eval-reports", page=AsyncOffsetPage[EvalSuiteReport], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, query=maybe_transform( { "limit": limit, "offset": offset, "workspace_uuid": workspace_uuid, }, report_list_params.ReportListParams, ), ), model=EvalSuiteReport, )
[docs] async def delete( self, report_uuid: str, *, workspace_uuid: str | 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, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> None: """ Delete an eval run suite report. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ if not report_uuid: raise ValueError(f"Expected a non-empty value for `report_uuid` but received {report_uuid!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( f"/v2/eval-reports/{report_uuid}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, query=await async_maybe_transform( {"workspace_uuid": workspace_uuid}, report_delete_params.ReportDeleteParams ), ), cast_to=NoneType, )
[docs] async def get( self, report_uuid: str, *, workspace_uuid: str | 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, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> EvalSuiteReport: """ Get a specific eval run suite report by UUID. Args: extra_headers: Send extra headers extra_query: Add additional query parameters to the request extra_body: Add additional JSON properties to the request timeout: Override the client-level default timeout for this request, in seconds """ if not report_uuid: raise ValueError(f"Expected a non-empty value for `report_uuid` but received {report_uuid!r}") return await self._get( f"/v2/eval-reports/{report_uuid}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, query=await async_maybe_transform( {"workspace_uuid": workspace_uuid}, report_get_params.ReportGetParams ), ), cast_to=EvalSuiteReport, )
class ReportsResourceWithRawResponse: def __init__(self, reports: ReportsResource) -> None: self._reports = reports self.create = to_raw_response_wrapper( reports.create, ) self.list = to_raw_response_wrapper( reports.list, ) self.delete = to_raw_response_wrapper( reports.delete, ) self.get = to_raw_response_wrapper( reports.get, ) class AsyncReportsResourceWithRawResponse: def __init__(self, reports: AsyncReportsResource) -> None: self._reports = reports self.create = async_to_raw_response_wrapper( reports.create, ) self.list = async_to_raw_response_wrapper( reports.list, ) self.delete = async_to_raw_response_wrapper( reports.delete, ) self.get = async_to_raw_response_wrapper( reports.get, ) class ReportsResourceWithStreamingResponse: def __init__(self, reports: ReportsResource) -> None: self._reports = reports self.create = to_streamed_response_wrapper( reports.create, ) self.list = to_streamed_response_wrapper( reports.list, ) self.delete = to_streamed_response_wrapper( reports.delete, ) self.get = to_streamed_response_wrapper( reports.get, ) class AsyncReportsResourceWithStreamingResponse: def __init__(self, reports: AsyncReportsResource) -> None: self._reports = reports self.create = async_to_streamed_response_wrapper( reports.create, ) self.list = async_to_streamed_response_wrapper( reports.list, ) self.delete = async_to_streamed_response_wrapper( reports.delete, ) self.get = async_to_streamed_response_wrapper( reports.get, )