openai/openai-python

Public

mirrored from https://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.23.6

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

tests/api_resources/beta/threads/test_runs.py

1345lines · modeblame

5cfb125aStainless Bot2 years ago1# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
baa9f07fRobert Craigie2 years ago2
3from __future__ import annotations
4
5import os
86379b44Stainless Bot2 years ago6from typing import Any, cast
baa9f07fRobert Craigie2 years ago7
8import pytest
9
10from openai import OpenAI, AsyncOpenAI
11from tests.utils import assert_matches_type
12from openai.pagination import SyncCursorPage, AsyncCursorPage
e4a9553eStainless Bot2 years ago13from openai.types.beta.threads.run import Run
baa9f07fRobert Craigie2 years ago14
595f3b36Stainless Bot2 years ago15# pyright: reportDeprecated=false
16
baa9f07fRobert Craigie2 years ago17base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
18
19
20class TestRuns:
98d779fbStainless Bot2 years ago21parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
baa9f07fRobert Craigie2 years ago22
23@parametrize
5429f696Stainless Bot2 years ago24def test_method_create_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago25run = client.beta.threads.runs.create(
26"string",
27assistant_id="string",
28)
29assert_matches_type(Run, run, path=["response"])
30
31@parametrize
5429f696Stainless Bot2 years ago32def test_method_create_with_all_params_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago33run = client.beta.threads.runs.create(
34"string",
35assistant_id="string",
53bca49eStainless Bot2 years ago36additional_instructions="string",
e2d65bf7Stainless Bot2 years ago37additional_messages=[
38{
39"role": "user",
40"content": "x",
5b20698dStainless Bot2 years ago41"attachments": [
42{
43"file_id": "string",
f73996b7Stainless Bot2 years ago44"tools": [
45{"type": "code_interpreter"},
46{"type": "code_interpreter"},
47{"type": "code_interpreter"},
48],
5b20698dStainless Bot2 years ago49},
50{
51"file_id": "string",
f73996b7Stainless Bot2 years ago52"tools": [
53{"type": "code_interpreter"},
54{"type": "code_interpreter"},
55{"type": "code_interpreter"},
56],
5b20698dStainless Bot2 years ago57},
58{
59"file_id": "string",
f73996b7Stainless Bot2 years ago60"tools": [
61{"type": "code_interpreter"},
62{"type": "code_interpreter"},
63{"type": "code_interpreter"},
64],
5b20698dStainless Bot2 years ago65},
66],
e2d65bf7Stainless Bot2 years ago67"metadata": {},
68},
69{
70"role": "user",
71"content": "x",
5b20698dStainless Bot2 years ago72"attachments": [
73{
74"file_id": "string",
f73996b7Stainless Bot2 years ago75"tools": [
76{"type": "code_interpreter"},
77{"type": "code_interpreter"},
78{"type": "code_interpreter"},
79],
5b20698dStainless Bot2 years ago80},
81{
82"file_id": "string",
f73996b7Stainless Bot2 years ago83"tools": [
84{"type": "code_interpreter"},
85{"type": "code_interpreter"},
86{"type": "code_interpreter"},
87],
5b20698dStainless Bot2 years ago88},
89{
90"file_id": "string",
f73996b7Stainless Bot2 years ago91"tools": [
92{"type": "code_interpreter"},
93{"type": "code_interpreter"},
94{"type": "code_interpreter"},
95],
5b20698dStainless Bot2 years ago96},
97],
e2d65bf7Stainless Bot2 years ago98"metadata": {},
99},
100{
101"role": "user",
102"content": "x",
5b20698dStainless Bot2 years ago103"attachments": [
104{
105"file_id": "string",
f73996b7Stainless Bot2 years ago106"tools": [
107{"type": "code_interpreter"},
108{"type": "code_interpreter"},
109{"type": "code_interpreter"},
110],
5b20698dStainless Bot2 years ago111},
112{
113"file_id": "string",
f73996b7Stainless Bot2 years ago114"tools": [
115{"type": "code_interpreter"},
116{"type": "code_interpreter"},
117{"type": "code_interpreter"},
118],
5b20698dStainless Bot2 years ago119},
120{
121"file_id": "string",
f73996b7Stainless Bot2 years ago122"tools": [
123{"type": "code_interpreter"},
124{"type": "code_interpreter"},
125{"type": "code_interpreter"},
126],
5b20698dStainless Bot2 years ago127},
128],
e2d65bf7Stainless Bot2 years ago129"metadata": {},
130},
131],
baa9f07fRobert Craigie2 years ago132instructions="string",
f5247e30Stainless Bot2 years ago133max_completion_tokens=256,
134max_prompt_tokens=256,
baa9f07fRobert Craigie2 years ago135metadata={},
f5247e30Stainless Bot2 years ago136model="gpt-4-turbo",
137response_format="none",
5429f696Stainless Bot2 years ago138stream=False,
27a4626aStainless Bot2 years ago139temperature=1,
f5247e30Stainless Bot2 years ago140tool_choice="none",
baa9f07fRobert Craigie2 years ago141tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago142top_p=1,
f5247e30Stainless Bot2 years ago143truncation_strategy={
144"type": "auto",
145"last_messages": 1,
146},
baa9f07fRobert Craigie2 years ago147)
148assert_matches_type(Run, run, path=["response"])
149
150@parametrize
5429f696Stainless Bot2 years ago151def test_raw_response_create_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago152response = client.beta.threads.runs.with_raw_response.create(
153"string",
154assistant_id="string",
155)
86379b44Stainless Bot2 years ago156
157assert response.is_closed is True
baa9f07fRobert Craigie2 years ago158assert response.http_request.headers.get("X-Stainless-Lang") == "python"
159run = response.parse()
160assert_matches_type(Run, run, path=["response"])
161
86379b44Stainless Bot2 years ago162@parametrize
5429f696Stainless Bot2 years ago163def test_streaming_response_create_overload_1(self, client: OpenAI) -> None:
86379b44Stainless Bot2 years ago164with client.beta.threads.runs.with_streaming_response.create(
165"string",
166assistant_id="string",
167) as response:
168assert not response.is_closed
169assert response.http_request.headers.get("X-Stainless-Lang") == "python"
170
171run = response.parse()
172assert_matches_type(Run, run, path=["response"])
173
174assert cast(Any, response.is_closed) is True
175
023a4e66Stainless Bot2 years ago176@parametrize
5429f696Stainless Bot2 years ago177def test_path_params_create_overload_1(self, client: OpenAI) -> None:
023a4e66Stainless Bot2 years ago178with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
179client.beta.threads.runs.with_raw_response.create(
180"",
181assistant_id="string",
182)
183
5429f696Stainless Bot2 years ago184@parametrize
185def test_method_create_overload_2(self, client: OpenAI) -> None:
186run_stream = client.beta.threads.runs.create(
187"string",
188assistant_id="string",
189stream=True,
190)
191run_stream.response.close()
192
193@parametrize
194def test_method_create_with_all_params_overload_2(self, client: OpenAI) -> None:
195run_stream = client.beta.threads.runs.create(
196"string",
197assistant_id="string",
198stream=True,
199additional_instructions="string",
e2d65bf7Stainless Bot2 years ago200additional_messages=[
201{
202"role": "user",
203"content": "x",
5b20698dStainless Bot2 years ago204"attachments": [
205{
206"file_id": "string",
f73996b7Stainless Bot2 years ago207"tools": [
208{"type": "code_interpreter"},
209{"type": "code_interpreter"},
210{"type": "code_interpreter"},
211],
5b20698dStainless Bot2 years ago212},
213{
214"file_id": "string",
f73996b7Stainless Bot2 years ago215"tools": [
216{"type": "code_interpreter"},
217{"type": "code_interpreter"},
218{"type": "code_interpreter"},
219],
5b20698dStainless Bot2 years ago220},
221{
222"file_id": "string",
f73996b7Stainless Bot2 years ago223"tools": [
224{"type": "code_interpreter"},
225{"type": "code_interpreter"},
226{"type": "code_interpreter"},
227],
5b20698dStainless Bot2 years ago228},
229],
e2d65bf7Stainless Bot2 years ago230"metadata": {},
231},
232{
233"role": "user",
234"content": "x",
5b20698dStainless Bot2 years ago235"attachments": [
236{
237"file_id": "string",
f73996b7Stainless Bot2 years ago238"tools": [
239{"type": "code_interpreter"},
240{"type": "code_interpreter"},
241{"type": "code_interpreter"},
242],
5b20698dStainless Bot2 years ago243},
244{
245"file_id": "string",
f73996b7Stainless Bot2 years ago246"tools": [
247{"type": "code_interpreter"},
248{"type": "code_interpreter"},
249{"type": "code_interpreter"},
250],
5b20698dStainless Bot2 years ago251},
252{
253"file_id": "string",
f73996b7Stainless Bot2 years ago254"tools": [
255{"type": "code_interpreter"},
256{"type": "code_interpreter"},
257{"type": "code_interpreter"},
258],
5b20698dStainless Bot2 years ago259},
260],
e2d65bf7Stainless Bot2 years ago261"metadata": {},
262},
263{
264"role": "user",
265"content": "x",
5b20698dStainless Bot2 years ago266"attachments": [
267{
268"file_id": "string",
f73996b7Stainless Bot2 years ago269"tools": [
270{"type": "code_interpreter"},
271{"type": "code_interpreter"},
272{"type": "code_interpreter"},
273],
5b20698dStainless Bot2 years ago274},
275{
276"file_id": "string",
f73996b7Stainless Bot2 years ago277"tools": [
278{"type": "code_interpreter"},
279{"type": "code_interpreter"},
280{"type": "code_interpreter"},
281],
5b20698dStainless Bot2 years ago282},
283{
284"file_id": "string",
f73996b7Stainless Bot2 years ago285"tools": [
286{"type": "code_interpreter"},
287{"type": "code_interpreter"},
288{"type": "code_interpreter"},
289],
5b20698dStainless Bot2 years ago290},
291],
e2d65bf7Stainless Bot2 years ago292"metadata": {},
293},
294],
5429f696Stainless Bot2 years ago295instructions="string",
f5247e30Stainless Bot2 years ago296max_completion_tokens=256,
297max_prompt_tokens=256,
5429f696Stainless Bot2 years ago298metadata={},
f5247e30Stainless Bot2 years ago299model="gpt-4-turbo",
300response_format="none",
27a4626aStainless Bot2 years ago301temperature=1,
f5247e30Stainless Bot2 years ago302tool_choice="none",
5429f696Stainless Bot2 years ago303tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago304top_p=1,
f5247e30Stainless Bot2 years ago305truncation_strategy={
306"type": "auto",
307"last_messages": 1,
308},
5429f696Stainless Bot2 years ago309)
310run_stream.response.close()
311
312@parametrize
313def test_raw_response_create_overload_2(self, client: OpenAI) -> None:
314response = client.beta.threads.runs.with_raw_response.create(
315"string",
316assistant_id="string",
317stream=True,
318)
319
320assert response.http_request.headers.get("X-Stainless-Lang") == "python"
321stream = response.parse()
322stream.close()
323
324@parametrize
325def test_streaming_response_create_overload_2(self, client: OpenAI) -> None:
326with client.beta.threads.runs.with_streaming_response.create(
327"string",
328assistant_id="string",
329stream=True,
330) as response:
331assert not response.is_closed
332assert response.http_request.headers.get("X-Stainless-Lang") == "python"
333
334stream = response.parse()
335stream.close()
336
337assert cast(Any, response.is_closed) is True
338
339@parametrize
340def test_path_params_create_overload_2(self, client: OpenAI) -> None:
341with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
342client.beta.threads.runs.with_raw_response.create(
343"",
344assistant_id="string",
345stream=True,
346)
347
baa9f07fRobert Craigie2 years ago348@parametrize
349def test_method_retrieve(self, client: OpenAI) -> None:
350run = client.beta.threads.runs.retrieve(
351"string",
352thread_id="string",
353)
354assert_matches_type(Run, run, path=["response"])
355
356@parametrize
357def test_raw_response_retrieve(self, client: OpenAI) -> None:
358response = client.beta.threads.runs.with_raw_response.retrieve(
359"string",
360thread_id="string",
361)
86379b44Stainless Bot2 years ago362
363assert response.is_closed is True
baa9f07fRobert Craigie2 years ago364assert response.http_request.headers.get("X-Stainless-Lang") == "python"
365run = response.parse()
366assert_matches_type(Run, run, path=["response"])
367
86379b44Stainless Bot2 years ago368@parametrize
369def test_streaming_response_retrieve(self, client: OpenAI) -> None:
370with client.beta.threads.runs.with_streaming_response.retrieve(
371"string",
372thread_id="string",
373) as response:
374assert not response.is_closed
375assert response.http_request.headers.get("X-Stainless-Lang") == "python"
376
377run = response.parse()
378assert_matches_type(Run, run, path=["response"])
379
380assert cast(Any, response.is_closed) is True
381
023a4e66Stainless Bot2 years ago382@parametrize
383def test_path_params_retrieve(self, client: OpenAI) -> None:
384with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
385client.beta.threads.runs.with_raw_response.retrieve(
386"string",
387thread_id="",
388)
389
390with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
391client.beta.threads.runs.with_raw_response.retrieve(
392"",
393thread_id="string",
394)
395
baa9f07fRobert Craigie2 years ago396@parametrize
397def test_method_update(self, client: OpenAI) -> None:
398run = client.beta.threads.runs.update(
399"string",
400thread_id="string",
401)
402assert_matches_type(Run, run, path=["response"])
403
404@parametrize
405def test_method_update_with_all_params(self, client: OpenAI) -> None:
406run = client.beta.threads.runs.update(
407"string",
408thread_id="string",
409metadata={},
410)
411assert_matches_type(Run, run, path=["response"])
412
413@parametrize
414def test_raw_response_update(self, client: OpenAI) -> None:
415response = client.beta.threads.runs.with_raw_response.update(
416"string",
417thread_id="string",
418)
86379b44Stainless Bot2 years ago419
420assert response.is_closed is True
baa9f07fRobert Craigie2 years ago421assert response.http_request.headers.get("X-Stainless-Lang") == "python"
422run = response.parse()
423assert_matches_type(Run, run, path=["response"])
424
86379b44Stainless Bot2 years ago425@parametrize
426def test_streaming_response_update(self, client: OpenAI) -> None:
427with client.beta.threads.runs.with_streaming_response.update(
428"string",
429thread_id="string",
430) as response:
431assert not response.is_closed
432assert response.http_request.headers.get("X-Stainless-Lang") == "python"
433
434run = response.parse()
435assert_matches_type(Run, run, path=["response"])
436
437assert cast(Any, response.is_closed) is True
438
023a4e66Stainless Bot2 years ago439@parametrize
440def test_path_params_update(self, client: OpenAI) -> None:
441with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
442client.beta.threads.runs.with_raw_response.update(
443"string",
444thread_id="",
445)
446
447with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
448client.beta.threads.runs.with_raw_response.update(
449"",
450thread_id="string",
451)
452
baa9f07fRobert Craigie2 years ago453@parametrize
454def test_method_list(self, client: OpenAI) -> None:
455run = client.beta.threads.runs.list(
456"string",
457)
458assert_matches_type(SyncCursorPage[Run], run, path=["response"])
459
460@parametrize
461def test_method_list_with_all_params(self, client: OpenAI) -> None:
462run = client.beta.threads.runs.list(
463"string",
464after="string",
465before="string",
466limit=0,
467order="asc",
468)
469assert_matches_type(SyncCursorPage[Run], run, path=["response"])
470
471@parametrize
472def test_raw_response_list(self, client: OpenAI) -> None:
473response = client.beta.threads.runs.with_raw_response.list(
474"string",
475)
86379b44Stainless Bot2 years ago476
477assert response.is_closed is True
baa9f07fRobert Craigie2 years ago478assert response.http_request.headers.get("X-Stainless-Lang") == "python"
479run = response.parse()
480assert_matches_type(SyncCursorPage[Run], run, path=["response"])
481
86379b44Stainless Bot2 years ago482@parametrize
483def test_streaming_response_list(self, client: OpenAI) -> None:
484with client.beta.threads.runs.with_streaming_response.list(
485"string",
486) as response:
487assert not response.is_closed
488assert response.http_request.headers.get("X-Stainless-Lang") == "python"
489
490run = response.parse()
491assert_matches_type(SyncCursorPage[Run], run, path=["response"])
492
493assert cast(Any, response.is_closed) is True
494
023a4e66Stainless Bot2 years ago495@parametrize
496def test_path_params_list(self, client: OpenAI) -> None:
497with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
498client.beta.threads.runs.with_raw_response.list(
499"",
500)
501
baa9f07fRobert Craigie2 years ago502@parametrize
503def test_method_cancel(self, client: OpenAI) -> None:
504run = client.beta.threads.runs.cancel(
505"string",
506thread_id="string",
507)
508assert_matches_type(Run, run, path=["response"])
509
510@parametrize
511def test_raw_response_cancel(self, client: OpenAI) -> None:
512response = client.beta.threads.runs.with_raw_response.cancel(
513"string",
514thread_id="string",
515)
86379b44Stainless Bot2 years ago516
517assert response.is_closed is True
baa9f07fRobert Craigie2 years ago518assert response.http_request.headers.get("X-Stainless-Lang") == "python"
519run = response.parse()
520assert_matches_type(Run, run, path=["response"])
521
86379b44Stainless Bot2 years ago522@parametrize
523def test_streaming_response_cancel(self, client: OpenAI) -> None:
524with client.beta.threads.runs.with_streaming_response.cancel(
525"string",
526thread_id="string",
527) as response:
528assert not response.is_closed
529assert response.http_request.headers.get("X-Stainless-Lang") == "python"
530
531run = response.parse()
532assert_matches_type(Run, run, path=["response"])
533
534assert cast(Any, response.is_closed) is True
535
023a4e66Stainless Bot2 years ago536@parametrize
537def test_path_params_cancel(self, client: OpenAI) -> None:
538with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
539client.beta.threads.runs.with_raw_response.cancel(
540"string",
541thread_id="",
542)
543
544with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
545client.beta.threads.runs.with_raw_response.cancel(
546"",
547thread_id="string",
548)
549
baa9f07fRobert Craigie2 years ago550@parametrize
5429f696Stainless Bot2 years ago551def test_method_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago552run = client.beta.threads.runs.submit_tool_outputs(
553"string",
554thread_id="string",
555tool_outputs=[{}, {}, {}],
556)
557assert_matches_type(Run, run, path=["response"])
558
559@parametrize
5429f696Stainless Bot2 years ago560def test_method_submit_tool_outputs_with_all_params_overload_1(self, client: OpenAI) -> None:
561run = client.beta.threads.runs.submit_tool_outputs(
562"string",
563thread_id="string",
564tool_outputs=[
565{
566"tool_call_id": "string",
567"output": "string",
568},
569{
570"tool_call_id": "string",
571"output": "string",
572},
573{
574"tool_call_id": "string",
575"output": "string",
576},
577],
578stream=False,
579)
580assert_matches_type(Run, run, path=["response"])
581
582@parametrize
583def test_raw_response_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago584response = client.beta.threads.runs.with_raw_response.submit_tool_outputs(
585"string",
586thread_id="string",
587tool_outputs=[{}, {}, {}],
588)
86379b44Stainless Bot2 years ago589
590assert response.is_closed is True
baa9f07fRobert Craigie2 years ago591assert response.http_request.headers.get("X-Stainless-Lang") == "python"
592run = response.parse()
593assert_matches_type(Run, run, path=["response"])
594
86379b44Stainless Bot2 years ago595@parametrize
5429f696Stainless Bot2 years ago596def test_streaming_response_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
86379b44Stainless Bot2 years ago597with client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
598"string",
599thread_id="string",
600tool_outputs=[{}, {}, {}],
601) as response:
602assert not response.is_closed
603assert response.http_request.headers.get("X-Stainless-Lang") == "python"
604
605run = response.parse()
606assert_matches_type(Run, run, path=["response"])
607
608assert cast(Any, response.is_closed) is True
609
023a4e66Stainless Bot2 years ago610@parametrize
5429f696Stainless Bot2 years ago611def test_path_params_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
612with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
613client.beta.threads.runs.with_raw_response.submit_tool_outputs(
614"string",
615thread_id="",
616tool_outputs=[{}, {}, {}],
617)
618
619with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
620client.beta.threads.runs.with_raw_response.submit_tool_outputs(
621"",
622thread_id="string",
623tool_outputs=[{}, {}, {}],
624)
625
626@parametrize
627def test_method_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
628run_stream = client.beta.threads.runs.submit_tool_outputs(
629"string",
630thread_id="string",
631stream=True,
632tool_outputs=[{}, {}, {}],
633)
634run_stream.response.close()
635
636@parametrize
637def test_raw_response_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
638response = client.beta.threads.runs.with_raw_response.submit_tool_outputs(
639"string",
640thread_id="string",
641stream=True,
642tool_outputs=[{}, {}, {}],
643)
644
645assert response.http_request.headers.get("X-Stainless-Lang") == "python"
646stream = response.parse()
647stream.close()
648
649@parametrize
650def test_streaming_response_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
651with client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
652"string",
653thread_id="string",
654stream=True,
655tool_outputs=[{}, {}, {}],
656) as response:
657assert not response.is_closed
658assert response.http_request.headers.get("X-Stainless-Lang") == "python"
659
660stream = response.parse()
661stream.close()
662
663assert cast(Any, response.is_closed) is True
664
665@parametrize
666def test_path_params_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
023a4e66Stainless Bot2 years ago667with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
668client.beta.threads.runs.with_raw_response.submit_tool_outputs(
669"string",
670thread_id="",
5429f696Stainless Bot2 years ago671stream=True,
023a4e66Stainless Bot2 years ago672tool_outputs=[{}, {}, {}],
673)
674
675with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
676client.beta.threads.runs.with_raw_response.submit_tool_outputs(
677"",
678thread_id="string",
5429f696Stainless Bot2 years ago679stream=True,
023a4e66Stainless Bot2 years ago680tool_outputs=[{}, {}, {}],
681)
682
baa9f07fRobert Craigie2 years ago683
684class TestAsyncRuns:
98d779fbStainless Bot2 years ago685parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
baa9f07fRobert Craigie2 years ago686
687@parametrize
5429f696Stainless Bot2 years ago688async def test_method_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago689run = await async_client.beta.threads.runs.create(
baa9f07fRobert Craigie2 years ago690"string",
691assistant_id="string",
692)
693assert_matches_type(Run, run, path=["response"])
694
695@parametrize
5429f696Stainless Bot2 years ago696async def test_method_create_with_all_params_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago697run = await async_client.beta.threads.runs.create(
baa9f07fRobert Craigie2 years ago698"string",
699assistant_id="string",
53bca49eStainless Bot2 years ago700additional_instructions="string",
e2d65bf7Stainless Bot2 years ago701additional_messages=[
702{
703"role": "user",
704"content": "x",
5b20698dStainless Bot2 years ago705"attachments": [
706{
707"file_id": "string",
f73996b7Stainless Bot2 years ago708"tools": [
709{"type": "code_interpreter"},
710{"type": "code_interpreter"},
711{"type": "code_interpreter"},
712],
5b20698dStainless Bot2 years ago713},
714{
715"file_id": "string",
f73996b7Stainless Bot2 years ago716"tools": [
717{"type": "code_interpreter"},
718{"type": "code_interpreter"},
719{"type": "code_interpreter"},
720],
5b20698dStainless Bot2 years ago721},
722{
723"file_id": "string",
f73996b7Stainless Bot2 years ago724"tools": [
725{"type": "code_interpreter"},
726{"type": "code_interpreter"},
727{"type": "code_interpreter"},
728],
5b20698dStainless Bot2 years ago729},
730],
e2d65bf7Stainless Bot2 years ago731"metadata": {},
732},
733{
734"role": "user",
735"content": "x",
5b20698dStainless Bot2 years ago736"attachments": [
737{
738"file_id": "string",
f73996b7Stainless Bot2 years ago739"tools": [
740{"type": "code_interpreter"},
741{"type": "code_interpreter"},
742{"type": "code_interpreter"},
743],
5b20698dStainless Bot2 years ago744},
745{
746"file_id": "string",
f73996b7Stainless Bot2 years ago747"tools": [
748{"type": "code_interpreter"},
749{"type": "code_interpreter"},
750{"type": "code_interpreter"},
751],
5b20698dStainless Bot2 years ago752},
753{
754"file_id": "string",
f73996b7Stainless Bot2 years ago755"tools": [
756{"type": "code_interpreter"},
757{"type": "code_interpreter"},
758{"type": "code_interpreter"},
759],
5b20698dStainless Bot2 years ago760},
761],
e2d65bf7Stainless Bot2 years ago762"metadata": {},
763},
764{
765"role": "user",
766"content": "x",
5b20698dStainless Bot2 years ago767"attachments": [
768{
769"file_id": "string",
f73996b7Stainless Bot2 years ago770"tools": [
771{"type": "code_interpreter"},
772{"type": "code_interpreter"},
773{"type": "code_interpreter"},
774],
5b20698dStainless Bot2 years ago775},
776{
777"file_id": "string",
f73996b7Stainless Bot2 years ago778"tools": [
779{"type": "code_interpreter"},
780{"type": "code_interpreter"},
781{"type": "code_interpreter"},
782],
5b20698dStainless Bot2 years ago783},
784{
785"file_id": "string",
f73996b7Stainless Bot2 years ago786"tools": [
787{"type": "code_interpreter"},
788{"type": "code_interpreter"},
789{"type": "code_interpreter"},
790],
5b20698dStainless Bot2 years ago791},
792],
e2d65bf7Stainless Bot2 years ago793"metadata": {},
794},
795],
baa9f07fRobert Craigie2 years ago796instructions="string",
f5247e30Stainless Bot2 years ago797max_completion_tokens=256,
798max_prompt_tokens=256,
baa9f07fRobert Craigie2 years ago799metadata={},
f5247e30Stainless Bot2 years ago800model="gpt-4-turbo",
801response_format="none",
5429f696Stainless Bot2 years ago802stream=False,
27a4626aStainless Bot2 years ago803temperature=1,
f5247e30Stainless Bot2 years ago804tool_choice="none",
baa9f07fRobert Craigie2 years ago805tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago806top_p=1,
f5247e30Stainless Bot2 years ago807truncation_strategy={
808"type": "auto",
809"last_messages": 1,
810},
baa9f07fRobert Craigie2 years ago811)
812assert_matches_type(Run, run, path=["response"])
813
814@parametrize
5429f696Stainless Bot2 years ago815async def test_raw_response_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago816response = await async_client.beta.threads.runs.with_raw_response.create(
baa9f07fRobert Craigie2 years ago817"string",
818assistant_id="string",
819)
86379b44Stainless Bot2 years ago820
821assert response.is_closed is True
baa9f07fRobert Craigie2 years ago822assert response.http_request.headers.get("X-Stainless-Lang") == "python"
823run = response.parse()
824assert_matches_type(Run, run, path=["response"])
825
86379b44Stainless Bot2 years ago826@parametrize
5429f696Stainless Bot2 years ago827async def test_streaming_response_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago828async with async_client.beta.threads.runs.with_streaming_response.create(
86379b44Stainless Bot2 years ago829"string",
830assistant_id="string",
831) as response:
832assert not response.is_closed
833assert response.http_request.headers.get("X-Stainless-Lang") == "python"
834
835run = await response.parse()
836assert_matches_type(Run, run, path=["response"])
837
838assert cast(Any, response.is_closed) is True
839
023a4e66Stainless Bot2 years ago840@parametrize
5429f696Stainless Bot2 years ago841async def test_path_params_create_overload_1(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago842with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago843await async_client.beta.threads.runs.with_raw_response.create(
023a4e66Stainless Bot2 years ago844"",
845assistant_id="string",
846)
847
5429f696Stainless Bot2 years ago848@parametrize
849async def test_method_create_overload_2(self, async_client: AsyncOpenAI) -> None:
850run_stream = await async_client.beta.threads.runs.create(
851"string",
852assistant_id="string",
853stream=True,
854)
855await run_stream.response.aclose()
856
857@parametrize
858async def test_method_create_with_all_params_overload_2(self, async_client: AsyncOpenAI) -> None:
859run_stream = await async_client.beta.threads.runs.create(
860"string",
861assistant_id="string",
862stream=True,
863additional_instructions="string",
e2d65bf7Stainless Bot2 years ago864additional_messages=[
865{
866"role": "user",
867"content": "x",
5b20698dStainless Bot2 years ago868"attachments": [
869{
870"file_id": "string",
f73996b7Stainless Bot2 years ago871"tools": [
872{"type": "code_interpreter"},
873{"type": "code_interpreter"},
874{"type": "code_interpreter"},
875],
5b20698dStainless Bot2 years ago876},
877{
878"file_id": "string",
f73996b7Stainless Bot2 years ago879"tools": [
880{"type": "code_interpreter"},
881{"type": "code_interpreter"},
882{"type": "code_interpreter"},
883],
5b20698dStainless Bot2 years ago884},
885{
886"file_id": "string",
f73996b7Stainless Bot2 years ago887"tools": [
888{"type": "code_interpreter"},
889{"type": "code_interpreter"},
890{"type": "code_interpreter"},
891],
5b20698dStainless Bot2 years ago892},
893],
e2d65bf7Stainless Bot2 years ago894"metadata": {},
895},
896{
897"role": "user",
898"content": "x",
5b20698dStainless Bot2 years ago899"attachments": [
900{
901"file_id": "string",
f73996b7Stainless Bot2 years ago902"tools": [
903{"type": "code_interpreter"},
904{"type": "code_interpreter"},
905{"type": "code_interpreter"},
906],
5b20698dStainless Bot2 years ago907},
908{
909"file_id": "string",
f73996b7Stainless Bot2 years ago910"tools": [
911{"type": "code_interpreter"},
912{"type": "code_interpreter"},
913{"type": "code_interpreter"},
914],
5b20698dStainless Bot2 years ago915},
916{
917"file_id": "string",
f73996b7Stainless Bot2 years ago918"tools": [
919{"type": "code_interpreter"},
920{"type": "code_interpreter"},
921{"type": "code_interpreter"},
922],
5b20698dStainless Bot2 years ago923},
924],
e2d65bf7Stainless Bot2 years ago925"metadata": {},
926},
927{
928"role": "user",
929"content": "x",
5b20698dStainless Bot2 years ago930"attachments": [
931{
932"file_id": "string",
f73996b7Stainless Bot2 years ago933"tools": [
934{"type": "code_interpreter"},
935{"type": "code_interpreter"},
936{"type": "code_interpreter"},
937],
5b20698dStainless Bot2 years ago938},
939{
940"file_id": "string",
f73996b7Stainless Bot2 years ago941"tools": [
942{"type": "code_interpreter"},
943{"type": "code_interpreter"},
944{"type": "code_interpreter"},
945],
5b20698dStainless Bot2 years ago946},
947{
948"file_id": "string",
f73996b7Stainless Bot2 years ago949"tools": [
950{"type": "code_interpreter"},
951{"type": "code_interpreter"},
952{"type": "code_interpreter"},
953],
5b20698dStainless Bot2 years ago954},
955],
e2d65bf7Stainless Bot2 years ago956"metadata": {},
957},
958],
5429f696Stainless Bot2 years ago959instructions="string",
f5247e30Stainless Bot2 years ago960max_completion_tokens=256,
961max_prompt_tokens=256,
5429f696Stainless Bot2 years ago962metadata={},
f5247e30Stainless Bot2 years ago963model="gpt-4-turbo",
964response_format="none",
27a4626aStainless Bot2 years ago965temperature=1,
f5247e30Stainless Bot2 years ago966tool_choice="none",
5429f696Stainless Bot2 years ago967tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago968top_p=1,
f5247e30Stainless Bot2 years ago969truncation_strategy={
970"type": "auto",
971"last_messages": 1,
972},
5429f696Stainless Bot2 years ago973)
974await run_stream.response.aclose()
975
976@parametrize
977async def test_raw_response_create_overload_2(self, async_client: AsyncOpenAI) -> None:
978response = await async_client.beta.threads.runs.with_raw_response.create(
979"string",
980assistant_id="string",
981stream=True,
982)
983
984assert response.http_request.headers.get("X-Stainless-Lang") == "python"
985stream = response.parse()
986await stream.close()
987
988@parametrize
989async def test_streaming_response_create_overload_2(self, async_client: AsyncOpenAI) -> None:
990async with async_client.beta.threads.runs.with_streaming_response.create(
991"string",
992assistant_id="string",
993stream=True,
994) as response:
995assert not response.is_closed
996assert response.http_request.headers.get("X-Stainless-Lang") == "python"
997
998stream = await response.parse()
999await stream.close()
1000
1001assert cast(Any, response.is_closed) is True
1002
1003@parametrize
1004async def test_path_params_create_overload_2(self, async_client: AsyncOpenAI) -> None:
1005with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
1006await async_client.beta.threads.runs.with_raw_response.create(
1007"",
1008assistant_id="string",
1009stream=True,
1010)
1011
baa9f07fRobert Craigie2 years ago1012@parametrize
98d779fbStainless Bot2 years ago1013async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None:
1014run = await async_client.beta.threads.runs.retrieve(
baa9f07fRobert Craigie2 years ago1015"string",
1016thread_id="string",
1017)
1018assert_matches_type(Run, run, path=["response"])
1019
1020@parametrize
98d779fbStainless Bot2 years ago1021async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None:
1022response = await async_client.beta.threads.runs.with_raw_response.retrieve(
baa9f07fRobert Craigie2 years ago1023"string",
1024thread_id="string",
1025)
86379b44Stainless Bot2 years ago1026
1027assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1028assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1029run = response.parse()
1030assert_matches_type(Run, run, path=["response"])
1031
86379b44Stainless Bot2 years ago1032@parametrize
98d779fbStainless Bot2 years ago1033async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None:
1034async with async_client.beta.threads.runs.with_streaming_response.retrieve(
86379b44Stainless Bot2 years ago1035"string",
1036thread_id="string",
1037) as response:
1038assert not response.is_closed
1039assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1040
1041run = await response.parse()
1042assert_matches_type(Run, run, path=["response"])
1043
1044assert cast(Any, response.is_closed) is True
1045
023a4e66Stainless Bot2 years ago1046@parametrize
98d779fbStainless Bot2 years ago1047async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1048with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1049await async_client.beta.threads.runs.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago1050"string",
1051thread_id="",
1052)
1053
1054with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1055await async_client.beta.threads.runs.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago1056"",
1057thread_id="string",
1058)
1059
baa9f07fRobert Craigie2 years ago1060@parametrize
98d779fbStainless Bot2 years ago1061async def test_method_update(self, async_client: AsyncOpenAI) -> None:
1062run = await async_client.beta.threads.runs.update(
baa9f07fRobert Craigie2 years ago1063"string",
1064thread_id="string",
1065)
1066assert_matches_type(Run, run, path=["response"])
1067
1068@parametrize
98d779fbStainless Bot2 years ago1069async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None:
1070run = await async_client.beta.threads.runs.update(
baa9f07fRobert Craigie2 years ago1071"string",
1072thread_id="string",
1073metadata={},
1074)
1075assert_matches_type(Run, run, path=["response"])
1076
1077@parametrize
98d779fbStainless Bot2 years ago1078async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None:
1079response = await async_client.beta.threads.runs.with_raw_response.update(
baa9f07fRobert Craigie2 years ago1080"string",
1081thread_id="string",
1082)
86379b44Stainless Bot2 years ago1083
1084assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1085assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1086run = response.parse()
1087assert_matches_type(Run, run, path=["response"])
1088
86379b44Stainless Bot2 years ago1089@parametrize
98d779fbStainless Bot2 years ago1090async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None:
1091async with async_client.beta.threads.runs.with_streaming_response.update(
86379b44Stainless Bot2 years ago1092"string",
1093thread_id="string",
1094) as response:
1095assert not response.is_closed
1096assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1097
1098run = await response.parse()
1099assert_matches_type(Run, run, path=["response"])
1100
1101assert cast(Any, response.is_closed) is True
1102
023a4e66Stainless Bot2 years ago1103@parametrize
98d779fbStainless Bot2 years ago1104async def test_path_params_update(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1105with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1106await async_client.beta.threads.runs.with_raw_response.update(
023a4e66Stainless Bot2 years ago1107"string",
1108thread_id="",
1109)
1110
1111with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1112await async_client.beta.threads.runs.with_raw_response.update(
023a4e66Stainless Bot2 years ago1113"",
1114thread_id="string",
1115)
1116
baa9f07fRobert Craigie2 years ago1117@parametrize
98d779fbStainless Bot2 years ago1118async def test_method_list(self, async_client: AsyncOpenAI) -> None:
1119run = await async_client.beta.threads.runs.list(
baa9f07fRobert Craigie2 years ago1120"string",
1121)
1122assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1123
1124@parametrize
98d779fbStainless Bot2 years ago1125async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None:
1126run = await async_client.beta.threads.runs.list(
baa9f07fRobert Craigie2 years ago1127"string",
1128after="string",
1129before="string",
1130limit=0,
1131order="asc",
1132)
1133assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1134
1135@parametrize
98d779fbStainless Bot2 years ago1136async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None:
1137response = await async_client.beta.threads.runs.with_raw_response.list(
baa9f07fRobert Craigie2 years ago1138"string",
1139)
86379b44Stainless Bot2 years ago1140
1141assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1142assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1143run = response.parse()
1144assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1145
86379b44Stainless Bot2 years ago1146@parametrize
98d779fbStainless Bot2 years ago1147async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None:
1148async with async_client.beta.threads.runs.with_streaming_response.list(
86379b44Stainless Bot2 years ago1149"string",
1150) as response:
1151assert not response.is_closed
1152assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1153
1154run = await response.parse()
1155assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1156
1157assert cast(Any, response.is_closed) is True
1158
023a4e66Stainless Bot2 years ago1159@parametrize
98d779fbStainless Bot2 years ago1160async def test_path_params_list(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1161with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1162await async_client.beta.threads.runs.with_raw_response.list(
023a4e66Stainless Bot2 years ago1163"",
1164)
1165
baa9f07fRobert Craigie2 years ago1166@parametrize
98d779fbStainless Bot2 years ago1167async def test_method_cancel(self, async_client: AsyncOpenAI) -> None:
1168run = await async_client.beta.threads.runs.cancel(
baa9f07fRobert Craigie2 years ago1169"string",
1170thread_id="string",
1171)
1172assert_matches_type(Run, run, path=["response"])
1173
1174@parametrize
98d779fbStainless Bot2 years ago1175async def test_raw_response_cancel(self, async_client: AsyncOpenAI) -> None:
1176response = await async_client.beta.threads.runs.with_raw_response.cancel(
baa9f07fRobert Craigie2 years ago1177"string",
1178thread_id="string",
1179)
86379b44Stainless Bot2 years ago1180
1181assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1182assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1183run = response.parse()
1184assert_matches_type(Run, run, path=["response"])
1185
86379b44Stainless Bot2 years ago1186@parametrize
98d779fbStainless Bot2 years ago1187async def test_streaming_response_cancel(self, async_client: AsyncOpenAI) -> None:
1188async with async_client.beta.threads.runs.with_streaming_response.cancel(
86379b44Stainless Bot2 years ago1189"string",
1190thread_id="string",
1191) as response:
1192assert not response.is_closed
1193assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1194
1195run = await response.parse()
1196assert_matches_type(Run, run, path=["response"])
1197
1198assert cast(Any, response.is_closed) is True
1199
023a4e66Stainless Bot2 years ago1200@parametrize
98d779fbStainless Bot2 years ago1201async def test_path_params_cancel(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1202with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1203await async_client.beta.threads.runs.with_raw_response.cancel(
023a4e66Stainless Bot2 years ago1204"string",
1205thread_id="",
1206)
1207
1208with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1209await async_client.beta.threads.runs.with_raw_response.cancel(
023a4e66Stainless Bot2 years ago1210"",
1211thread_id="string",
1212)
1213
baa9f07fRobert Craigie2 years ago1214@parametrize
5429f696Stainless Bot2 years ago1215async def test_method_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago1216run = await async_client.beta.threads.runs.submit_tool_outputs(
baa9f07fRobert Craigie2 years ago1217"string",
1218thread_id="string",
1219tool_outputs=[{}, {}, {}],
1220)
1221assert_matches_type(Run, run, path=["response"])
1222
1223@parametrize
5429f696Stainless Bot2 years ago1224async def test_method_submit_tool_outputs_with_all_params_overload_1(self, async_client: AsyncOpenAI) -> None:
1225run = await async_client.beta.threads.runs.submit_tool_outputs(
1226"string",
1227thread_id="string",
1228tool_outputs=[
1229{
1230"tool_call_id": "string",
1231"output": "string",
1232},
1233{
1234"tool_call_id": "string",
1235"output": "string",
1236},
1237{
1238"tool_call_id": "string",
1239"output": "string",
1240},
1241],
1242stream=False,
1243)
1244assert_matches_type(Run, run, path=["response"])
1245
1246@parametrize
1247async def test_raw_response_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago1248response = await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
baa9f07fRobert Craigie2 years ago1249"string",
1250thread_id="string",
1251tool_outputs=[{}, {}, {}],
1252)
86379b44Stainless Bot2 years ago1253
1254assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1255assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1256run = response.parse()
1257assert_matches_type(Run, run, path=["response"])
86379b44Stainless Bot2 years ago1258
1259@parametrize
5429f696Stainless Bot2 years ago1260async def test_streaming_response_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago1261async with async_client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
86379b44Stainless Bot2 years ago1262"string",
1263thread_id="string",
1264tool_outputs=[{}, {}, {}],
1265) as response:
1266assert not response.is_closed
1267assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1268
1269run = await response.parse()
1270assert_matches_type(Run, run, path=["response"])
1271
1272assert cast(Any, response.is_closed) is True
023a4e66Stainless Bot2 years ago1273
1274@parametrize
5429f696Stainless Bot2 years ago1275async def test_path_params_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
1276with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
1277await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
1278"string",
1279thread_id="",
1280tool_outputs=[{}, {}, {}],
1281)
1282
1283with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
1284await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
1285"",
1286thread_id="string",
1287tool_outputs=[{}, {}, {}],
1288)
1289
1290@parametrize
1291async def test_method_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
1292run_stream = await async_client.beta.threads.runs.submit_tool_outputs(
1293"string",
1294thread_id="string",
1295stream=True,
1296tool_outputs=[{}, {}, {}],
1297)
1298await run_stream.response.aclose()
1299
1300@parametrize
1301async def test_raw_response_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
1302response = await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
1303"string",
1304thread_id="string",
1305stream=True,
1306tool_outputs=[{}, {}, {}],
1307)
1308
1309assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1310stream = response.parse()
1311await stream.close()
1312
1313@parametrize
1314async def test_streaming_response_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
1315async with async_client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
1316"string",
1317thread_id="string",
1318stream=True,
1319tool_outputs=[{}, {}, {}],
1320) as response:
1321assert not response.is_closed
1322assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1323
1324stream = await response.parse()
1325await stream.close()
1326
1327assert cast(Any, response.is_closed) is True
1328
1329@parametrize
1330async def test_path_params_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1331with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1332await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
023a4e66Stainless Bot2 years ago1333"string",
1334thread_id="",
5429f696Stainless Bot2 years ago1335stream=True,
023a4e66Stainless Bot2 years ago1336tool_outputs=[{}, {}, {}],
1337)
1338
1339with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1340await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
023a4e66Stainless Bot2 years ago1341"",
1342thread_id="string",
5429f696Stainless Bot2 years ago1343stream=True,
023a4e66Stainless Bot2 years ago1344tool_outputs=[{}, {}, {}],
1345)