|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from typing import List |
| 6 | + |
| 7 | +import httpx |
| 8 | + |
| 9 | +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 10 | +from ...._utils import ( |
| 11 | + maybe_transform, |
| 12 | + async_maybe_transform, |
| 13 | +) |
| 14 | +from ...._compat import cached_property |
| 15 | +from ...._resource import SyncAPIResource, AsyncAPIResource |
| 16 | +from ...._response import ( |
| 17 | + to_raw_response_wrapper, |
| 18 | + to_streamed_response_wrapper, |
| 19 | + async_to_raw_response_wrapper, |
| 20 | + async_to_streamed_response_wrapper, |
| 21 | +) |
| 22 | +from ...._base_client import make_request_options |
| 23 | +from ....types.agents.query import retrieval_info_params |
| 24 | +from ....types.agents.query.retrieval_info_response import RetrievalInfoResponse |
| 25 | + |
| 26 | +__all__ = ["RetrievalResource", "AsyncRetrievalResource"] |
| 27 | + |
| 28 | + |
| 29 | +class RetrievalResource(SyncAPIResource): |
| 30 | + @cached_property |
| 31 | + def with_raw_response(self) -> RetrievalResourceWithRawResponse: |
| 32 | + """ |
| 33 | + This property can be used as a prefix for any HTTP method call to return the |
| 34 | + the raw response object instead of the parsed content. |
| 35 | +
|
| 36 | + For more information, see https://www.github.com/stainless-sdks/sunrise-python#accessing-raw-response-data-eg-headers |
| 37 | + """ |
| 38 | + return RetrievalResourceWithRawResponse(self) |
| 39 | + |
| 40 | + @cached_property |
| 41 | + def with_streaming_response(self) -> RetrievalResourceWithStreamingResponse: |
| 42 | + """ |
| 43 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 44 | +
|
| 45 | + For more information, see https://www.github.com/stainless-sdks/sunrise-python#with_streaming_response |
| 46 | + """ |
| 47 | + return RetrievalResourceWithStreamingResponse(self) |
| 48 | + |
| 49 | + def info( |
| 50 | + self, |
| 51 | + message_id: str, |
| 52 | + *, |
| 53 | + agent_id: str, |
| 54 | + content_ids: List[str], |
| 55 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 56 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 57 | + extra_headers: Headers | None = None, |
| 58 | + extra_query: Query | None = None, |
| 59 | + extra_body: Body | None = None, |
| 60 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 61 | + ) -> RetrievalInfoResponse: |
| 62 | + """ |
| 63 | + Return content metadata of the contents used to generate response for a given |
| 64 | + message. |
| 65 | +
|
| 66 | + Args: |
| 67 | + agent_id: Agent ID of the agent which sent the provided message. |
| 68 | +
|
| 69 | + message_id: Message ID for which the content metadata needs to be retrieved. |
| 70 | +
|
| 71 | + content_ids: List of content ids for which to get the metadata. |
| 72 | +
|
| 73 | + extra_headers: Send extra headers |
| 74 | +
|
| 75 | + extra_query: Add additional query parameters to the request |
| 76 | +
|
| 77 | + extra_body: Add additional JSON properties to the request |
| 78 | +
|
| 79 | + timeout: Override the client-level default timeout for this request, in seconds |
| 80 | + """ |
| 81 | + if not agent_id: |
| 82 | + raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") |
| 83 | + if not message_id: |
| 84 | + raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}") |
| 85 | + return self._get( |
| 86 | + f"/agents/{agent_id}/query/{message_id}/retrieval/info", |
| 87 | + options=make_request_options( |
| 88 | + extra_headers=extra_headers, |
| 89 | + extra_query=extra_query, |
| 90 | + extra_body=extra_body, |
| 91 | + timeout=timeout, |
| 92 | + query=maybe_transform({"content_ids": content_ids}, retrieval_info_params.RetrievalInfoParams), |
| 93 | + ), |
| 94 | + cast_to=RetrievalInfoResponse, |
| 95 | + ) |
| 96 | + |
| 97 | + |
| 98 | +class AsyncRetrievalResource(AsyncAPIResource): |
| 99 | + @cached_property |
| 100 | + def with_raw_response(self) -> AsyncRetrievalResourceWithRawResponse: |
| 101 | + """ |
| 102 | + This property can be used as a prefix for any HTTP method call to return the |
| 103 | + the raw response object instead of the parsed content. |
| 104 | +
|
| 105 | + For more information, see https://www.github.com/stainless-sdks/sunrise-python#accessing-raw-response-data-eg-headers |
| 106 | + """ |
| 107 | + return AsyncRetrievalResourceWithRawResponse(self) |
| 108 | + |
| 109 | + @cached_property |
| 110 | + def with_streaming_response(self) -> AsyncRetrievalResourceWithStreamingResponse: |
| 111 | + """ |
| 112 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 113 | +
|
| 114 | + For more information, see https://www.github.com/stainless-sdks/sunrise-python#with_streaming_response |
| 115 | + """ |
| 116 | + return AsyncRetrievalResourceWithStreamingResponse(self) |
| 117 | + |
| 118 | + async def info( |
| 119 | + self, |
| 120 | + message_id: str, |
| 121 | + *, |
| 122 | + agent_id: str, |
| 123 | + content_ids: List[str], |
| 124 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 125 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 126 | + extra_headers: Headers | None = None, |
| 127 | + extra_query: Query | None = None, |
| 128 | + extra_body: Body | None = None, |
| 129 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 130 | + ) -> RetrievalInfoResponse: |
| 131 | + """ |
| 132 | + Return content metadata of the contents used to generate response for a given |
| 133 | + message. |
| 134 | +
|
| 135 | + Args: |
| 136 | + agent_id: Agent ID of the agent which sent the provided message. |
| 137 | +
|
| 138 | + message_id: Message ID for which the content metadata needs to be retrieved. |
| 139 | +
|
| 140 | + content_ids: List of content ids for which to get the metadata. |
| 141 | +
|
| 142 | + extra_headers: Send extra headers |
| 143 | +
|
| 144 | + extra_query: Add additional query parameters to the request |
| 145 | +
|
| 146 | + extra_body: Add additional JSON properties to the request |
| 147 | +
|
| 148 | + timeout: Override the client-level default timeout for this request, in seconds |
| 149 | + """ |
| 150 | + if not agent_id: |
| 151 | + raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}") |
| 152 | + if not message_id: |
| 153 | + raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}") |
| 154 | + return await self._get( |
| 155 | + f"/agents/{agent_id}/query/{message_id}/retrieval/info", |
| 156 | + options=make_request_options( |
| 157 | + extra_headers=extra_headers, |
| 158 | + extra_query=extra_query, |
| 159 | + extra_body=extra_body, |
| 160 | + timeout=timeout, |
| 161 | + query=await async_maybe_transform( |
| 162 | + {"content_ids": content_ids}, retrieval_info_params.RetrievalInfoParams |
| 163 | + ), |
| 164 | + ), |
| 165 | + cast_to=RetrievalInfoResponse, |
| 166 | + ) |
| 167 | + |
| 168 | + |
| 169 | +class RetrievalResourceWithRawResponse: |
| 170 | + def __init__(self, retrieval: RetrievalResource) -> None: |
| 171 | + self._retrieval = retrieval |
| 172 | + |
| 173 | + self.info = to_raw_response_wrapper( |
| 174 | + retrieval.info, |
| 175 | + ) |
| 176 | + |
| 177 | + |
| 178 | +class AsyncRetrievalResourceWithRawResponse: |
| 179 | + def __init__(self, retrieval: AsyncRetrievalResource) -> None: |
| 180 | + self._retrieval = retrieval |
| 181 | + |
| 182 | + self.info = async_to_raw_response_wrapper( |
| 183 | + retrieval.info, |
| 184 | + ) |
| 185 | + |
| 186 | + |
| 187 | +class RetrievalResourceWithStreamingResponse: |
| 188 | + def __init__(self, retrieval: RetrievalResource) -> None: |
| 189 | + self._retrieval = retrieval |
| 190 | + |
| 191 | + self.info = to_streamed_response_wrapper( |
| 192 | + retrieval.info, |
| 193 | + ) |
| 194 | + |
| 195 | + |
| 196 | +class AsyncRetrievalResourceWithStreamingResponse: |
| 197 | + def __init__(self, retrieval: AsyncRetrievalResource) -> None: |
| 198 | + self._retrieval = retrieval |
| 199 | + |
| 200 | + self.info = async_to_streamed_response_wrapper( |
| 201 | + retrieval.info, |
| 202 | + ) |
0 commit comments