|
| 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 Optional |
| 6 | + |
| 7 | +import httpx |
| 8 | + |
| 9 | +from ..types import project_update_params |
| 10 | +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 11 | +from .._utils import ( |
| 12 | + maybe_transform, |
| 13 | + async_maybe_transform, |
| 14 | +) |
| 15 | +from .._compat import cached_property |
| 16 | +from .._resource import SyncAPIResource, AsyncAPIResource |
| 17 | +from .._response import ( |
| 18 | + to_raw_response_wrapper, |
| 19 | + to_streamed_response_wrapper, |
| 20 | + async_to_raw_response_wrapper, |
| 21 | + async_to_streamed_response_wrapper, |
| 22 | +) |
| 23 | +from .._base_client import make_request_options |
| 24 | +from ..types.sys.project import Project |
| 25 | +from ..types.project_list_model_groups_response import ProjectListModelGroupsResponse |
| 26 | + |
| 27 | +__all__ = ["ProjectResource", "AsyncProjectResource"] |
| 28 | + |
| 29 | + |
| 30 | +class ProjectResource(SyncAPIResource): |
| 31 | + @cached_property |
| 32 | + def with_raw_response(self) -> ProjectResourceWithRawResponse: |
| 33 | + """ |
| 34 | + This property can be used as a prefix for any HTTP method call to return the |
| 35 | + the raw response object instead of the parsed content. |
| 36 | +
|
| 37 | + For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers |
| 38 | + """ |
| 39 | + return ProjectResourceWithRawResponse(self) |
| 40 | + |
| 41 | + @cached_property |
| 42 | + def with_streaming_response(self) -> ProjectResourceWithStreamingResponse: |
| 43 | + """ |
| 44 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 45 | +
|
| 46 | + For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response |
| 47 | + """ |
| 48 | + return ProjectResourceWithStreamingResponse(self) |
| 49 | + |
| 50 | + def update( |
| 51 | + self, |
| 52 | + *, |
| 53 | + llm_model_group: Optional[str] | NotGiven = NOT_GIVEN, |
| 54 | + name: Optional[str] | NotGiven = NOT_GIVEN, |
| 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 | + ) -> Project: |
| 62 | + """ |
| 63 | + Update Project Name And Model Group |
| 64 | +
|
| 65 | + Args: |
| 66 | + llm_model_group: 模型组 |
| 67 | +
|
| 68 | + name: 项目名称 |
| 69 | +
|
| 70 | + extra_headers: Send extra headers |
| 71 | +
|
| 72 | + extra_query: Add additional query parameters to the request |
| 73 | +
|
| 74 | + extra_body: Add additional JSON properties to the request |
| 75 | +
|
| 76 | + timeout: Override the client-level default timeout for this request, in seconds |
| 77 | + """ |
| 78 | + return self._patch( |
| 79 | + "/project", |
| 80 | + body=maybe_transform( |
| 81 | + { |
| 82 | + "llm_model_group": llm_model_group, |
| 83 | + "name": name, |
| 84 | + }, |
| 85 | + project_update_params.ProjectUpdateParams, |
| 86 | + ), |
| 87 | + options=make_request_options( |
| 88 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 89 | + ), |
| 90 | + cast_to=Project, |
| 91 | + ) |
| 92 | + |
| 93 | + def list_model_groups( |
| 94 | + self, |
| 95 | + *, |
| 96 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 97 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 98 | + extra_headers: Headers | None = None, |
| 99 | + extra_query: Query | None = None, |
| 100 | + extra_body: Body | None = None, |
| 101 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 102 | + ) -> ProjectListModelGroupsResponse: |
| 103 | + """Get Llm Model Groups""" |
| 104 | + return self._get( |
| 105 | + "/project/model-groups", |
| 106 | + options=make_request_options( |
| 107 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 108 | + ), |
| 109 | + cast_to=ProjectListModelGroupsResponse, |
| 110 | + ) |
| 111 | + |
| 112 | + |
| 113 | +class AsyncProjectResource(AsyncAPIResource): |
| 114 | + @cached_property |
| 115 | + def with_raw_response(self) -> AsyncProjectResourceWithRawResponse: |
| 116 | + """ |
| 117 | + This property can be used as a prefix for any HTTP method call to return the |
| 118 | + the raw response object instead of the parsed content. |
| 119 | +
|
| 120 | + For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers |
| 121 | + """ |
| 122 | + return AsyncProjectResourceWithRawResponse(self) |
| 123 | + |
| 124 | + @cached_property |
| 125 | + def with_streaming_response(self) -> AsyncProjectResourceWithStreamingResponse: |
| 126 | + """ |
| 127 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 128 | +
|
| 129 | + For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response |
| 130 | + """ |
| 131 | + return AsyncProjectResourceWithStreamingResponse(self) |
| 132 | + |
| 133 | + async def update( |
| 134 | + self, |
| 135 | + *, |
| 136 | + llm_model_group: Optional[str] | NotGiven = NOT_GIVEN, |
| 137 | + name: Optional[str] | NotGiven = NOT_GIVEN, |
| 138 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 139 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 140 | + extra_headers: Headers | None = None, |
| 141 | + extra_query: Query | None = None, |
| 142 | + extra_body: Body | None = None, |
| 143 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 144 | + ) -> Project: |
| 145 | + """ |
| 146 | + Update Project Name And Model Group |
| 147 | +
|
| 148 | + Args: |
| 149 | + llm_model_group: 模型组 |
| 150 | +
|
| 151 | + name: 项目名称 |
| 152 | +
|
| 153 | + extra_headers: Send extra headers |
| 154 | +
|
| 155 | + extra_query: Add additional query parameters to the request |
| 156 | +
|
| 157 | + extra_body: Add additional JSON properties to the request |
| 158 | +
|
| 159 | + timeout: Override the client-level default timeout for this request, in seconds |
| 160 | + """ |
| 161 | + return await self._patch( |
| 162 | + "/project", |
| 163 | + body=await async_maybe_transform( |
| 164 | + { |
| 165 | + "llm_model_group": llm_model_group, |
| 166 | + "name": name, |
| 167 | + }, |
| 168 | + project_update_params.ProjectUpdateParams, |
| 169 | + ), |
| 170 | + options=make_request_options( |
| 171 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 172 | + ), |
| 173 | + cast_to=Project, |
| 174 | + ) |
| 175 | + |
| 176 | + async def list_model_groups( |
| 177 | + self, |
| 178 | + *, |
| 179 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 180 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 181 | + extra_headers: Headers | None = None, |
| 182 | + extra_query: Query | None = None, |
| 183 | + extra_body: Body | None = None, |
| 184 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 185 | + ) -> ProjectListModelGroupsResponse: |
| 186 | + """Get Llm Model Groups""" |
| 187 | + return await self._get( |
| 188 | + "/project/model-groups", |
| 189 | + options=make_request_options( |
| 190 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 191 | + ), |
| 192 | + cast_to=ProjectListModelGroupsResponse, |
| 193 | + ) |
| 194 | + |
| 195 | + |
| 196 | +class ProjectResourceWithRawResponse: |
| 197 | + def __init__(self, project: ProjectResource) -> None: |
| 198 | + self._project = project |
| 199 | + |
| 200 | + self.update = to_raw_response_wrapper( |
| 201 | + project.update, |
| 202 | + ) |
| 203 | + self.list_model_groups = to_raw_response_wrapper( |
| 204 | + project.list_model_groups, |
| 205 | + ) |
| 206 | + |
| 207 | + |
| 208 | +class AsyncProjectResourceWithRawResponse: |
| 209 | + def __init__(self, project: AsyncProjectResource) -> None: |
| 210 | + self._project = project |
| 211 | + |
| 212 | + self.update = async_to_raw_response_wrapper( |
| 213 | + project.update, |
| 214 | + ) |
| 215 | + self.list_model_groups = async_to_raw_response_wrapper( |
| 216 | + project.list_model_groups, |
| 217 | + ) |
| 218 | + |
| 219 | + |
| 220 | +class ProjectResourceWithStreamingResponse: |
| 221 | + def __init__(self, project: ProjectResource) -> None: |
| 222 | + self._project = project |
| 223 | + |
| 224 | + self.update = to_streamed_response_wrapper( |
| 225 | + project.update, |
| 226 | + ) |
| 227 | + self.list_model_groups = to_streamed_response_wrapper( |
| 228 | + project.list_model_groups, |
| 229 | + ) |
| 230 | + |
| 231 | + |
| 232 | +class AsyncProjectResourceWithStreamingResponse: |
| 233 | + def __init__(self, project: AsyncProjectResource) -> None: |
| 234 | + self._project = project |
| 235 | + |
| 236 | + self.update = async_to_streamed_response_wrapper( |
| 237 | + project.update, |
| 238 | + ) |
| 239 | + self.list_model_groups = async_to_streamed_response_wrapper( |
| 240 | + project.list_model_groups, |
| 241 | + ) |
0 commit comments