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