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