openai/openai-python
Publicmirrored from https://github.com/openai/openai-pythonAvailable
tests/api_resources/beta/test_assistants.py
548lines · modeblame
5cfb125aStainless Bot2 years ago | 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
baa9f07fRobert Craigie2 years ago | 2 | |
| 3 | from __future__ import annotations | |
| 4 | | |
| 5 | import os | |
86379b44Stainless Bot2 years ago | 6 | from typing import Any, cast |
baa9f07fRobert Craigie2 years ago | 7 | |
| 8 | import pytest | |
| 9 | | |
| 10 | from openai import OpenAI, AsyncOpenAI | |
| 11 | from tests.utils import assert_matches_type | |
| 12 | from openai.pagination import SyncCursorPage, AsyncCursorPage | |
4a0f0fa0Stainless Bot2 years ago | 13 | from openai.types.beta import ( |
| 14 | Assistant, | |
| 15 | AssistantDeleted, | |
| 16 | ) | |
baa9f07fRobert Craigie2 years ago | 17 | |
c4f76b2estainless-app[bot]5 months ago | 18 | # pyright: reportDeprecated=false |
| 19 | | |
baa9f07fRobert Craigie2 years ago | 20 | base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") |
| 21 | | |
| 22 | | |
| 23 | class TestAssistants: | |
98d779fbStainless Bot2 years ago | 24 | parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) |
baa9f07fRobert Craigie2 years ago | 25 | |
| 26 | @parametrize | |
| 27 | def test_method_create(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 28 | with pytest.warns(DeprecationWarning): |
| 29 | assistant = client.beta.assistants.create( | |
| 30 | model="gpt-4o", | |
| 31 | ) | |
| 32 | | |
baa9f07fRobert Craigie2 years ago | 33 | assert_matches_type(Assistant, assistant, path=["response"]) |
| 34 | | |
| 35 | @parametrize | |
| 36 | def test_method_create_with_all_params(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 37 | with pytest.warns(DeprecationWarning): |
| 38 | assistant = client.beta.assistants.create( | |
| 39 | model="gpt-4o", | |
| 40 | description="description", | |
| 41 | instructions="instructions", | |
| 42 | metadata={"foo": "string"}, | |
| 43 | name="name", | |
| 44 | reasoning_effort="none", | |
| 45 | response_format="auto", | |
| 46 | temperature=1, | |
| 47 | tool_resources={ | |
| 48 | "code_interpreter": {"file_ids": ["string"]}, | |
| 49 | "file_search": { | |
| 50 | "vector_store_ids": ["string"], | |
| 51 | "vector_stores": [ | |
| 52 | { | |
| 53 | "chunking_strategy": {"type": "auto"}, | |
| 54 | "file_ids": ["string"], | |
| 55 | "metadata": {"foo": "string"}, | |
| 56 | } | |
| 57 | ], | |
| 58 | }, | |
5b20698dStainless Bot2 years ago | 59 | }, |
c4f76b2estainless-app[bot]5 months ago | 60 | tools=[{"type": "code_interpreter"}], |
| 61 | top_p=1, | |
| 62 | ) | |
| 63 | | |
baa9f07fRobert Craigie2 years ago | 64 | assert_matches_type(Assistant, assistant, path=["response"]) |
| 65 | | |
| 66 | @parametrize | |
| 67 | def test_raw_response_create(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 68 | with pytest.warns(DeprecationWarning): |
| 69 | response = client.beta.assistants.with_raw_response.create( | |
| 70 | model="gpt-4o", | |
| 71 | ) | |
86379b44Stainless Bot2 years ago | 72 | |
| 73 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 74 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 75 | assistant = response.parse() | |
| 76 | assert_matches_type(Assistant, assistant, path=["response"]) | |
| 77 | | |
86379b44Stainless Bot2 years ago | 78 | @parametrize |
| 79 | def test_streaming_response_create(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 80 | with pytest.warns(DeprecationWarning): |
| 81 | with client.beta.assistants.with_streaming_response.create( | |
| 82 | model="gpt-4o", | |
| 83 | ) as response: | |
| 84 | assert not response.is_closed | |
| 85 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
86379b44Stainless Bot2 years ago | 86 | |
c4f76b2estainless-app[bot]5 months ago | 87 | assistant = response.parse() |
| 88 | assert_matches_type(Assistant, assistant, path=["response"]) | |
86379b44Stainless Bot2 years ago | 89 | |
| 90 | assert cast(Any, response.is_closed) is True | |
| 91 | | |
baa9f07fRobert Craigie2 years ago | 92 | @parametrize |
| 93 | def test_method_retrieve(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 94 | with pytest.warns(DeprecationWarning): |
| 95 | assistant = client.beta.assistants.retrieve( | |
| 96 | "assistant_id", | |
| 97 | ) | |
| 98 | | |
baa9f07fRobert Craigie2 years ago | 99 | assert_matches_type(Assistant, assistant, path=["response"]) |
| 100 | | |
| 101 | @parametrize | |
| 102 | def test_raw_response_retrieve(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 103 | with pytest.warns(DeprecationWarning): |
| 104 | response = client.beta.assistants.with_raw_response.retrieve( | |
| 105 | "assistant_id", | |
| 106 | ) | |
86379b44Stainless Bot2 years ago | 107 | |
| 108 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 109 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 110 | assistant = response.parse() | |
| 111 | assert_matches_type(Assistant, assistant, path=["response"]) | |
| 112 | | |
86379b44Stainless Bot2 years ago | 113 | @parametrize |
| 114 | def test_streaming_response_retrieve(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 115 | with pytest.warns(DeprecationWarning): |
| 116 | with client.beta.assistants.with_streaming_response.retrieve( | |
| 117 | "assistant_id", | |
| 118 | ) as response: | |
| 119 | assert not response.is_closed | |
| 120 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
86379b44Stainless Bot2 years ago | 121 | |
c4f76b2estainless-app[bot]5 months ago | 122 | assistant = response.parse() |
| 123 | assert_matches_type(Assistant, assistant, path=["response"]) | |
86379b44Stainless Bot2 years ago | 124 | |
| 125 | assert cast(Any, response.is_closed) is True | |
| 126 | | |
023a4e66Stainless Bot2 years ago | 127 | @parametrize |
| 128 | def test_path_params_retrieve(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 129 | with pytest.warns(DeprecationWarning): |
| 130 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): | |
| 131 | client.beta.assistants.with_raw_response.retrieve( | |
| 132 | "", | |
| 133 | ) | |
023a4e66Stainless Bot2 years ago | 134 | |
baa9f07fRobert Craigie2 years ago | 135 | @parametrize |
| 136 | def test_method_update(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 137 | with pytest.warns(DeprecationWarning): |
| 138 | assistant = client.beta.assistants.update( | |
| 139 | assistant_id="assistant_id", | |
| 140 | ) | |
| 141 | | |
baa9f07fRobert Craigie2 years ago | 142 | assert_matches_type(Assistant, assistant, path=["response"]) |
| 143 | | |
| 144 | @parametrize | |
| 145 | def test_method_update_with_all_params(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 146 | with pytest.warns(DeprecationWarning): |
| 147 | assistant = client.beta.assistants.update( | |
| 148 | assistant_id="assistant_id", | |
| 149 | description="description", | |
| 150 | instructions="instructions", | |
| 151 | metadata={"foo": "string"}, | |
e5b65b1fstainless-app[bot]3 months ago | 152 | model="gpt-5", |
c4f76b2estainless-app[bot]5 months ago | 153 | name="name", |
| 154 | reasoning_effort="none", | |
| 155 | response_format="auto", | |
| 156 | temperature=1, | |
| 157 | tool_resources={ | |
| 158 | "code_interpreter": {"file_ids": ["string"]}, | |
| 159 | "file_search": {"vector_store_ids": ["string"]}, | |
| 160 | }, | |
| 161 | tools=[{"type": "code_interpreter"}], | |
| 162 | top_p=1, | |
| 163 | ) | |
| 164 | | |
baa9f07fRobert Craigie2 years ago | 165 | assert_matches_type(Assistant, assistant, path=["response"]) |
| 166 | | |
| 167 | @parametrize | |
| 168 | def test_raw_response_update(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 169 | with pytest.warns(DeprecationWarning): |
| 170 | response = client.beta.assistants.with_raw_response.update( | |
| 171 | assistant_id="assistant_id", | |
| 172 | ) | |
86379b44Stainless Bot2 years ago | 173 | |
| 174 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 175 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 176 | assistant = response.parse() | |
| 177 | assert_matches_type(Assistant, assistant, path=["response"]) | |
| 178 | | |
86379b44Stainless Bot2 years ago | 179 | @parametrize |
| 180 | def test_streaming_response_update(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 181 | with pytest.warns(DeprecationWarning): |
| 182 | with client.beta.assistants.with_streaming_response.update( | |
| 183 | assistant_id="assistant_id", | |
| 184 | ) as response: | |
| 185 | assert not response.is_closed | |
| 186 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
86379b44Stainless Bot2 years ago | 187 | |
c4f76b2estainless-app[bot]5 months ago | 188 | assistant = response.parse() |
| 189 | assert_matches_type(Assistant, assistant, path=["response"]) | |
86379b44Stainless Bot2 years ago | 190 | |
| 191 | assert cast(Any, response.is_closed) is True | |
| 192 | | |
023a4e66Stainless Bot2 years ago | 193 | @parametrize |
| 194 | def test_path_params_update(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 195 | with pytest.warns(DeprecationWarning): |
| 196 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): | |
| 197 | client.beta.assistants.with_raw_response.update( | |
| 198 | assistant_id="", | |
| 199 | ) | |
023a4e66Stainless Bot2 years ago | 200 | |
baa9f07fRobert Craigie2 years ago | 201 | @parametrize |
| 202 | def test_method_list(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 203 | with pytest.warns(DeprecationWarning): |
| 204 | assistant = client.beta.assistants.list() | |
| 205 | | |
baa9f07fRobert Craigie2 years ago | 206 | assert_matches_type(SyncCursorPage[Assistant], assistant, path=["response"]) |
| 207 | | |
| 208 | @parametrize | |
| 209 | def test_method_list_with_all_params(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 210 | with pytest.warns(DeprecationWarning): |
| 211 | assistant = client.beta.assistants.list( | |
| 212 | after="after", | |
| 213 | before="before", | |
| 214 | limit=0, | |
| 215 | order="asc", | |
| 216 | ) | |
| 217 | | |
baa9f07fRobert Craigie2 years ago | 218 | assert_matches_type(SyncCursorPage[Assistant], assistant, path=["response"]) |
| 219 | | |
| 220 | @parametrize | |
| 221 | def test_raw_response_list(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 222 | with pytest.warns(DeprecationWarning): |
| 223 | response = client.beta.assistants.with_raw_response.list() | |
86379b44Stainless Bot2 years ago | 224 | |
| 225 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 226 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 227 | assistant = response.parse() | |
| 228 | assert_matches_type(SyncCursorPage[Assistant], assistant, path=["response"]) | |
| 229 | | |
86379b44Stainless Bot2 years ago | 230 | @parametrize |
| 231 | def test_streaming_response_list(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 232 | with pytest.warns(DeprecationWarning): |
| 233 | with client.beta.assistants.with_streaming_response.list() as response: | |
| 234 | assert not response.is_closed | |
| 235 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
86379b44Stainless Bot2 years ago | 236 | |
c4f76b2estainless-app[bot]5 months ago | 237 | assistant = response.parse() |
| 238 | assert_matches_type(SyncCursorPage[Assistant], assistant, path=["response"]) | |
86379b44Stainless Bot2 years ago | 239 | |
| 240 | assert cast(Any, response.is_closed) is True | |
| 241 | | |
baa9f07fRobert Craigie2 years ago | 242 | @parametrize |
| 243 | def test_method_delete(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 244 | with pytest.warns(DeprecationWarning): |
| 245 | assistant = client.beta.assistants.delete( | |
| 246 | "assistant_id", | |
| 247 | ) | |
| 248 | | |
f5ef2b3aStainless Bot2 years ago | 249 | assert_matches_type(AssistantDeleted, assistant, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 250 | |
| 251 | @parametrize | |
| 252 | def test_raw_response_delete(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 253 | with pytest.warns(DeprecationWarning): |
| 254 | response = client.beta.assistants.with_raw_response.delete( | |
| 255 | "assistant_id", | |
| 256 | ) | |
86379b44Stainless Bot2 years ago | 257 | |
| 258 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 259 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 260 | assistant = response.parse() | |
f5ef2b3aStainless Bot2 years ago | 261 | assert_matches_type(AssistantDeleted, assistant, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 262 | |
86379b44Stainless Bot2 years ago | 263 | @parametrize |
| 264 | def test_streaming_response_delete(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 265 | with pytest.warns(DeprecationWarning): |
| 266 | with client.beta.assistants.with_streaming_response.delete( | |
| 267 | "assistant_id", | |
| 268 | ) as response: | |
| 269 | assert not response.is_closed | |
| 270 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
86379b44Stainless Bot2 years ago | 271 | |
c4f76b2estainless-app[bot]5 months ago | 272 | assistant = response.parse() |
| 273 | assert_matches_type(AssistantDeleted, assistant, path=["response"]) | |
86379b44Stainless Bot2 years ago | 274 | |
| 275 | assert cast(Any, response.is_closed) is True | |
| 276 | | |
023a4e66Stainless Bot2 years ago | 277 | @parametrize |
| 278 | def test_path_params_delete(self, client: OpenAI) -> None: | |
c4f76b2estainless-app[bot]5 months ago | 279 | with pytest.warns(DeprecationWarning): |
| 280 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): | |
| 281 | client.beta.assistants.with_raw_response.delete( | |
| 282 | "", | |
| 283 | ) | |
023a4e66Stainless Bot2 years ago | 284 | |
baa9f07fRobert Craigie2 years ago | 285 | |
| 286 | class TestAsyncAssistants: | |
d7700afdstainless-app[bot]1 years ago | 287 | parametrize = pytest.mark.parametrize( |
| 288 | "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] | |
| 289 | ) | |
baa9f07fRobert Craigie2 years ago | 290 | |
| 291 | @parametrize | |
98d779fbStainless Bot2 years ago | 292 | async def test_method_create(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 293 | with pytest.warns(DeprecationWarning): |
| 294 | assistant = await async_client.beta.assistants.create( | |
| 295 | model="gpt-4o", | |
| 296 | ) | |
| 297 | | |
baa9f07fRobert Craigie2 years ago | 298 | assert_matches_type(Assistant, assistant, path=["response"]) |
| 299 | | |
| 300 | @parametrize | |
98d779fbStainless Bot2 years ago | 301 | async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 302 | with pytest.warns(DeprecationWarning): |
| 303 | assistant = await async_client.beta.assistants.create( | |
| 304 | model="gpt-4o", | |
| 305 | description="description", | |
| 306 | instructions="instructions", | |
| 307 | metadata={"foo": "string"}, | |
| 308 | name="name", | |
| 309 | reasoning_effort="none", | |
| 310 | response_format="auto", | |
| 311 | temperature=1, | |
| 312 | tool_resources={ | |
| 313 | "code_interpreter": {"file_ids": ["string"]}, | |
| 314 | "file_search": { | |
| 315 | "vector_store_ids": ["string"], | |
| 316 | "vector_stores": [ | |
| 317 | { | |
| 318 | "chunking_strategy": {"type": "auto"}, | |
| 319 | "file_ids": ["string"], | |
| 320 | "metadata": {"foo": "string"}, | |
| 321 | } | |
| 322 | ], | |
| 323 | }, | |
5b20698dStainless Bot2 years ago | 324 | }, |
c4f76b2estainless-app[bot]5 months ago | 325 | tools=[{"type": "code_interpreter"}], |
| 326 | top_p=1, | |
| 327 | ) | |
| 328 | | |
baa9f07fRobert Craigie2 years ago | 329 | assert_matches_type(Assistant, assistant, path=["response"]) |
| 330 | | |
| 331 | @parametrize | |
98d779fbStainless Bot2 years ago | 332 | async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 333 | with pytest.warns(DeprecationWarning): |
| 334 | response = await async_client.beta.assistants.with_raw_response.create( | |
| 335 | model="gpt-4o", | |
| 336 | ) | |
86379b44Stainless Bot2 years ago | 337 | |
| 338 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 339 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 340 | assistant = response.parse() | |
| 341 | assert_matches_type(Assistant, assistant, path=["response"]) | |
| 342 | | |
86379b44Stainless Bot2 years ago | 343 | @parametrize |
98d779fbStainless Bot2 years ago | 344 | async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 345 | with pytest.warns(DeprecationWarning): |
| 346 | async with async_client.beta.assistants.with_streaming_response.create( | |
| 347 | model="gpt-4o", | |
| 348 | ) as response: | |
| 349 | assert not response.is_closed | |
| 350 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
86379b44Stainless Bot2 years ago | 351 | |
c4f76b2estainless-app[bot]5 months ago | 352 | assistant = await response.parse() |
| 353 | assert_matches_type(Assistant, assistant, path=["response"]) | |
86379b44Stainless Bot2 years ago | 354 | |
| 355 | assert cast(Any, response.is_closed) is True | |
| 356 | | |
baa9f07fRobert Craigie2 years ago | 357 | @parametrize |
98d779fbStainless Bot2 years ago | 358 | async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 359 | with pytest.warns(DeprecationWarning): |
| 360 | assistant = await async_client.beta.assistants.retrieve( | |
| 361 | "assistant_id", | |
| 362 | ) | |
| 363 | | |
baa9f07fRobert Craigie2 years ago | 364 | assert_matches_type(Assistant, assistant, path=["response"]) |
| 365 | | |
| 366 | @parametrize | |
98d779fbStainless Bot2 years ago | 367 | async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 368 | with pytest.warns(DeprecationWarning): |
| 369 | response = await async_client.beta.assistants.with_raw_response.retrieve( | |
| 370 | "assistant_id", | |
| 371 | ) | |
86379b44Stainless Bot2 years ago | 372 | |
| 373 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 374 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 375 | assistant = response.parse() | |
| 376 | assert_matches_type(Assistant, assistant, path=["response"]) | |
| 377 | | |
86379b44Stainless Bot2 years ago | 378 | @parametrize |
98d779fbStainless Bot2 years ago | 379 | async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 380 | with pytest.warns(DeprecationWarning): |
| 381 | async with async_client.beta.assistants.with_streaming_response.retrieve( | |
| 382 | "assistant_id", | |
| 383 | ) as response: | |
| 384 | assert not response.is_closed | |
| 385 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
86379b44Stainless Bot2 years ago | 386 | |
c4f76b2estainless-app[bot]5 months ago | 387 | assistant = await response.parse() |
| 388 | assert_matches_type(Assistant, assistant, path=["response"]) | |
86379b44Stainless Bot2 years ago | 389 | |
| 390 | assert cast(Any, response.is_closed) is True | |
| 391 | | |
023a4e66Stainless Bot2 years ago | 392 | @parametrize |
98d779fbStainless Bot2 years ago | 393 | async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 394 | with pytest.warns(DeprecationWarning): |
| 395 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): | |
| 396 | await async_client.beta.assistants.with_raw_response.retrieve( | |
| 397 | "", | |
| 398 | ) | |
023a4e66Stainless Bot2 years ago | 399 | |
baa9f07fRobert Craigie2 years ago | 400 | @parametrize |
98d779fbStainless Bot2 years ago | 401 | async def test_method_update(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 402 | with pytest.warns(DeprecationWarning): |
| 403 | assistant = await async_client.beta.assistants.update( | |
| 404 | assistant_id="assistant_id", | |
| 405 | ) | |
| 406 | | |
baa9f07fRobert Craigie2 years ago | 407 | assert_matches_type(Assistant, assistant, path=["response"]) |
| 408 | | |
| 409 | @parametrize | |
98d779fbStainless Bot2 years ago | 410 | async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 411 | with pytest.warns(DeprecationWarning): |
| 412 | assistant = await async_client.beta.assistants.update( | |
| 413 | assistant_id="assistant_id", | |
| 414 | description="description", | |
| 415 | instructions="instructions", | |
| 416 | metadata={"foo": "string"}, | |
e5b65b1fstainless-app[bot]3 months ago | 417 | model="gpt-5", |
c4f76b2estainless-app[bot]5 months ago | 418 | name="name", |
| 419 | reasoning_effort="none", | |
| 420 | response_format="auto", | |
| 421 | temperature=1, | |
| 422 | tool_resources={ | |
| 423 | "code_interpreter": {"file_ids": ["string"]}, | |
| 424 | "file_search": {"vector_store_ids": ["string"]}, | |
| 425 | }, | |
| 426 | tools=[{"type": "code_interpreter"}], | |
| 427 | top_p=1, | |
| 428 | ) | |
| 429 | | |
baa9f07fRobert Craigie2 years ago | 430 | assert_matches_type(Assistant, assistant, path=["response"]) |
| 431 | | |
| 432 | @parametrize | |
98d779fbStainless Bot2 years ago | 433 | async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 434 | with pytest.warns(DeprecationWarning): |
| 435 | response = await async_client.beta.assistants.with_raw_response.update( | |
| 436 | assistant_id="assistant_id", | |
| 437 | ) | |
86379b44Stainless Bot2 years ago | 438 | |
| 439 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 440 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 441 | assistant = response.parse() | |
| 442 | assert_matches_type(Assistant, assistant, path=["response"]) | |
| 443 | | |
86379b44Stainless Bot2 years ago | 444 | @parametrize |
98d779fbStainless Bot2 years ago | 445 | async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 446 | with pytest.warns(DeprecationWarning): |
| 447 | async with async_client.beta.assistants.with_streaming_response.update( | |
| 448 | assistant_id="assistant_id", | |
| 449 | ) as response: | |
| 450 | assert not response.is_closed | |
| 451 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
86379b44Stainless Bot2 years ago | 452 | |
c4f76b2estainless-app[bot]5 months ago | 453 | assistant = await response.parse() |
| 454 | assert_matches_type(Assistant, assistant, path=["response"]) | |
86379b44Stainless Bot2 years ago | 455 | |
| 456 | assert cast(Any, response.is_closed) is True | |
| 457 | | |
023a4e66Stainless Bot2 years ago | 458 | @parametrize |
98d779fbStainless Bot2 years ago | 459 | async def test_path_params_update(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 460 | with pytest.warns(DeprecationWarning): |
| 461 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): | |
| 462 | await async_client.beta.assistants.with_raw_response.update( | |
| 463 | assistant_id="", | |
| 464 | ) | |
023a4e66Stainless Bot2 years ago | 465 | |
baa9f07fRobert Craigie2 years ago | 466 | @parametrize |
98d779fbStainless Bot2 years ago | 467 | async def test_method_list(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 468 | with pytest.warns(DeprecationWarning): |
| 469 | assistant = await async_client.beta.assistants.list() | |
| 470 | | |
baa9f07fRobert Craigie2 years ago | 471 | assert_matches_type(AsyncCursorPage[Assistant], assistant, path=["response"]) |
| 472 | | |
| 473 | @parametrize | |
98d779fbStainless Bot2 years ago | 474 | async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 475 | with pytest.warns(DeprecationWarning): |
| 476 | assistant = await async_client.beta.assistants.list( | |
| 477 | after="after", | |
| 478 | before="before", | |
| 479 | limit=0, | |
| 480 | order="asc", | |
| 481 | ) | |
| 482 | | |
baa9f07fRobert Craigie2 years ago | 483 | assert_matches_type(AsyncCursorPage[Assistant], assistant, path=["response"]) |
| 484 | | |
| 485 | @parametrize | |
98d779fbStainless Bot2 years ago | 486 | async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 487 | with pytest.warns(DeprecationWarning): |
| 488 | response = await async_client.beta.assistants.with_raw_response.list() | |
86379b44Stainless Bot2 years ago | 489 | |
| 490 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 491 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 492 | assistant = response.parse() | |
| 493 | assert_matches_type(AsyncCursorPage[Assistant], assistant, path=["response"]) | |
| 494 | | |
86379b44Stainless Bot2 years ago | 495 | @parametrize |
98d779fbStainless Bot2 years ago | 496 | async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 497 | with pytest.warns(DeprecationWarning): |
| 498 | async with async_client.beta.assistants.with_streaming_response.list() as response: | |
| 499 | assert not response.is_closed | |
| 500 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
86379b44Stainless Bot2 years ago | 501 | |
c4f76b2estainless-app[bot]5 months ago | 502 | assistant = await response.parse() |
| 503 | assert_matches_type(AsyncCursorPage[Assistant], assistant, path=["response"]) | |
86379b44Stainless Bot2 years ago | 504 | |
| 505 | assert cast(Any, response.is_closed) is True | |
| 506 | | |
baa9f07fRobert Craigie2 years ago | 507 | @parametrize |
98d779fbStainless Bot2 years ago | 508 | async def test_method_delete(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 509 | with pytest.warns(DeprecationWarning): |
| 510 | assistant = await async_client.beta.assistants.delete( | |
| 511 | "assistant_id", | |
| 512 | ) | |
| 513 | | |
f5ef2b3aStainless Bot2 years ago | 514 | assert_matches_type(AssistantDeleted, assistant, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 515 | |
| 516 | @parametrize | |
98d779fbStainless Bot2 years ago | 517 | async def test_raw_response_delete(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 518 | with pytest.warns(DeprecationWarning): |
| 519 | response = await async_client.beta.assistants.with_raw_response.delete( | |
| 520 | "assistant_id", | |
| 521 | ) | |
86379b44Stainless Bot2 years ago | 522 | |
| 523 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 524 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 525 | assistant = response.parse() | |
f5ef2b3aStainless Bot2 years ago | 526 | assert_matches_type(AssistantDeleted, assistant, path=["response"]) |
86379b44Stainless Bot2 years ago | 527 | |
| 528 | @parametrize | |
98d779fbStainless Bot2 years ago | 529 | async def test_streaming_response_delete(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 530 | with pytest.warns(DeprecationWarning): |
| 531 | async with async_client.beta.assistants.with_streaming_response.delete( | |
| 532 | "assistant_id", | |
| 533 | ) as response: | |
| 534 | assert not response.is_closed | |
| 535 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
86379b44Stainless Bot2 years ago | 536 | |
c4f76b2estainless-app[bot]5 months ago | 537 | assistant = await response.parse() |
| 538 | assert_matches_type(AssistantDeleted, assistant, path=["response"]) | |
86379b44Stainless Bot2 years ago | 539 | |
| 540 | assert cast(Any, response.is_closed) is True | |
023a4e66Stainless Bot2 years ago | 541 | |
| 542 | @parametrize | |
98d779fbStainless Bot2 years ago | 543 | async def test_path_params_delete(self, async_client: AsyncOpenAI) -> None: |
c4f76b2estainless-app[bot]5 months ago | 544 | with pytest.warns(DeprecationWarning): |
| 545 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"): | |
| 546 | await async_client.beta.assistants.with_raw_response.delete( | |
| 547 | "", | |
| 548 | ) |