openai/openai-python
Publicmirrored from https://github.com/openai/openai-pythonAvailable
tests/api_resources/beta/threads/test_runs.py
1015lines · 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.threads import ( |
| 14 | Run, | |
| 15 | ) | |
baa9f07fRobert Craigie2 years ago | 16 | |
595f3b36Stainless Bot2 years ago | 17 | # pyright: reportDeprecated=false |
| 18 | | |
baa9f07fRobert Craigie2 years ago | 19 | base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") |
| 20 | | |
| 21 | | |
| 22 | class TestRuns: | |
98d779fbStainless Bot2 years ago | 23 | parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) |
baa9f07fRobert Craigie2 years ago | 24 | |
| 25 | @parametrize | |
5429f696Stainless Bot2 years ago | 26 | def test_method_create_overload_1(self, client: OpenAI) -> None: |
baa9f07fRobert Craigie2 years ago | 27 | run = client.beta.threads.runs.create( |
| 28 | "string", | |
| 29 | assistant_id="string", | |
| 30 | ) | |
| 31 | assert_matches_type(Run, run, path=["response"]) | |
| 32 | | |
| 33 | @parametrize | |
5429f696Stainless Bot2 years ago | 34 | def test_method_create_with_all_params_overload_1(self, client: OpenAI) -> None: |
baa9f07fRobert Craigie2 years ago | 35 | run = client.beta.threads.runs.create( |
5d3111a8Stainless Bot1 years ago | 36 | thread_id="thread_id", |
| 37 | assistant_id="assistant_id", | |
| 38 | include=["step_details.tool_calls[*].file_search.results[*].content"], | |
| 39 | additional_instructions="additional_instructions", | |
e2d65bf7Stainless Bot2 years ago | 40 | additional_messages=[ |
| 41 | { | |
79a0b401Stainless Bot2 years ago | 42 | "content": "string", |
092a8df7Stainless Bot1 years ago | 43 | "role": "user", |
5b20698dStainless Bot2 years ago | 44 | "attachments": [ |
| 45 | { | |
dd19d4f9Stainless Bot1 years ago | 46 | "file_id": "file_id", |
| 47 | "tools": [{"type": "code_interpreter"}], | |
| 48 | } | |
5b20698dStainless Bot2 years ago | 49 | ], |
fdd52476stainless-app[bot]1 years ago | 50 | "metadata": {"foo": "string"}, |
dd19d4f9Stainless Bot1 years ago | 51 | } |
e2d65bf7Stainless Bot2 years ago | 52 | ], |
baa9f07fRobert Craigie2 years ago | 53 | instructions="string", |
f5247e30Stainless Bot2 years ago | 54 | max_completion_tokens=256, |
| 55 | max_prompt_tokens=256, | |
fdd52476stainless-app[bot]1 years ago | 56 | metadata={"foo": "string"}, |
bf1ca86cRobert Craigie1 years ago | 57 | model="gpt-4o", |
7399ffc8Stainless Bot2 years ago | 58 | parallel_tool_calls=True, |
8640fd83stainless-app[bot]1 years ago | 59 | reasoning_effort="low", |
bf1ca86cRobert Craigie1 years ago | 60 | response_format="auto", |
5429f696Stainless Bot2 years ago | 61 | stream=False, |
27a4626aStainless Bot2 years ago | 62 | temperature=1, |
f5247e30Stainless Bot2 years ago | 63 | tool_choice="none", |
dd19d4f9Stainless Bot1 years ago | 64 | tools=[{"type": "code_interpreter"}], |
5b20698dStainless Bot2 years ago | 65 | top_p=1, |
f5247e30Stainless Bot2 years ago | 66 | truncation_strategy={ |
| 67 | "type": "auto", | |
| 68 | "last_messages": 1, | |
| 69 | }, | |
baa9f07fRobert Craigie2 years ago | 70 | ) |
| 71 | assert_matches_type(Run, run, path=["response"]) | |
| 72 | | |
| 73 | @parametrize | |
5429f696Stainless Bot2 years ago | 74 | def test_raw_response_create_overload_1(self, client: OpenAI) -> None: |
baa9f07fRobert Craigie2 years ago | 75 | response = client.beta.threads.runs.with_raw_response.create( |
| 76 | "string", | |
| 77 | assistant_id="string", | |
| 78 | ) | |
86379b44Stainless Bot2 years ago | 79 | |
| 80 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 81 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 82 | run = response.parse() | |
| 83 | assert_matches_type(Run, run, path=["response"]) | |
| 84 | | |
86379b44Stainless Bot2 years ago | 85 | @parametrize |
5429f696Stainless Bot2 years ago | 86 | def test_streaming_response_create_overload_1(self, client: OpenAI) -> None: |
86379b44Stainless Bot2 years ago | 87 | with client.beta.threads.runs.with_streaming_response.create( |
| 88 | "string", | |
| 89 | assistant_id="string", | |
| 90 | ) as response: | |
| 91 | assert not response.is_closed | |
| 92 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 93 | | |
| 94 | run = response.parse() | |
| 95 | assert_matches_type(Run, run, path=["response"]) | |
| 96 | | |
| 97 | assert cast(Any, response.is_closed) is True | |
| 98 | | |
023a4e66Stainless Bot2 years ago | 99 | @parametrize |
5429f696Stainless Bot2 years ago | 100 | def test_path_params_create_overload_1(self, client: OpenAI) -> None: |
023a4e66Stainless Bot2 years ago | 101 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 102 | client.beta.threads.runs.with_raw_response.create( | |
| 103 | "", | |
| 104 | assistant_id="string", | |
| 105 | ) | |
| 106 | | |
5429f696Stainless Bot2 years ago | 107 | @parametrize |
| 108 | def test_method_create_overload_2(self, client: OpenAI) -> None: | |
| 109 | run_stream = client.beta.threads.runs.create( | |
| 110 | "string", | |
| 111 | assistant_id="string", | |
| 112 | stream=True, | |
| 113 | ) | |
| 114 | run_stream.response.close() | |
| 115 | | |
| 116 | @parametrize | |
| 117 | def test_method_create_with_all_params_overload_2(self, client: OpenAI) -> None: | |
| 118 | run_stream = client.beta.threads.runs.create( | |
| 119 | "string", | |
| 120 | assistant_id="string", | |
| 121 | stream=True, | |
5d3111a8Stainless Bot1 years ago | 122 | include=["step_details.tool_calls[*].file_search.results[*].content"], |
| 123 | additional_instructions="additional_instructions", | |
e2d65bf7Stainless Bot2 years ago | 124 | additional_messages=[ |
| 125 | { | |
79a0b401Stainless Bot2 years ago | 126 | "content": "string", |
092a8df7Stainless Bot1 years ago | 127 | "role": "user", |
5b20698dStainless Bot2 years ago | 128 | "attachments": [ |
| 129 | { | |
dd19d4f9Stainless Bot1 years ago | 130 | "file_id": "file_id", |
| 131 | "tools": [{"type": "code_interpreter"}], | |
| 132 | } | |
5b20698dStainless Bot2 years ago | 133 | ], |
fdd52476stainless-app[bot]1 years ago | 134 | "metadata": {"foo": "string"}, |
dd19d4f9Stainless Bot1 years ago | 135 | } |
e2d65bf7Stainless Bot2 years ago | 136 | ], |
5429f696Stainless Bot2 years ago | 137 | instructions="string", |
f5247e30Stainless Bot2 years ago | 138 | max_completion_tokens=256, |
| 139 | max_prompt_tokens=256, | |
fdd52476stainless-app[bot]1 years ago | 140 | metadata={"foo": "string"}, |
bf1ca86cRobert Craigie1 years ago | 141 | model="gpt-4o", |
7399ffc8Stainless Bot2 years ago | 142 | parallel_tool_calls=True, |
8640fd83stainless-app[bot]1 years ago | 143 | reasoning_effort="low", |
bf1ca86cRobert Craigie1 years ago | 144 | response_format="auto", |
27a4626aStainless Bot2 years ago | 145 | temperature=1, |
f5247e30Stainless Bot2 years ago | 146 | tool_choice="none", |
dd19d4f9Stainless Bot1 years ago | 147 | tools=[{"type": "code_interpreter"}], |
5b20698dStainless Bot2 years ago | 148 | top_p=1, |
f5247e30Stainless Bot2 years ago | 149 | truncation_strategy={ |
| 150 | "type": "auto", | |
| 151 | "last_messages": 1, | |
| 152 | }, | |
5429f696Stainless Bot2 years ago | 153 | ) |
| 154 | run_stream.response.close() | |
| 155 | | |
| 156 | @parametrize | |
| 157 | def test_raw_response_create_overload_2(self, client: OpenAI) -> None: | |
| 158 | response = client.beta.threads.runs.with_raw_response.create( | |
| 159 | "string", | |
| 160 | assistant_id="string", | |
| 161 | stream=True, | |
| 162 | ) | |
| 163 | | |
| 164 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 165 | stream = response.parse() | |
| 166 | stream.close() | |
| 167 | | |
| 168 | @parametrize | |
| 169 | def test_streaming_response_create_overload_2(self, client: OpenAI) -> None: | |
| 170 | with client.beta.threads.runs.with_streaming_response.create( | |
| 171 | "string", | |
| 172 | assistant_id="string", | |
| 173 | stream=True, | |
| 174 | ) as response: | |
| 175 | assert not response.is_closed | |
| 176 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 177 | | |
| 178 | stream = response.parse() | |
| 179 | stream.close() | |
| 180 | | |
| 181 | assert cast(Any, response.is_closed) is True | |
| 182 | | |
| 183 | @parametrize | |
| 184 | def test_path_params_create_overload_2(self, client: OpenAI) -> None: | |
| 185 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): | |
| 186 | client.beta.threads.runs.with_raw_response.create( | |
| 187 | "", | |
| 188 | assistant_id="string", | |
| 189 | stream=True, | |
| 190 | ) | |
| 191 | | |
baa9f07fRobert Craigie2 years ago | 192 | @parametrize |
| 193 | def test_method_retrieve(self, client: OpenAI) -> None: | |
| 194 | run = client.beta.threads.runs.retrieve( | |
| 195 | "string", | |
| 196 | thread_id="string", | |
| 197 | ) | |
| 198 | assert_matches_type(Run, run, path=["response"]) | |
| 199 | | |
| 200 | @parametrize | |
| 201 | def test_raw_response_retrieve(self, client: OpenAI) -> None: | |
| 202 | response = client.beta.threads.runs.with_raw_response.retrieve( | |
| 203 | "string", | |
| 204 | thread_id="string", | |
| 205 | ) | |
86379b44Stainless Bot2 years ago | 206 | |
| 207 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 208 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 209 | run = response.parse() | |
| 210 | assert_matches_type(Run, run, path=["response"]) | |
| 211 | | |
86379b44Stainless Bot2 years ago | 212 | @parametrize |
| 213 | def test_streaming_response_retrieve(self, client: OpenAI) -> None: | |
| 214 | with client.beta.threads.runs.with_streaming_response.retrieve( | |
| 215 | "string", | |
| 216 | thread_id="string", | |
| 217 | ) as response: | |
| 218 | assert not response.is_closed | |
| 219 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 220 | | |
| 221 | run = response.parse() | |
| 222 | assert_matches_type(Run, run, path=["response"]) | |
| 223 | | |
| 224 | assert cast(Any, response.is_closed) is True | |
| 225 | | |
023a4e66Stainless Bot2 years ago | 226 | @parametrize |
| 227 | def test_path_params_retrieve(self, client: OpenAI) -> None: | |
| 228 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): | |
| 229 | client.beta.threads.runs.with_raw_response.retrieve( | |
| 230 | "string", | |
| 231 | thread_id="", | |
| 232 | ) | |
| 233 | | |
| 234 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): | |
| 235 | client.beta.threads.runs.with_raw_response.retrieve( | |
| 236 | "", | |
| 237 | thread_id="string", | |
| 238 | ) | |
| 239 | | |
baa9f07fRobert Craigie2 years ago | 240 | @parametrize |
| 241 | def test_method_update(self, client: OpenAI) -> None: | |
| 242 | run = client.beta.threads.runs.update( | |
| 243 | "string", | |
| 244 | thread_id="string", | |
| 245 | ) | |
| 246 | assert_matches_type(Run, run, path=["response"]) | |
| 247 | | |
| 248 | @parametrize | |
| 249 | def test_method_update_with_all_params(self, client: OpenAI) -> None: | |
| 250 | run = client.beta.threads.runs.update( | |
fdd52476stainless-app[bot]1 years ago | 251 | run_id="run_id", |
| 252 | thread_id="thread_id", | |
| 253 | metadata={"foo": "string"}, | |
baa9f07fRobert Craigie2 years ago | 254 | ) |
| 255 | assert_matches_type(Run, run, path=["response"]) | |
| 256 | | |
| 257 | @parametrize | |
| 258 | def test_raw_response_update(self, client: OpenAI) -> None: | |
| 259 | response = client.beta.threads.runs.with_raw_response.update( | |
| 260 | "string", | |
| 261 | thread_id="string", | |
| 262 | ) | |
86379b44Stainless Bot2 years ago | 263 | |
| 264 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 265 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 266 | run = response.parse() | |
| 267 | assert_matches_type(Run, run, path=["response"]) | |
| 268 | | |
86379b44Stainless Bot2 years ago | 269 | @parametrize |
| 270 | def test_streaming_response_update(self, client: OpenAI) -> None: | |
| 271 | with client.beta.threads.runs.with_streaming_response.update( | |
| 272 | "string", | |
| 273 | thread_id="string", | |
| 274 | ) as response: | |
| 275 | assert not response.is_closed | |
| 276 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 277 | | |
| 278 | run = response.parse() | |
| 279 | assert_matches_type(Run, run, path=["response"]) | |
| 280 | | |
| 281 | assert cast(Any, response.is_closed) is True | |
| 282 | | |
023a4e66Stainless Bot2 years ago | 283 | @parametrize |
| 284 | def test_path_params_update(self, client: OpenAI) -> None: | |
| 285 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): | |
| 286 | client.beta.threads.runs.with_raw_response.update( | |
| 287 | "string", | |
| 288 | thread_id="", | |
| 289 | ) | |
| 290 | | |
| 291 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): | |
| 292 | client.beta.threads.runs.with_raw_response.update( | |
| 293 | "", | |
| 294 | thread_id="string", | |
| 295 | ) | |
| 296 | | |
baa9f07fRobert Craigie2 years ago | 297 | @parametrize |
| 298 | def test_method_list(self, client: OpenAI) -> None: | |
| 299 | run = client.beta.threads.runs.list( | |
| 300 | "string", | |
| 301 | ) | |
| 302 | assert_matches_type(SyncCursorPage[Run], run, path=["response"]) | |
| 303 | | |
| 304 | @parametrize | |
| 305 | def test_method_list_with_all_params(self, client: OpenAI) -> None: | |
| 306 | run = client.beta.threads.runs.list( | |
| 307 | "string", | |
| 308 | after="string", | |
| 309 | before="string", | |
| 310 | limit=0, | |
| 311 | order="asc", | |
| 312 | ) | |
| 313 | assert_matches_type(SyncCursorPage[Run], run, path=["response"]) | |
| 314 | | |
| 315 | @parametrize | |
| 316 | def test_raw_response_list(self, client: OpenAI) -> None: | |
| 317 | response = client.beta.threads.runs.with_raw_response.list( | |
| 318 | "string", | |
| 319 | ) | |
86379b44Stainless Bot2 years ago | 320 | |
| 321 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 322 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 323 | run = response.parse() | |
| 324 | assert_matches_type(SyncCursorPage[Run], run, path=["response"]) | |
| 325 | | |
86379b44Stainless Bot2 years ago | 326 | @parametrize |
| 327 | def test_streaming_response_list(self, client: OpenAI) -> None: | |
| 328 | with client.beta.threads.runs.with_streaming_response.list( | |
| 329 | "string", | |
| 330 | ) as response: | |
| 331 | assert not response.is_closed | |
| 332 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 333 | | |
| 334 | run = response.parse() | |
| 335 | assert_matches_type(SyncCursorPage[Run], run, path=["response"]) | |
| 336 | | |
| 337 | assert cast(Any, response.is_closed) is True | |
| 338 | | |
023a4e66Stainless Bot2 years ago | 339 | @parametrize |
| 340 | def test_path_params_list(self, client: OpenAI) -> None: | |
| 341 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): | |
| 342 | client.beta.threads.runs.with_raw_response.list( | |
| 343 | "", | |
| 344 | ) | |
| 345 | | |
baa9f07fRobert Craigie2 years ago | 346 | @parametrize |
| 347 | def test_method_cancel(self, client: OpenAI) -> None: | |
| 348 | run = client.beta.threads.runs.cancel( | |
| 349 | "string", | |
| 350 | thread_id="string", | |
| 351 | ) | |
| 352 | assert_matches_type(Run, run, path=["response"]) | |
| 353 | | |
| 354 | @parametrize | |
| 355 | def test_raw_response_cancel(self, client: OpenAI) -> None: | |
| 356 | response = client.beta.threads.runs.with_raw_response.cancel( | |
| 357 | "string", | |
| 358 | thread_id="string", | |
| 359 | ) | |
86379b44Stainless Bot2 years ago | 360 | |
| 361 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 362 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 363 | run = response.parse() | |
| 364 | assert_matches_type(Run, run, path=["response"]) | |
| 365 | | |
86379b44Stainless Bot2 years ago | 366 | @parametrize |
| 367 | def test_streaming_response_cancel(self, client: OpenAI) -> None: | |
| 368 | with client.beta.threads.runs.with_streaming_response.cancel( | |
| 369 | "string", | |
| 370 | thread_id="string", | |
| 371 | ) as response: | |
| 372 | assert not response.is_closed | |
| 373 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 374 | | |
| 375 | run = response.parse() | |
| 376 | assert_matches_type(Run, run, path=["response"]) | |
| 377 | | |
| 378 | assert cast(Any, response.is_closed) is True | |
| 379 | | |
023a4e66Stainless Bot2 years ago | 380 | @parametrize |
| 381 | def test_path_params_cancel(self, client: OpenAI) -> None: | |
| 382 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): | |
| 383 | client.beta.threads.runs.with_raw_response.cancel( | |
| 384 | "string", | |
| 385 | thread_id="", | |
| 386 | ) | |
| 387 | | |
| 388 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): | |
| 389 | client.beta.threads.runs.with_raw_response.cancel( | |
| 390 | "", | |
| 391 | thread_id="string", | |
| 392 | ) | |
| 393 | | |
baa9f07fRobert Craigie2 years ago | 394 | @parametrize |
5429f696Stainless Bot2 years ago | 395 | def test_method_submit_tool_outputs_overload_1(self, client: OpenAI) -> None: |
baa9f07fRobert Craigie2 years ago | 396 | run = client.beta.threads.runs.submit_tool_outputs( |
dd19d4f9Stainless Bot1 years ago | 397 | run_id="run_id", |
| 398 | thread_id="thread_id", | |
| 399 | tool_outputs=[{}], | |
baa9f07fRobert Craigie2 years ago | 400 | ) |
| 401 | assert_matches_type(Run, run, path=["response"]) | |
| 402 | | |
| 403 | @parametrize | |
5429f696Stainless Bot2 years ago | 404 | def test_method_submit_tool_outputs_with_all_params_overload_1(self, client: OpenAI) -> None: |
| 405 | run = client.beta.threads.runs.submit_tool_outputs( | |
| 406 | "string", | |
| 407 | thread_id="string", | |
| 408 | tool_outputs=[ | |
| 409 | { | |
092a8df7Stainless Bot1 years ago | 410 | "output": "output", |
| 411 | "tool_call_id": "tool_call_id", | |
dd19d4f9Stainless Bot1 years ago | 412 | } |
5429f696Stainless Bot2 years ago | 413 | ], |
| 414 | stream=False, | |
| 415 | ) | |
| 416 | assert_matches_type(Run, run, path=["response"]) | |
| 417 | | |
| 418 | @parametrize | |
| 419 | def test_raw_response_submit_tool_outputs_overload_1(self, client: OpenAI) -> None: | |
baa9f07fRobert Craigie2 years ago | 420 | response = client.beta.threads.runs.with_raw_response.submit_tool_outputs( |
dd19d4f9Stainless Bot1 years ago | 421 | run_id="run_id", |
| 422 | thread_id="thread_id", | |
| 423 | tool_outputs=[{}], | |
baa9f07fRobert Craigie2 years ago | 424 | ) |
86379b44Stainless Bot2 years ago | 425 | |
| 426 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 427 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 428 | run = response.parse() | |
| 429 | assert_matches_type(Run, run, path=["response"]) | |
| 430 | | |
86379b44Stainless Bot2 years ago | 431 | @parametrize |
5429f696Stainless Bot2 years ago | 432 | def test_streaming_response_submit_tool_outputs_overload_1(self, client: OpenAI) -> None: |
86379b44Stainless Bot2 years ago | 433 | with client.beta.threads.runs.with_streaming_response.submit_tool_outputs( |
dd19d4f9Stainless Bot1 years ago | 434 | run_id="run_id", |
| 435 | thread_id="thread_id", | |
| 436 | tool_outputs=[{}], | |
86379b44Stainless Bot2 years ago | 437 | ) as response: |
| 438 | assert not response.is_closed | |
| 439 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 440 | | |
| 441 | run = response.parse() | |
| 442 | assert_matches_type(Run, run, path=["response"]) | |
| 443 | | |
| 444 | assert cast(Any, response.is_closed) is True | |
| 445 | | |
023a4e66Stainless Bot2 years ago | 446 | @parametrize |
5429f696Stainless Bot2 years ago | 447 | def test_path_params_submit_tool_outputs_overload_1(self, client: OpenAI) -> None: |
| 448 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): | |
| 449 | client.beta.threads.runs.with_raw_response.submit_tool_outputs( | |
| 450 | "string", | |
| 451 | thread_id="", | |
dd19d4f9Stainless Bot1 years ago | 452 | tool_outputs=[{}], |
5429f696Stainless Bot2 years ago | 453 | ) |
| 454 | | |
| 455 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): | |
| 456 | client.beta.threads.runs.with_raw_response.submit_tool_outputs( | |
dd19d4f9Stainless Bot1 years ago | 457 | run_id="", |
| 458 | thread_id="thread_id", | |
| 459 | tool_outputs=[{}], | |
5429f696Stainless Bot2 years ago | 460 | ) |
| 461 | | |
| 462 | @parametrize | |
| 463 | def test_method_submit_tool_outputs_overload_2(self, client: OpenAI) -> None: | |
| 464 | run_stream = client.beta.threads.runs.submit_tool_outputs( | |
| 465 | "string", | |
| 466 | thread_id="string", | |
| 467 | stream=True, | |
dd19d4f9Stainless Bot1 years ago | 468 | tool_outputs=[{}], |
5429f696Stainless Bot2 years ago | 469 | ) |
| 470 | run_stream.response.close() | |
| 471 | | |
| 472 | @parametrize | |
| 473 | def test_raw_response_submit_tool_outputs_overload_2(self, client: OpenAI) -> None: | |
| 474 | response = client.beta.threads.runs.with_raw_response.submit_tool_outputs( | |
| 475 | "string", | |
| 476 | thread_id="string", | |
| 477 | stream=True, | |
dd19d4f9Stainless Bot1 years ago | 478 | tool_outputs=[{}], |
5429f696Stainless Bot2 years ago | 479 | ) |
| 480 | | |
| 481 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 482 | stream = response.parse() | |
| 483 | stream.close() | |
| 484 | | |
| 485 | @parametrize | |
| 486 | def test_streaming_response_submit_tool_outputs_overload_2(self, client: OpenAI) -> None: | |
| 487 | with client.beta.threads.runs.with_streaming_response.submit_tool_outputs( | |
| 488 | "string", | |
| 489 | thread_id="string", | |
| 490 | stream=True, | |
dd19d4f9Stainless Bot1 years ago | 491 | tool_outputs=[{}], |
5429f696Stainless Bot2 years ago | 492 | ) as response: |
| 493 | assert not response.is_closed | |
| 494 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 495 | | |
| 496 | stream = response.parse() | |
| 497 | stream.close() | |
| 498 | | |
| 499 | assert cast(Any, response.is_closed) is True | |
| 500 | | |
| 501 | @parametrize | |
| 502 | def test_path_params_submit_tool_outputs_overload_2(self, client: OpenAI) -> None: | |
023a4e66Stainless Bot2 years ago | 503 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 504 | client.beta.threads.runs.with_raw_response.submit_tool_outputs( | |
| 505 | "string", | |
| 506 | thread_id="", | |
5429f696Stainless Bot2 years ago | 507 | stream=True, |
dd19d4f9Stainless Bot1 years ago | 508 | tool_outputs=[{}], |
023a4e66Stainless Bot2 years ago | 509 | ) |
| 510 | | |
| 511 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): | |
| 512 | client.beta.threads.runs.with_raw_response.submit_tool_outputs( | |
| 513 | "", | |
| 514 | thread_id="string", | |
5429f696Stainless Bot2 years ago | 515 | stream=True, |
dd19d4f9Stainless Bot1 years ago | 516 | tool_outputs=[{}], |
023a4e66Stainless Bot2 years ago | 517 | ) |
| 518 | | |
baa9f07fRobert Craigie2 years ago | 519 | |
| 520 | class TestAsyncRuns: | |
98d779fbStainless Bot2 years ago | 521 | parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) |
baa9f07fRobert Craigie2 years ago | 522 | |
| 523 | @parametrize | |
5429f696Stainless Bot2 years ago | 524 | async def test_method_create_overload_1(self, async_client: AsyncOpenAI) -> None: |
98d779fbStainless Bot2 years ago | 525 | run = await async_client.beta.threads.runs.create( |
baa9f07fRobert Craigie2 years ago | 526 | "string", |
| 527 | assistant_id="string", | |
| 528 | ) | |
| 529 | assert_matches_type(Run, run, path=["response"]) | |
| 530 | | |
| 531 | @parametrize | |
5429f696Stainless Bot2 years ago | 532 | async def test_method_create_with_all_params_overload_1(self, async_client: AsyncOpenAI) -> None: |
98d779fbStainless Bot2 years ago | 533 | run = await async_client.beta.threads.runs.create( |
5d3111a8Stainless Bot1 years ago | 534 | thread_id="thread_id", |
| 535 | assistant_id="assistant_id", | |
| 536 | include=["step_details.tool_calls[*].file_search.results[*].content"], | |
| 537 | additional_instructions="additional_instructions", | |
e2d65bf7Stainless Bot2 years ago | 538 | additional_messages=[ |
| 539 | { | |
79a0b401Stainless Bot2 years ago | 540 | "content": "string", |
092a8df7Stainless Bot1 years ago | 541 | "role": "user", |
5b20698dStainless Bot2 years ago | 542 | "attachments": [ |
| 543 | { | |
dd19d4f9Stainless Bot1 years ago | 544 | "file_id": "file_id", |
| 545 | "tools": [{"type": "code_interpreter"}], | |
| 546 | } | |
5b20698dStainless Bot2 years ago | 547 | ], |
fdd52476stainless-app[bot]1 years ago | 548 | "metadata": {"foo": "string"}, |
dd19d4f9Stainless Bot1 years ago | 549 | } |
e2d65bf7Stainless Bot2 years ago | 550 | ], |
baa9f07fRobert Craigie2 years ago | 551 | instructions="string", |
f5247e30Stainless Bot2 years ago | 552 | max_completion_tokens=256, |
| 553 | max_prompt_tokens=256, | |
fdd52476stainless-app[bot]1 years ago | 554 | metadata={"foo": "string"}, |
bf1ca86cRobert Craigie1 years ago | 555 | model="gpt-4o", |
7399ffc8Stainless Bot2 years ago | 556 | parallel_tool_calls=True, |
8640fd83stainless-app[bot]1 years ago | 557 | reasoning_effort="low", |
bf1ca86cRobert Craigie1 years ago | 558 | response_format="auto", |
5429f696Stainless Bot2 years ago | 559 | stream=False, |
27a4626aStainless Bot2 years ago | 560 | temperature=1, |
f5247e30Stainless Bot2 years ago | 561 | tool_choice="none", |
dd19d4f9Stainless Bot1 years ago | 562 | tools=[{"type": "code_interpreter"}], |
5b20698dStainless Bot2 years ago | 563 | top_p=1, |
f5247e30Stainless Bot2 years ago | 564 | truncation_strategy={ |
| 565 | "type": "auto", | |
| 566 | "last_messages": 1, | |
| 567 | }, | |
baa9f07fRobert Craigie2 years ago | 568 | ) |
| 569 | assert_matches_type(Run, run, path=["response"]) | |
| 570 | | |
| 571 | @parametrize | |
5429f696Stainless Bot2 years ago | 572 | async def test_raw_response_create_overload_1(self, async_client: AsyncOpenAI) -> None: |
98d779fbStainless Bot2 years ago | 573 | response = await async_client.beta.threads.runs.with_raw_response.create( |
baa9f07fRobert Craigie2 years ago | 574 | "string", |
| 575 | assistant_id="string", | |
| 576 | ) | |
86379b44Stainless Bot2 years ago | 577 | |
| 578 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 579 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 580 | run = response.parse() | |
| 581 | assert_matches_type(Run, run, path=["response"]) | |
| 582 | | |
86379b44Stainless Bot2 years ago | 583 | @parametrize |
5429f696Stainless Bot2 years ago | 584 | async def test_streaming_response_create_overload_1(self, async_client: AsyncOpenAI) -> None: |
98d779fbStainless Bot2 years ago | 585 | async with async_client.beta.threads.runs.with_streaming_response.create( |
86379b44Stainless Bot2 years ago | 586 | "string", |
| 587 | assistant_id="string", | |
| 588 | ) as response: | |
| 589 | assert not response.is_closed | |
| 590 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 591 | | |
| 592 | run = await response.parse() | |
| 593 | assert_matches_type(Run, run, path=["response"]) | |
| 594 | | |
| 595 | assert cast(Any, response.is_closed) is True | |
| 596 | | |
023a4e66Stainless Bot2 years ago | 597 | @parametrize |
5429f696Stainless Bot2 years ago | 598 | async def test_path_params_create_overload_1(self, async_client: AsyncOpenAI) -> None: |
023a4e66Stainless Bot2 years ago | 599 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
98d779fbStainless Bot2 years ago | 600 | await async_client.beta.threads.runs.with_raw_response.create( |
023a4e66Stainless Bot2 years ago | 601 | "", |
| 602 | assistant_id="string", | |
| 603 | ) | |
| 604 | | |
5429f696Stainless Bot2 years ago | 605 | @parametrize |
| 606 | async def test_method_create_overload_2(self, async_client: AsyncOpenAI) -> None: | |
| 607 | run_stream = await async_client.beta.threads.runs.create( | |
| 608 | "string", | |
| 609 | assistant_id="string", | |
| 610 | stream=True, | |
| 611 | ) | |
| 612 | await run_stream.response.aclose() | |
| 613 | | |
| 614 | @parametrize | |
| 615 | async def test_method_create_with_all_params_overload_2(self, async_client: AsyncOpenAI) -> None: | |
| 616 | run_stream = await async_client.beta.threads.runs.create( | |
| 617 | "string", | |
| 618 | assistant_id="string", | |
| 619 | stream=True, | |
5d3111a8Stainless Bot1 years ago | 620 | include=["step_details.tool_calls[*].file_search.results[*].content"], |
| 621 | additional_instructions="additional_instructions", | |
e2d65bf7Stainless Bot2 years ago | 622 | additional_messages=[ |
| 623 | { | |
79a0b401Stainless Bot2 years ago | 624 | "content": "string", |
092a8df7Stainless Bot1 years ago | 625 | "role": "user", |
5b20698dStainless Bot2 years ago | 626 | "attachments": [ |
| 627 | { | |
dd19d4f9Stainless Bot1 years ago | 628 | "file_id": "file_id", |
| 629 | "tools": [{"type": "code_interpreter"}], | |
| 630 | } | |
5b20698dStainless Bot2 years ago | 631 | ], |
fdd52476stainless-app[bot]1 years ago | 632 | "metadata": {"foo": "string"}, |
dd19d4f9Stainless Bot1 years ago | 633 | } |
e2d65bf7Stainless Bot2 years ago | 634 | ], |
5429f696Stainless Bot2 years ago | 635 | instructions="string", |
f5247e30Stainless Bot2 years ago | 636 | max_completion_tokens=256, |
| 637 | max_prompt_tokens=256, | |
fdd52476stainless-app[bot]1 years ago | 638 | metadata={"foo": "string"}, |
bf1ca86cRobert Craigie1 years ago | 639 | model="gpt-4o", |
7399ffc8Stainless Bot2 years ago | 640 | parallel_tool_calls=True, |
8640fd83stainless-app[bot]1 years ago | 641 | reasoning_effort="low", |
bf1ca86cRobert Craigie1 years ago | 642 | response_format="auto", |
27a4626aStainless Bot2 years ago | 643 | temperature=1, |
f5247e30Stainless Bot2 years ago | 644 | tool_choice="none", |
dd19d4f9Stainless Bot1 years ago | 645 | tools=[{"type": "code_interpreter"}], |
5b20698dStainless Bot2 years ago | 646 | top_p=1, |
f5247e30Stainless Bot2 years ago | 647 | truncation_strategy={ |
| 648 | "type": "auto", | |
| 649 | "last_messages": 1, | |
| 650 | }, | |
5429f696Stainless Bot2 years ago | 651 | ) |
| 652 | await run_stream.response.aclose() | |
| 653 | | |
| 654 | @parametrize | |
| 655 | async def test_raw_response_create_overload_2(self, async_client: AsyncOpenAI) -> None: | |
| 656 | response = await async_client.beta.threads.runs.with_raw_response.create( | |
| 657 | "string", | |
| 658 | assistant_id="string", | |
| 659 | stream=True, | |
| 660 | ) | |
| 661 | | |
| 662 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 663 | stream = response.parse() | |
| 664 | await stream.close() | |
| 665 | | |
| 666 | @parametrize | |
| 667 | async def test_streaming_response_create_overload_2(self, async_client: AsyncOpenAI) -> None: | |
| 668 | async with async_client.beta.threads.runs.with_streaming_response.create( | |
| 669 | "string", | |
| 670 | assistant_id="string", | |
| 671 | stream=True, | |
| 672 | ) as response: | |
| 673 | assert not response.is_closed | |
| 674 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 675 | | |
| 676 | stream = await response.parse() | |
| 677 | await stream.close() | |
| 678 | | |
| 679 | assert cast(Any, response.is_closed) is True | |
| 680 | | |
| 681 | @parametrize | |
| 682 | async def test_path_params_create_overload_2(self, async_client: AsyncOpenAI) -> None: | |
| 683 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): | |
| 684 | await async_client.beta.threads.runs.with_raw_response.create( | |
| 685 | "", | |
| 686 | assistant_id="string", | |
| 687 | stream=True, | |
| 688 | ) | |
| 689 | | |
baa9f07fRobert Craigie2 years ago | 690 | @parametrize |
98d779fbStainless Bot2 years ago | 691 | async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None: |
| 692 | run = await async_client.beta.threads.runs.retrieve( | |
baa9f07fRobert Craigie2 years ago | 693 | "string", |
| 694 | thread_id="string", | |
| 695 | ) | |
| 696 | assert_matches_type(Run, run, path=["response"]) | |
| 697 | | |
| 698 | @parametrize | |
98d779fbStainless Bot2 years ago | 699 | async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None: |
| 700 | response = await async_client.beta.threads.runs.with_raw_response.retrieve( | |
baa9f07fRobert Craigie2 years ago | 701 | "string", |
| 702 | thread_id="string", | |
| 703 | ) | |
86379b44Stainless Bot2 years ago | 704 | |
| 705 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 706 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 707 | run = response.parse() | |
| 708 | assert_matches_type(Run, run, path=["response"]) | |
| 709 | | |
86379b44Stainless Bot2 years ago | 710 | @parametrize |
98d779fbStainless Bot2 years ago | 711 | async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None: |
| 712 | async with async_client.beta.threads.runs.with_streaming_response.retrieve( | |
86379b44Stainless Bot2 years ago | 713 | "string", |
| 714 | thread_id="string", | |
| 715 | ) as response: | |
| 716 | assert not response.is_closed | |
| 717 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 718 | | |
| 719 | run = await response.parse() | |
| 720 | assert_matches_type(Run, run, path=["response"]) | |
| 721 | | |
| 722 | assert cast(Any, response.is_closed) is True | |
| 723 | | |
023a4e66Stainless Bot2 years ago | 724 | @parametrize |
98d779fbStainless Bot2 years ago | 725 | async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None: |
023a4e66Stainless Bot2 years ago | 726 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
98d779fbStainless Bot2 years ago | 727 | await async_client.beta.threads.runs.with_raw_response.retrieve( |
023a4e66Stainless Bot2 years ago | 728 | "string", |
| 729 | thread_id="", | |
| 730 | ) | |
| 731 | | |
| 732 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): | |
98d779fbStainless Bot2 years ago | 733 | await async_client.beta.threads.runs.with_raw_response.retrieve( |
023a4e66Stainless Bot2 years ago | 734 | "", |
| 735 | thread_id="string", | |
| 736 | ) | |
| 737 | | |
baa9f07fRobert Craigie2 years ago | 738 | @parametrize |
98d779fbStainless Bot2 years ago | 739 | async def test_method_update(self, async_client: AsyncOpenAI) -> None: |
| 740 | run = await async_client.beta.threads.runs.update( | |
baa9f07fRobert Craigie2 years ago | 741 | "string", |
| 742 | thread_id="string", | |
| 743 | ) | |
| 744 | assert_matches_type(Run, run, path=["response"]) | |
| 745 | | |
| 746 | @parametrize | |
98d779fbStainless Bot2 years ago | 747 | async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None: |
| 748 | run = await async_client.beta.threads.runs.update( | |
fdd52476stainless-app[bot]1 years ago | 749 | run_id="run_id", |
| 750 | thread_id="thread_id", | |
| 751 | metadata={"foo": "string"}, | |
baa9f07fRobert Craigie2 years ago | 752 | ) |
| 753 | assert_matches_type(Run, run, path=["response"]) | |
| 754 | | |
| 755 | @parametrize | |
98d779fbStainless Bot2 years ago | 756 | async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None: |
| 757 | response = await async_client.beta.threads.runs.with_raw_response.update( | |
baa9f07fRobert Craigie2 years ago | 758 | "string", |
| 759 | thread_id="string", | |
| 760 | ) | |
86379b44Stainless Bot2 years ago | 761 | |
| 762 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 763 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 764 | run = response.parse() | |
| 765 | assert_matches_type(Run, run, path=["response"]) | |
| 766 | | |
86379b44Stainless Bot2 years ago | 767 | @parametrize |
98d779fbStainless Bot2 years ago | 768 | async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None: |
| 769 | async with async_client.beta.threads.runs.with_streaming_response.update( | |
86379b44Stainless Bot2 years ago | 770 | "string", |
| 771 | thread_id="string", | |
| 772 | ) as response: | |
| 773 | assert not response.is_closed | |
| 774 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 775 | | |
| 776 | run = await response.parse() | |
| 777 | assert_matches_type(Run, run, path=["response"]) | |
| 778 | | |
| 779 | assert cast(Any, response.is_closed) is True | |
| 780 | | |
023a4e66Stainless Bot2 years ago | 781 | @parametrize |
98d779fbStainless Bot2 years ago | 782 | async def test_path_params_update(self, async_client: AsyncOpenAI) -> None: |
023a4e66Stainless Bot2 years ago | 783 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
98d779fbStainless Bot2 years ago | 784 | await async_client.beta.threads.runs.with_raw_response.update( |
023a4e66Stainless Bot2 years ago | 785 | "string", |
| 786 | thread_id="", | |
| 787 | ) | |
| 788 | | |
| 789 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): | |
98d779fbStainless Bot2 years ago | 790 | await async_client.beta.threads.runs.with_raw_response.update( |
023a4e66Stainless Bot2 years ago | 791 | "", |
| 792 | thread_id="string", | |
| 793 | ) | |
| 794 | | |
baa9f07fRobert Craigie2 years ago | 795 | @parametrize |
98d779fbStainless Bot2 years ago | 796 | async def test_method_list(self, async_client: AsyncOpenAI) -> None: |
| 797 | run = await async_client.beta.threads.runs.list( | |
baa9f07fRobert Craigie2 years ago | 798 | "string", |
| 799 | ) | |
| 800 | assert_matches_type(AsyncCursorPage[Run], run, path=["response"]) | |
| 801 | | |
| 802 | @parametrize | |
98d779fbStainless Bot2 years ago | 803 | async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None: |
| 804 | run = await async_client.beta.threads.runs.list( | |
baa9f07fRobert Craigie2 years ago | 805 | "string", |
| 806 | after="string", | |
| 807 | before="string", | |
| 808 | limit=0, | |
| 809 | order="asc", | |
| 810 | ) | |
| 811 | assert_matches_type(AsyncCursorPage[Run], run, path=["response"]) | |
| 812 | | |
| 813 | @parametrize | |
98d779fbStainless Bot2 years ago | 814 | async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None: |
| 815 | response = await async_client.beta.threads.runs.with_raw_response.list( | |
baa9f07fRobert Craigie2 years ago | 816 | "string", |
| 817 | ) | |
86379b44Stainless Bot2 years ago | 818 | |
| 819 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 820 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 821 | run = response.parse() | |
| 822 | assert_matches_type(AsyncCursorPage[Run], run, path=["response"]) | |
| 823 | | |
86379b44Stainless Bot2 years ago | 824 | @parametrize |
98d779fbStainless Bot2 years ago | 825 | async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None: |
| 826 | async with async_client.beta.threads.runs.with_streaming_response.list( | |
86379b44Stainless Bot2 years ago | 827 | "string", |
| 828 | ) as response: | |
| 829 | assert not response.is_closed | |
| 830 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 831 | | |
| 832 | run = await response.parse() | |
| 833 | assert_matches_type(AsyncCursorPage[Run], run, path=["response"]) | |
| 834 | | |
| 835 | assert cast(Any, response.is_closed) is True | |
| 836 | | |
023a4e66Stainless Bot2 years ago | 837 | @parametrize |
98d779fbStainless Bot2 years ago | 838 | async def test_path_params_list(self, async_client: AsyncOpenAI) -> None: |
023a4e66Stainless Bot2 years ago | 839 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
98d779fbStainless Bot2 years ago | 840 | await async_client.beta.threads.runs.with_raw_response.list( |
023a4e66Stainless Bot2 years ago | 841 | "", |
| 842 | ) | |
| 843 | | |
baa9f07fRobert Craigie2 years ago | 844 | @parametrize |
98d779fbStainless Bot2 years ago | 845 | async def test_method_cancel(self, async_client: AsyncOpenAI) -> None: |
| 846 | run = await async_client.beta.threads.runs.cancel( | |
baa9f07fRobert Craigie2 years ago | 847 | "string", |
| 848 | thread_id="string", | |
| 849 | ) | |
| 850 | assert_matches_type(Run, run, path=["response"]) | |
| 851 | | |
| 852 | @parametrize | |
98d779fbStainless Bot2 years ago | 853 | async def test_raw_response_cancel(self, async_client: AsyncOpenAI) -> None: |
| 854 | response = await async_client.beta.threads.runs.with_raw_response.cancel( | |
baa9f07fRobert Craigie2 years ago | 855 | "string", |
| 856 | thread_id="string", | |
| 857 | ) | |
86379b44Stainless Bot2 years ago | 858 | |
| 859 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 860 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 861 | run = response.parse() | |
| 862 | assert_matches_type(Run, run, path=["response"]) | |
| 863 | | |
86379b44Stainless Bot2 years ago | 864 | @parametrize |
98d779fbStainless Bot2 years ago | 865 | async def test_streaming_response_cancel(self, async_client: AsyncOpenAI) -> None: |
| 866 | async with async_client.beta.threads.runs.with_streaming_response.cancel( | |
86379b44Stainless Bot2 years ago | 867 | "string", |
| 868 | thread_id="string", | |
| 869 | ) as response: | |
| 870 | assert not response.is_closed | |
| 871 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 872 | | |
| 873 | run = await response.parse() | |
| 874 | assert_matches_type(Run, run, path=["response"]) | |
| 875 | | |
| 876 | assert cast(Any, response.is_closed) is True | |
| 877 | | |
023a4e66Stainless Bot2 years ago | 878 | @parametrize |
98d779fbStainless Bot2 years ago | 879 | async def test_path_params_cancel(self, async_client: AsyncOpenAI) -> None: |
023a4e66Stainless Bot2 years ago | 880 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
98d779fbStainless Bot2 years ago | 881 | await async_client.beta.threads.runs.with_raw_response.cancel( |
023a4e66Stainless Bot2 years ago | 882 | "string", |
| 883 | thread_id="", | |
| 884 | ) | |
| 885 | | |
| 886 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): | |
98d779fbStainless Bot2 years ago | 887 | await async_client.beta.threads.runs.with_raw_response.cancel( |
023a4e66Stainless Bot2 years ago | 888 | "", |
| 889 | thread_id="string", | |
| 890 | ) | |
| 891 | | |
baa9f07fRobert Craigie2 years ago | 892 | @parametrize |
5429f696Stainless Bot2 years ago | 893 | async def test_method_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None: |
98d779fbStainless Bot2 years ago | 894 | run = await async_client.beta.threads.runs.submit_tool_outputs( |
dd19d4f9Stainless Bot1 years ago | 895 | run_id="run_id", |
| 896 | thread_id="thread_id", | |
| 897 | tool_outputs=[{}], | |
baa9f07fRobert Craigie2 years ago | 898 | ) |
| 899 | assert_matches_type(Run, run, path=["response"]) | |
| 900 | | |
| 901 | @parametrize | |
5429f696Stainless Bot2 years ago | 902 | async def test_method_submit_tool_outputs_with_all_params_overload_1(self, async_client: AsyncOpenAI) -> None: |
| 903 | run = await async_client.beta.threads.runs.submit_tool_outputs( | |
| 904 | "string", | |
| 905 | thread_id="string", | |
| 906 | tool_outputs=[ | |
| 907 | { | |
092a8df7Stainless Bot1 years ago | 908 | "output": "output", |
| 909 | "tool_call_id": "tool_call_id", | |
dd19d4f9Stainless Bot1 years ago | 910 | } |
5429f696Stainless Bot2 years ago | 911 | ], |
| 912 | stream=False, | |
| 913 | ) | |
| 914 | assert_matches_type(Run, run, path=["response"]) | |
| 915 | | |
| 916 | @parametrize | |
| 917 | async def test_raw_response_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None: | |
98d779fbStainless Bot2 years ago | 918 | response = await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs( |
dd19d4f9Stainless Bot1 years ago | 919 | run_id="run_id", |
| 920 | thread_id="thread_id", | |
| 921 | tool_outputs=[{}], | |
baa9f07fRobert Craigie2 years ago | 922 | ) |
86379b44Stainless Bot2 years ago | 923 | |
| 924 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 925 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 926 | run = response.parse() | |
| 927 | assert_matches_type(Run, run, path=["response"]) | |
86379b44Stainless Bot2 years ago | 928 | |
| 929 | @parametrize | |
5429f696Stainless Bot2 years ago | 930 | async def test_streaming_response_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None: |
98d779fbStainless Bot2 years ago | 931 | async with async_client.beta.threads.runs.with_streaming_response.submit_tool_outputs( |
dd19d4f9Stainless Bot1 years ago | 932 | run_id="run_id", |
| 933 | thread_id="thread_id", | |
| 934 | tool_outputs=[{}], | |
86379b44Stainless Bot2 years ago | 935 | ) as response: |
| 936 | assert not response.is_closed | |
| 937 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 938 | | |
| 939 | run = await response.parse() | |
| 940 | assert_matches_type(Run, run, path=["response"]) | |
| 941 | | |
| 942 | assert cast(Any, response.is_closed) is True | |
023a4e66Stainless Bot2 years ago | 943 | |
| 944 | @parametrize | |
5429f696Stainless Bot2 years ago | 945 | async def test_path_params_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None: |
| 946 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): | |
| 947 | await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs( | |
| 948 | "string", | |
| 949 | thread_id="", | |
dd19d4f9Stainless Bot1 years ago | 950 | tool_outputs=[{}], |
5429f696Stainless Bot2 years ago | 951 | ) |
| 952 | | |
| 953 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): | |
| 954 | await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs( | |
dd19d4f9Stainless Bot1 years ago | 955 | run_id="", |
| 956 | thread_id="thread_id", | |
| 957 | tool_outputs=[{}], | |
5429f696Stainless Bot2 years ago | 958 | ) |
| 959 | | |
| 960 | @parametrize | |
| 961 | async def test_method_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None: | |
| 962 | run_stream = await async_client.beta.threads.runs.submit_tool_outputs( | |
| 963 | "string", | |
| 964 | thread_id="string", | |
| 965 | stream=True, | |
dd19d4f9Stainless Bot1 years ago | 966 | tool_outputs=[{}], |
5429f696Stainless Bot2 years ago | 967 | ) |
| 968 | await run_stream.response.aclose() | |
| 969 | | |
| 970 | @parametrize | |
| 971 | async def test_raw_response_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None: | |
| 972 | response = await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs( | |
| 973 | "string", | |
| 974 | thread_id="string", | |
| 975 | stream=True, | |
dd19d4f9Stainless Bot1 years ago | 976 | tool_outputs=[{}], |
5429f696Stainless Bot2 years ago | 977 | ) |
| 978 | | |
| 979 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 980 | stream = response.parse() | |
| 981 | await stream.close() | |
| 982 | | |
| 983 | @parametrize | |
| 984 | async def test_streaming_response_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None: | |
| 985 | async with async_client.beta.threads.runs.with_streaming_response.submit_tool_outputs( | |
| 986 | "string", | |
| 987 | thread_id="string", | |
| 988 | stream=True, | |
dd19d4f9Stainless Bot1 years ago | 989 | tool_outputs=[{}], |
5429f696Stainless Bot2 years ago | 990 | ) as response: |
| 991 | assert not response.is_closed | |
| 992 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 993 | | |
| 994 | stream = await response.parse() | |
| 995 | await stream.close() | |
| 996 | | |
| 997 | assert cast(Any, response.is_closed) is True | |
| 998 | | |
| 999 | @parametrize | |
| 1000 | async def test_path_params_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None: | |
023a4e66Stainless Bot2 years ago | 1001 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
98d779fbStainless Bot2 years ago | 1002 | await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs( |
023a4e66Stainless Bot2 years ago | 1003 | "string", |
| 1004 | thread_id="", | |
5429f696Stainless Bot2 years ago | 1005 | stream=True, |
dd19d4f9Stainless Bot1 years ago | 1006 | tool_outputs=[{}], |
023a4e66Stainless Bot2 years ago | 1007 | ) |
| 1008 | | |
| 1009 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): | |
98d779fbStainless Bot2 years ago | 1010 | await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs( |
023a4e66Stainless Bot2 years ago | 1011 | "", |
| 1012 | thread_id="string", | |
5429f696Stainless Bot2 years ago | 1013 | stream=True, |
dd19d4f9Stainless Bot1 years ago | 1014 | tool_outputs=[{}], |
023a4e66Stainless Bot2 years ago | 1015 | ) |