openai/openai-python

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.24.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api_resources/beta/threads/test_runs.py

1347lines · 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
4a0f0fa0Stainless Bot2 years ago13from openai.types.beta.threads import (
14Run,
15)
baa9f07fRobert Craigie2 years ago16
595f3b36Stainless Bot2 years ago17# pyright: reportDeprecated=false
18
baa9f07fRobert Craigie2 years ago19base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
20
21
22class TestRuns:
98d779fbStainless Bot2 years ago23parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
baa9f07fRobert Craigie2 years ago24
25@parametrize
5429f696Stainless Bot2 years ago26def test_method_create_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago27run = client.beta.threads.runs.create(
28"string",
29assistant_id="string",
30)
31assert_matches_type(Run, run, path=["response"])
32
33@parametrize
5429f696Stainless Bot2 years ago34def test_method_create_with_all_params_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago35run = client.beta.threads.runs.create(
36"string",
37assistant_id="string",
53bca49eStainless Bot2 years ago38additional_instructions="string",
e2d65bf7Stainless Bot2 years ago39additional_messages=[
40{
41"role": "user",
42"content": "x",
5b20698dStainless Bot2 years ago43"attachments": [
44{
45"file_id": "string",
f73996b7Stainless Bot2 years ago46"tools": [
47{"type": "code_interpreter"},
48{"type": "code_interpreter"},
49{"type": "code_interpreter"},
50],
5b20698dStainless Bot2 years ago51},
52{
53"file_id": "string",
f73996b7Stainless Bot2 years ago54"tools": [
55{"type": "code_interpreter"},
56{"type": "code_interpreter"},
57{"type": "code_interpreter"},
58],
5b20698dStainless Bot2 years ago59},
60{
61"file_id": "string",
f73996b7Stainless Bot2 years ago62"tools": [
63{"type": "code_interpreter"},
64{"type": "code_interpreter"},
65{"type": "code_interpreter"},
66],
5b20698dStainless Bot2 years ago67},
68],
e2d65bf7Stainless Bot2 years ago69"metadata": {},
70},
71{
72"role": "user",
73"content": "x",
5b20698dStainless Bot2 years ago74"attachments": [
75{
76"file_id": "string",
f73996b7Stainless Bot2 years ago77"tools": [
78{"type": "code_interpreter"},
79{"type": "code_interpreter"},
80{"type": "code_interpreter"},
81],
5b20698dStainless Bot2 years ago82},
83{
84"file_id": "string",
f73996b7Stainless Bot2 years ago85"tools": [
86{"type": "code_interpreter"},
87{"type": "code_interpreter"},
88{"type": "code_interpreter"},
89],
5b20698dStainless Bot2 years ago90},
91{
92"file_id": "string",
f73996b7Stainless Bot2 years ago93"tools": [
94{"type": "code_interpreter"},
95{"type": "code_interpreter"},
96{"type": "code_interpreter"},
97],
5b20698dStainless Bot2 years ago98},
99],
e2d65bf7Stainless Bot2 years ago100"metadata": {},
101},
102{
103"role": "user",
104"content": "x",
5b20698dStainless Bot2 years ago105"attachments": [
106{
107"file_id": "string",
f73996b7Stainless Bot2 years ago108"tools": [
109{"type": "code_interpreter"},
110{"type": "code_interpreter"},
111{"type": "code_interpreter"},
112],
5b20698dStainless Bot2 years ago113},
114{
115"file_id": "string",
f73996b7Stainless Bot2 years ago116"tools": [
117{"type": "code_interpreter"},
118{"type": "code_interpreter"},
119{"type": "code_interpreter"},
120],
5b20698dStainless Bot2 years ago121},
122{
123"file_id": "string",
f73996b7Stainless Bot2 years ago124"tools": [
125{"type": "code_interpreter"},
126{"type": "code_interpreter"},
127{"type": "code_interpreter"},
128],
5b20698dStainless Bot2 years ago129},
130],
e2d65bf7Stainless Bot2 years ago131"metadata": {},
132},
133],
baa9f07fRobert Craigie2 years ago134instructions="string",
f5247e30Stainless Bot2 years ago135max_completion_tokens=256,
136max_prompt_tokens=256,
baa9f07fRobert Craigie2 years ago137metadata={},
f5247e30Stainless Bot2 years ago138model="gpt-4-turbo",
139response_format="none",
5429f696Stainless Bot2 years ago140stream=False,
27a4626aStainless Bot2 years ago141temperature=1,
f5247e30Stainless Bot2 years ago142tool_choice="none",
baa9f07fRobert Craigie2 years ago143tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago144top_p=1,
f5247e30Stainless Bot2 years ago145truncation_strategy={
146"type": "auto",
147"last_messages": 1,
148},
baa9f07fRobert Craigie2 years ago149)
150assert_matches_type(Run, run, path=["response"])
151
152@parametrize
5429f696Stainless Bot2 years ago153def test_raw_response_create_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago154response = client.beta.threads.runs.with_raw_response.create(
155"string",
156assistant_id="string",
157)
86379b44Stainless Bot2 years ago158
159assert response.is_closed is True
baa9f07fRobert Craigie2 years ago160assert response.http_request.headers.get("X-Stainless-Lang") == "python"
161run = response.parse()
162assert_matches_type(Run, run, path=["response"])
163
86379b44Stainless Bot2 years ago164@parametrize
5429f696Stainless Bot2 years ago165def test_streaming_response_create_overload_1(self, client: OpenAI) -> None:
86379b44Stainless Bot2 years ago166with client.beta.threads.runs.with_streaming_response.create(
167"string",
168assistant_id="string",
169) as response:
170assert not response.is_closed
171assert response.http_request.headers.get("X-Stainless-Lang") == "python"
172
173run = response.parse()
174assert_matches_type(Run, run, path=["response"])
175
176assert cast(Any, response.is_closed) is True
177
023a4e66Stainless Bot2 years ago178@parametrize
5429f696Stainless Bot2 years ago179def test_path_params_create_overload_1(self, client: OpenAI) -> None:
023a4e66Stainless Bot2 years ago180with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
181client.beta.threads.runs.with_raw_response.create(
182"",
183assistant_id="string",
184)
185
5429f696Stainless Bot2 years ago186@parametrize
187def test_method_create_overload_2(self, client: OpenAI) -> None:
188run_stream = client.beta.threads.runs.create(
189"string",
190assistant_id="string",
191stream=True,
192)
193run_stream.response.close()
194
195@parametrize
196def test_method_create_with_all_params_overload_2(self, client: OpenAI) -> None:
197run_stream = client.beta.threads.runs.create(
198"string",
199assistant_id="string",
200stream=True,
201additional_instructions="string",
e2d65bf7Stainless Bot2 years ago202additional_messages=[
203{
204"role": "user",
205"content": "x",
5b20698dStainless Bot2 years ago206"attachments": [
207{
208"file_id": "string",
f73996b7Stainless Bot2 years ago209"tools": [
210{"type": "code_interpreter"},
211{"type": "code_interpreter"},
212{"type": "code_interpreter"},
213],
5b20698dStainless Bot2 years ago214},
215{
216"file_id": "string",
f73996b7Stainless Bot2 years ago217"tools": [
218{"type": "code_interpreter"},
219{"type": "code_interpreter"},
220{"type": "code_interpreter"},
221],
5b20698dStainless Bot2 years ago222},
223{
224"file_id": "string",
f73996b7Stainless Bot2 years ago225"tools": [
226{"type": "code_interpreter"},
227{"type": "code_interpreter"},
228{"type": "code_interpreter"},
229],
5b20698dStainless Bot2 years ago230},
231],
e2d65bf7Stainless Bot2 years ago232"metadata": {},
233},
234{
235"role": "user",
236"content": "x",
5b20698dStainless Bot2 years ago237"attachments": [
238{
239"file_id": "string",
f73996b7Stainless Bot2 years ago240"tools": [
241{"type": "code_interpreter"},
242{"type": "code_interpreter"},
243{"type": "code_interpreter"},
244],
5b20698dStainless Bot2 years ago245},
246{
247"file_id": "string",
f73996b7Stainless Bot2 years ago248"tools": [
249{"type": "code_interpreter"},
250{"type": "code_interpreter"},
251{"type": "code_interpreter"},
252],
5b20698dStainless Bot2 years ago253},
254{
255"file_id": "string",
f73996b7Stainless Bot2 years ago256"tools": [
257{"type": "code_interpreter"},
258{"type": "code_interpreter"},
259{"type": "code_interpreter"},
260],
5b20698dStainless Bot2 years ago261},
262],
e2d65bf7Stainless Bot2 years ago263"metadata": {},
264},
265{
266"role": "user",
267"content": "x",
5b20698dStainless Bot2 years ago268"attachments": [
269{
270"file_id": "string",
f73996b7Stainless Bot2 years ago271"tools": [
272{"type": "code_interpreter"},
273{"type": "code_interpreter"},
274{"type": "code_interpreter"},
275],
5b20698dStainless Bot2 years ago276},
277{
278"file_id": "string",
f73996b7Stainless Bot2 years ago279"tools": [
280{"type": "code_interpreter"},
281{"type": "code_interpreter"},
282{"type": "code_interpreter"},
283],
5b20698dStainless Bot2 years ago284},
285{
286"file_id": "string",
f73996b7Stainless Bot2 years ago287"tools": [
288{"type": "code_interpreter"},
289{"type": "code_interpreter"},
290{"type": "code_interpreter"},
291],
5b20698dStainless Bot2 years ago292},
293],
e2d65bf7Stainless Bot2 years ago294"metadata": {},
295},
296],
5429f696Stainless Bot2 years ago297instructions="string",
f5247e30Stainless Bot2 years ago298max_completion_tokens=256,
299max_prompt_tokens=256,
5429f696Stainless Bot2 years ago300metadata={},
f5247e30Stainless Bot2 years ago301model="gpt-4-turbo",
302response_format="none",
27a4626aStainless Bot2 years ago303temperature=1,
f5247e30Stainless Bot2 years ago304tool_choice="none",
5429f696Stainless Bot2 years ago305tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago306top_p=1,
f5247e30Stainless Bot2 years ago307truncation_strategy={
308"type": "auto",
309"last_messages": 1,
310},
5429f696Stainless Bot2 years ago311)
312run_stream.response.close()
313
314@parametrize
315def test_raw_response_create_overload_2(self, client: OpenAI) -> None:
316response = client.beta.threads.runs.with_raw_response.create(
317"string",
318assistant_id="string",
319stream=True,
320)
321
322assert response.http_request.headers.get("X-Stainless-Lang") == "python"
323stream = response.parse()
324stream.close()
325
326@parametrize
327def test_streaming_response_create_overload_2(self, client: OpenAI) -> None:
328with client.beta.threads.runs.with_streaming_response.create(
329"string",
330assistant_id="string",
331stream=True,
332) as response:
333assert not response.is_closed
334assert response.http_request.headers.get("X-Stainless-Lang") == "python"
335
336stream = response.parse()
337stream.close()
338
339assert cast(Any, response.is_closed) is True
340
341@parametrize
342def test_path_params_create_overload_2(self, client: OpenAI) -> None:
343with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
344client.beta.threads.runs.with_raw_response.create(
345"",
346assistant_id="string",
347stream=True,
348)
349
baa9f07fRobert Craigie2 years ago350@parametrize
351def test_method_retrieve(self, client: OpenAI) -> None:
352run = client.beta.threads.runs.retrieve(
353"string",
354thread_id="string",
355)
356assert_matches_type(Run, run, path=["response"])
357
358@parametrize
359def test_raw_response_retrieve(self, client: OpenAI) -> None:
360response = client.beta.threads.runs.with_raw_response.retrieve(
361"string",
362thread_id="string",
363)
86379b44Stainless Bot2 years ago364
365assert response.is_closed is True
baa9f07fRobert Craigie2 years ago366assert response.http_request.headers.get("X-Stainless-Lang") == "python"
367run = response.parse()
368assert_matches_type(Run, run, path=["response"])
369
86379b44Stainless Bot2 years ago370@parametrize
371def test_streaming_response_retrieve(self, client: OpenAI) -> None:
372with client.beta.threads.runs.with_streaming_response.retrieve(
373"string",
374thread_id="string",
375) as response:
376assert not response.is_closed
377assert response.http_request.headers.get("X-Stainless-Lang") == "python"
378
379run = response.parse()
380assert_matches_type(Run, run, path=["response"])
381
382assert cast(Any, response.is_closed) is True
383
023a4e66Stainless Bot2 years ago384@parametrize
385def test_path_params_retrieve(self, client: OpenAI) -> None:
386with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
387client.beta.threads.runs.with_raw_response.retrieve(
388"string",
389thread_id="",
390)
391
392with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
393client.beta.threads.runs.with_raw_response.retrieve(
394"",
395thread_id="string",
396)
397
baa9f07fRobert Craigie2 years ago398@parametrize
399def test_method_update(self, client: OpenAI) -> None:
400run = client.beta.threads.runs.update(
401"string",
402thread_id="string",
403)
404assert_matches_type(Run, run, path=["response"])
405
406@parametrize
407def test_method_update_with_all_params(self, client: OpenAI) -> None:
408run = client.beta.threads.runs.update(
409"string",
410thread_id="string",
411metadata={},
412)
413assert_matches_type(Run, run, path=["response"])
414
415@parametrize
416def test_raw_response_update(self, client: OpenAI) -> None:
417response = client.beta.threads.runs.with_raw_response.update(
418"string",
419thread_id="string",
420)
86379b44Stainless Bot2 years ago421
422assert response.is_closed is True
baa9f07fRobert Craigie2 years ago423assert response.http_request.headers.get("X-Stainless-Lang") == "python"
424run = response.parse()
425assert_matches_type(Run, run, path=["response"])
426
86379b44Stainless Bot2 years ago427@parametrize
428def test_streaming_response_update(self, client: OpenAI) -> None:
429with client.beta.threads.runs.with_streaming_response.update(
430"string",
431thread_id="string",
432) as response:
433assert not response.is_closed
434assert response.http_request.headers.get("X-Stainless-Lang") == "python"
435
436run = response.parse()
437assert_matches_type(Run, run, path=["response"])
438
439assert cast(Any, response.is_closed) is True
440
023a4e66Stainless Bot2 years ago441@parametrize
442def test_path_params_update(self, client: OpenAI) -> None:
443with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
444client.beta.threads.runs.with_raw_response.update(
445"string",
446thread_id="",
447)
448
449with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
450client.beta.threads.runs.with_raw_response.update(
451"",
452thread_id="string",
453)
454
baa9f07fRobert Craigie2 years ago455@parametrize
456def test_method_list(self, client: OpenAI) -> None:
457run = client.beta.threads.runs.list(
458"string",
459)
460assert_matches_type(SyncCursorPage[Run], run, path=["response"])
461
462@parametrize
463def test_method_list_with_all_params(self, client: OpenAI) -> None:
464run = client.beta.threads.runs.list(
465"string",
466after="string",
467before="string",
468limit=0,
469order="asc",
470)
471assert_matches_type(SyncCursorPage[Run], run, path=["response"])
472
473@parametrize
474def test_raw_response_list(self, client: OpenAI) -> None:
475response = client.beta.threads.runs.with_raw_response.list(
476"string",
477)
86379b44Stainless Bot2 years ago478
479assert response.is_closed is True
baa9f07fRobert Craigie2 years ago480assert response.http_request.headers.get("X-Stainless-Lang") == "python"
481run = response.parse()
482assert_matches_type(SyncCursorPage[Run], run, path=["response"])
483
86379b44Stainless Bot2 years ago484@parametrize
485def test_streaming_response_list(self, client: OpenAI) -> None:
486with client.beta.threads.runs.with_streaming_response.list(
487"string",
488) as response:
489assert not response.is_closed
490assert response.http_request.headers.get("X-Stainless-Lang") == "python"
491
492run = response.parse()
493assert_matches_type(SyncCursorPage[Run], run, path=["response"])
494
495assert cast(Any, response.is_closed) is True
496
023a4e66Stainless Bot2 years ago497@parametrize
498def test_path_params_list(self, client: OpenAI) -> None:
499with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
500client.beta.threads.runs.with_raw_response.list(
501"",
502)
503
baa9f07fRobert Craigie2 years ago504@parametrize
505def test_method_cancel(self, client: OpenAI) -> None:
506run = client.beta.threads.runs.cancel(
507"string",
508thread_id="string",
509)
510assert_matches_type(Run, run, path=["response"])
511
512@parametrize
513def test_raw_response_cancel(self, client: OpenAI) -> None:
514response = client.beta.threads.runs.with_raw_response.cancel(
515"string",
516thread_id="string",
517)
86379b44Stainless Bot2 years ago518
519assert response.is_closed is True
baa9f07fRobert Craigie2 years ago520assert response.http_request.headers.get("X-Stainless-Lang") == "python"
521run = response.parse()
522assert_matches_type(Run, run, path=["response"])
523
86379b44Stainless Bot2 years ago524@parametrize
525def test_streaming_response_cancel(self, client: OpenAI) -> None:
526with client.beta.threads.runs.with_streaming_response.cancel(
527"string",
528thread_id="string",
529) as response:
530assert not response.is_closed
531assert response.http_request.headers.get("X-Stainless-Lang") == "python"
532
533run = response.parse()
534assert_matches_type(Run, run, path=["response"])
535
536assert cast(Any, response.is_closed) is True
537
023a4e66Stainless Bot2 years ago538@parametrize
539def test_path_params_cancel(self, client: OpenAI) -> None:
540with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
541client.beta.threads.runs.with_raw_response.cancel(
542"string",
543thread_id="",
544)
545
546with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
547client.beta.threads.runs.with_raw_response.cancel(
548"",
549thread_id="string",
550)
551
baa9f07fRobert Craigie2 years ago552@parametrize
5429f696Stainless Bot2 years ago553def test_method_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago554run = client.beta.threads.runs.submit_tool_outputs(
555"string",
556thread_id="string",
557tool_outputs=[{}, {}, {}],
558)
559assert_matches_type(Run, run, path=["response"])
560
561@parametrize
5429f696Stainless Bot2 years ago562def test_method_submit_tool_outputs_with_all_params_overload_1(self, client: OpenAI) -> None:
563run = client.beta.threads.runs.submit_tool_outputs(
564"string",
565thread_id="string",
566tool_outputs=[
567{
568"tool_call_id": "string",
569"output": "string",
570},
571{
572"tool_call_id": "string",
573"output": "string",
574},
575{
576"tool_call_id": "string",
577"output": "string",
578},
579],
580stream=False,
581)
582assert_matches_type(Run, run, path=["response"])
583
584@parametrize
585def test_raw_response_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago586response = client.beta.threads.runs.with_raw_response.submit_tool_outputs(
587"string",
588thread_id="string",
589tool_outputs=[{}, {}, {}],
590)
86379b44Stainless Bot2 years ago591
592assert response.is_closed is True
baa9f07fRobert Craigie2 years ago593assert response.http_request.headers.get("X-Stainless-Lang") == "python"
594run = response.parse()
595assert_matches_type(Run, run, path=["response"])
596
86379b44Stainless Bot2 years ago597@parametrize
5429f696Stainless Bot2 years ago598def test_streaming_response_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
86379b44Stainless Bot2 years ago599with client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
600"string",
601thread_id="string",
602tool_outputs=[{}, {}, {}],
603) as response:
604assert not response.is_closed
605assert response.http_request.headers.get("X-Stainless-Lang") == "python"
606
607run = response.parse()
608assert_matches_type(Run, run, path=["response"])
609
610assert cast(Any, response.is_closed) is True
611
023a4e66Stainless Bot2 years ago612@parametrize
5429f696Stainless Bot2 years ago613def test_path_params_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
614with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
615client.beta.threads.runs.with_raw_response.submit_tool_outputs(
616"string",
617thread_id="",
618tool_outputs=[{}, {}, {}],
619)
620
621with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
622client.beta.threads.runs.with_raw_response.submit_tool_outputs(
623"",
624thread_id="string",
625tool_outputs=[{}, {}, {}],
626)
627
628@parametrize
629def test_method_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
630run_stream = client.beta.threads.runs.submit_tool_outputs(
631"string",
632thread_id="string",
633stream=True,
634tool_outputs=[{}, {}, {}],
635)
636run_stream.response.close()
637
638@parametrize
639def test_raw_response_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
640response = client.beta.threads.runs.with_raw_response.submit_tool_outputs(
641"string",
642thread_id="string",
643stream=True,
644tool_outputs=[{}, {}, {}],
645)
646
647assert response.http_request.headers.get("X-Stainless-Lang") == "python"
648stream = response.parse()
649stream.close()
650
651@parametrize
652def test_streaming_response_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
653with client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
654"string",
655thread_id="string",
656stream=True,
657tool_outputs=[{}, {}, {}],
658) as response:
659assert not response.is_closed
660assert response.http_request.headers.get("X-Stainless-Lang") == "python"
661
662stream = response.parse()
663stream.close()
664
665assert cast(Any, response.is_closed) is True
666
667@parametrize
668def test_path_params_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
023a4e66Stainless Bot2 years ago669with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
670client.beta.threads.runs.with_raw_response.submit_tool_outputs(
671"string",
672thread_id="",
5429f696Stainless Bot2 years ago673stream=True,
023a4e66Stainless Bot2 years ago674tool_outputs=[{}, {}, {}],
675)
676
677with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
678client.beta.threads.runs.with_raw_response.submit_tool_outputs(
679"",
680thread_id="string",
5429f696Stainless Bot2 years ago681stream=True,
023a4e66Stainless Bot2 years ago682tool_outputs=[{}, {}, {}],
683)
684
baa9f07fRobert Craigie2 years ago685
686class TestAsyncRuns:
98d779fbStainless Bot2 years ago687parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
baa9f07fRobert Craigie2 years ago688
689@parametrize
5429f696Stainless Bot2 years ago690async def test_method_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago691run = await async_client.beta.threads.runs.create(
baa9f07fRobert Craigie2 years ago692"string",
693assistant_id="string",
694)
695assert_matches_type(Run, run, path=["response"])
696
697@parametrize
5429f696Stainless Bot2 years ago698async def test_method_create_with_all_params_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago699run = await async_client.beta.threads.runs.create(
baa9f07fRobert Craigie2 years ago700"string",
701assistant_id="string",
53bca49eStainless Bot2 years ago702additional_instructions="string",
e2d65bf7Stainless Bot2 years ago703additional_messages=[
704{
705"role": "user",
706"content": "x",
5b20698dStainless Bot2 years ago707"attachments": [
708{
709"file_id": "string",
f73996b7Stainless Bot2 years ago710"tools": [
711{"type": "code_interpreter"},
712{"type": "code_interpreter"},
713{"type": "code_interpreter"},
714],
5b20698dStainless Bot2 years ago715},
716{
717"file_id": "string",
f73996b7Stainless Bot2 years ago718"tools": [
719{"type": "code_interpreter"},
720{"type": "code_interpreter"},
721{"type": "code_interpreter"},
722],
5b20698dStainless Bot2 years ago723},
724{
725"file_id": "string",
f73996b7Stainless Bot2 years ago726"tools": [
727{"type": "code_interpreter"},
728{"type": "code_interpreter"},
729{"type": "code_interpreter"},
730],
5b20698dStainless Bot2 years ago731},
732],
e2d65bf7Stainless Bot2 years ago733"metadata": {},
734},
735{
736"role": "user",
737"content": "x",
5b20698dStainless Bot2 years ago738"attachments": [
739{
740"file_id": "string",
f73996b7Stainless Bot2 years ago741"tools": [
742{"type": "code_interpreter"},
743{"type": "code_interpreter"},
744{"type": "code_interpreter"},
745],
5b20698dStainless Bot2 years ago746},
747{
748"file_id": "string",
f73996b7Stainless Bot2 years ago749"tools": [
750{"type": "code_interpreter"},
751{"type": "code_interpreter"},
752{"type": "code_interpreter"},
753],
5b20698dStainless Bot2 years ago754},
755{
756"file_id": "string",
f73996b7Stainless Bot2 years ago757"tools": [
758{"type": "code_interpreter"},
759{"type": "code_interpreter"},
760{"type": "code_interpreter"},
761],
5b20698dStainless Bot2 years ago762},
763],
e2d65bf7Stainless Bot2 years ago764"metadata": {},
765},
766{
767"role": "user",
768"content": "x",
5b20698dStainless Bot2 years ago769"attachments": [
770{
771"file_id": "string",
f73996b7Stainless Bot2 years ago772"tools": [
773{"type": "code_interpreter"},
774{"type": "code_interpreter"},
775{"type": "code_interpreter"},
776],
5b20698dStainless Bot2 years ago777},
778{
779"file_id": "string",
f73996b7Stainless Bot2 years ago780"tools": [
781{"type": "code_interpreter"},
782{"type": "code_interpreter"},
783{"type": "code_interpreter"},
784],
5b20698dStainless Bot2 years ago785},
786{
787"file_id": "string",
f73996b7Stainless Bot2 years ago788"tools": [
789{"type": "code_interpreter"},
790{"type": "code_interpreter"},
791{"type": "code_interpreter"},
792],
5b20698dStainless Bot2 years ago793},
794],
e2d65bf7Stainless Bot2 years ago795"metadata": {},
796},
797],
baa9f07fRobert Craigie2 years ago798instructions="string",
f5247e30Stainless Bot2 years ago799max_completion_tokens=256,
800max_prompt_tokens=256,
baa9f07fRobert Craigie2 years ago801metadata={},
f5247e30Stainless Bot2 years ago802model="gpt-4-turbo",
803response_format="none",
5429f696Stainless Bot2 years ago804stream=False,
27a4626aStainless Bot2 years ago805temperature=1,
f5247e30Stainless Bot2 years ago806tool_choice="none",
baa9f07fRobert Craigie2 years ago807tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago808top_p=1,
f5247e30Stainless Bot2 years ago809truncation_strategy={
810"type": "auto",
811"last_messages": 1,
812},
baa9f07fRobert Craigie2 years ago813)
814assert_matches_type(Run, run, path=["response"])
815
816@parametrize
5429f696Stainless Bot2 years ago817async def test_raw_response_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago818response = await async_client.beta.threads.runs.with_raw_response.create(
baa9f07fRobert Craigie2 years ago819"string",
820assistant_id="string",
821)
86379b44Stainless Bot2 years ago822
823assert response.is_closed is True
baa9f07fRobert Craigie2 years ago824assert response.http_request.headers.get("X-Stainless-Lang") == "python"
825run = response.parse()
826assert_matches_type(Run, run, path=["response"])
827
86379b44Stainless Bot2 years ago828@parametrize
5429f696Stainless Bot2 years ago829async def test_streaming_response_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago830async with async_client.beta.threads.runs.with_streaming_response.create(
86379b44Stainless Bot2 years ago831"string",
832assistant_id="string",
833) as response:
834assert not response.is_closed
835assert response.http_request.headers.get("X-Stainless-Lang") == "python"
836
837run = await response.parse()
838assert_matches_type(Run, run, path=["response"])
839
840assert cast(Any, response.is_closed) is True
841
023a4e66Stainless Bot2 years ago842@parametrize
5429f696Stainless Bot2 years ago843async def test_path_params_create_overload_1(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago844with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago845await async_client.beta.threads.runs.with_raw_response.create(
023a4e66Stainless Bot2 years ago846"",
847assistant_id="string",
848)
849
5429f696Stainless Bot2 years ago850@parametrize
851async def test_method_create_overload_2(self, async_client: AsyncOpenAI) -> None:
852run_stream = await async_client.beta.threads.runs.create(
853"string",
854assistant_id="string",
855stream=True,
856)
857await run_stream.response.aclose()
858
859@parametrize
860async def test_method_create_with_all_params_overload_2(self, async_client: AsyncOpenAI) -> None:
861run_stream = await async_client.beta.threads.runs.create(
862"string",
863assistant_id="string",
864stream=True,
865additional_instructions="string",
e2d65bf7Stainless Bot2 years ago866additional_messages=[
867{
868"role": "user",
869"content": "x",
5b20698dStainless Bot2 years ago870"attachments": [
871{
872"file_id": "string",
f73996b7Stainless Bot2 years ago873"tools": [
874{"type": "code_interpreter"},
875{"type": "code_interpreter"},
876{"type": "code_interpreter"},
877],
5b20698dStainless Bot2 years ago878},
879{
880"file_id": "string",
f73996b7Stainless Bot2 years ago881"tools": [
882{"type": "code_interpreter"},
883{"type": "code_interpreter"},
884{"type": "code_interpreter"},
885],
5b20698dStainless Bot2 years ago886},
887{
888"file_id": "string",
f73996b7Stainless Bot2 years ago889"tools": [
890{"type": "code_interpreter"},
891{"type": "code_interpreter"},
892{"type": "code_interpreter"},
893],
5b20698dStainless Bot2 years ago894},
895],
e2d65bf7Stainless Bot2 years ago896"metadata": {},
897},
898{
899"role": "user",
900"content": "x",
5b20698dStainless Bot2 years ago901"attachments": [
902{
903"file_id": "string",
f73996b7Stainless Bot2 years ago904"tools": [
905{"type": "code_interpreter"},
906{"type": "code_interpreter"},
907{"type": "code_interpreter"},
908],
5b20698dStainless Bot2 years ago909},
910{
911"file_id": "string",
f73996b7Stainless Bot2 years ago912"tools": [
913{"type": "code_interpreter"},
914{"type": "code_interpreter"},
915{"type": "code_interpreter"},
916],
5b20698dStainless Bot2 years ago917},
918{
919"file_id": "string",
f73996b7Stainless Bot2 years ago920"tools": [
921{"type": "code_interpreter"},
922{"type": "code_interpreter"},
923{"type": "code_interpreter"},
924],
5b20698dStainless Bot2 years ago925},
926],
e2d65bf7Stainless Bot2 years ago927"metadata": {},
928},
929{
930"role": "user",
931"content": "x",
5b20698dStainless Bot2 years ago932"attachments": [
933{
934"file_id": "string",
f73996b7Stainless Bot2 years ago935"tools": [
936{"type": "code_interpreter"},
937{"type": "code_interpreter"},
938{"type": "code_interpreter"},
939],
5b20698dStainless Bot2 years ago940},
941{
942"file_id": "string",
f73996b7Stainless Bot2 years ago943"tools": [
944{"type": "code_interpreter"},
945{"type": "code_interpreter"},
946{"type": "code_interpreter"},
947],
5b20698dStainless Bot2 years ago948},
949{
950"file_id": "string",
f73996b7Stainless Bot2 years ago951"tools": [
952{"type": "code_interpreter"},
953{"type": "code_interpreter"},
954{"type": "code_interpreter"},
955],
5b20698dStainless Bot2 years ago956},
957],
e2d65bf7Stainless Bot2 years ago958"metadata": {},
959},
960],
5429f696Stainless Bot2 years ago961instructions="string",
f5247e30Stainless Bot2 years ago962max_completion_tokens=256,
963max_prompt_tokens=256,
5429f696Stainless Bot2 years ago964metadata={},
f5247e30Stainless Bot2 years ago965model="gpt-4-turbo",
966response_format="none",
27a4626aStainless Bot2 years ago967temperature=1,
f5247e30Stainless Bot2 years ago968tool_choice="none",
5429f696Stainless Bot2 years ago969tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago970top_p=1,
f5247e30Stainless Bot2 years ago971truncation_strategy={
972"type": "auto",
973"last_messages": 1,
974},
5429f696Stainless Bot2 years ago975)
976await run_stream.response.aclose()
977
978@parametrize
979async def test_raw_response_create_overload_2(self, async_client: AsyncOpenAI) -> None:
980response = await async_client.beta.threads.runs.with_raw_response.create(
981"string",
982assistant_id="string",
983stream=True,
984)
985
986assert response.http_request.headers.get("X-Stainless-Lang") == "python"
987stream = response.parse()
988await stream.close()
989
990@parametrize
991async def test_streaming_response_create_overload_2(self, async_client: AsyncOpenAI) -> None:
992async with async_client.beta.threads.runs.with_streaming_response.create(
993"string",
994assistant_id="string",
995stream=True,
996) as response:
997assert not response.is_closed
998assert response.http_request.headers.get("X-Stainless-Lang") == "python"
999
1000stream = await response.parse()
1001await stream.close()
1002
1003assert cast(Any, response.is_closed) is True
1004
1005@parametrize
1006async def test_path_params_create_overload_2(self, async_client: AsyncOpenAI) -> None:
1007with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
1008await async_client.beta.threads.runs.with_raw_response.create(
1009"",
1010assistant_id="string",
1011stream=True,
1012)
1013
baa9f07fRobert Craigie2 years ago1014@parametrize
98d779fbStainless Bot2 years ago1015async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None:
1016run = await async_client.beta.threads.runs.retrieve(
baa9f07fRobert Craigie2 years ago1017"string",
1018thread_id="string",
1019)
1020assert_matches_type(Run, run, path=["response"])
1021
1022@parametrize
98d779fbStainless Bot2 years ago1023async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None:
1024response = await async_client.beta.threads.runs.with_raw_response.retrieve(
baa9f07fRobert Craigie2 years ago1025"string",
1026thread_id="string",
1027)
86379b44Stainless Bot2 years ago1028
1029assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1030assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1031run = response.parse()
1032assert_matches_type(Run, run, path=["response"])
1033
86379b44Stainless Bot2 years ago1034@parametrize
98d779fbStainless Bot2 years ago1035async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None:
1036async with async_client.beta.threads.runs.with_streaming_response.retrieve(
86379b44Stainless Bot2 years ago1037"string",
1038thread_id="string",
1039) as response:
1040assert not response.is_closed
1041assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1042
1043run = await response.parse()
1044assert_matches_type(Run, run, path=["response"])
1045
1046assert cast(Any, response.is_closed) is True
1047
023a4e66Stainless Bot2 years ago1048@parametrize
98d779fbStainless Bot2 years ago1049async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1050with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1051await async_client.beta.threads.runs.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago1052"string",
1053thread_id="",
1054)
1055
1056with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1057await async_client.beta.threads.runs.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago1058"",
1059thread_id="string",
1060)
1061
baa9f07fRobert Craigie2 years ago1062@parametrize
98d779fbStainless Bot2 years ago1063async def test_method_update(self, async_client: AsyncOpenAI) -> None:
1064run = await async_client.beta.threads.runs.update(
baa9f07fRobert Craigie2 years ago1065"string",
1066thread_id="string",
1067)
1068assert_matches_type(Run, run, path=["response"])
1069
1070@parametrize
98d779fbStainless Bot2 years ago1071async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None:
1072run = await async_client.beta.threads.runs.update(
baa9f07fRobert Craigie2 years ago1073"string",
1074thread_id="string",
1075metadata={},
1076)
1077assert_matches_type(Run, run, path=["response"])
1078
1079@parametrize
98d779fbStainless Bot2 years ago1080async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None:
1081response = await async_client.beta.threads.runs.with_raw_response.update(
baa9f07fRobert Craigie2 years ago1082"string",
1083thread_id="string",
1084)
86379b44Stainless Bot2 years ago1085
1086assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1087assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1088run = response.parse()
1089assert_matches_type(Run, run, path=["response"])
1090
86379b44Stainless Bot2 years ago1091@parametrize
98d779fbStainless Bot2 years ago1092async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None:
1093async with async_client.beta.threads.runs.with_streaming_response.update(
86379b44Stainless Bot2 years ago1094"string",
1095thread_id="string",
1096) as response:
1097assert not response.is_closed
1098assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1099
1100run = await response.parse()
1101assert_matches_type(Run, run, path=["response"])
1102
1103assert cast(Any, response.is_closed) is True
1104
023a4e66Stainless Bot2 years ago1105@parametrize
98d779fbStainless Bot2 years ago1106async def test_path_params_update(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1107with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1108await async_client.beta.threads.runs.with_raw_response.update(
023a4e66Stainless Bot2 years ago1109"string",
1110thread_id="",
1111)
1112
1113with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1114await async_client.beta.threads.runs.with_raw_response.update(
023a4e66Stainless Bot2 years ago1115"",
1116thread_id="string",
1117)
1118
baa9f07fRobert Craigie2 years ago1119@parametrize
98d779fbStainless Bot2 years ago1120async def test_method_list(self, async_client: AsyncOpenAI) -> None:
1121run = await async_client.beta.threads.runs.list(
baa9f07fRobert Craigie2 years ago1122"string",
1123)
1124assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1125
1126@parametrize
98d779fbStainless Bot2 years ago1127async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None:
1128run = await async_client.beta.threads.runs.list(
baa9f07fRobert Craigie2 years ago1129"string",
1130after="string",
1131before="string",
1132limit=0,
1133order="asc",
1134)
1135assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1136
1137@parametrize
98d779fbStainless Bot2 years ago1138async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None:
1139response = await async_client.beta.threads.runs.with_raw_response.list(
baa9f07fRobert Craigie2 years ago1140"string",
1141)
86379b44Stainless Bot2 years ago1142
1143assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1144assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1145run = response.parse()
1146assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1147
86379b44Stainless Bot2 years ago1148@parametrize
98d779fbStainless Bot2 years ago1149async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None:
1150async with async_client.beta.threads.runs.with_streaming_response.list(
86379b44Stainless Bot2 years ago1151"string",
1152) as response:
1153assert not response.is_closed
1154assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1155
1156run = await response.parse()
1157assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1158
1159assert cast(Any, response.is_closed) is True
1160
023a4e66Stainless Bot2 years ago1161@parametrize
98d779fbStainless Bot2 years ago1162async def test_path_params_list(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1163with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1164await async_client.beta.threads.runs.with_raw_response.list(
023a4e66Stainless Bot2 years ago1165"",
1166)
1167
baa9f07fRobert Craigie2 years ago1168@parametrize
98d779fbStainless Bot2 years ago1169async def test_method_cancel(self, async_client: AsyncOpenAI) -> None:
1170run = await async_client.beta.threads.runs.cancel(
baa9f07fRobert Craigie2 years ago1171"string",
1172thread_id="string",
1173)
1174assert_matches_type(Run, run, path=["response"])
1175
1176@parametrize
98d779fbStainless Bot2 years ago1177async def test_raw_response_cancel(self, async_client: AsyncOpenAI) -> None:
1178response = await async_client.beta.threads.runs.with_raw_response.cancel(
baa9f07fRobert Craigie2 years ago1179"string",
1180thread_id="string",
1181)
86379b44Stainless Bot2 years ago1182
1183assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1184assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1185run = response.parse()
1186assert_matches_type(Run, run, path=["response"])
1187
86379b44Stainless Bot2 years ago1188@parametrize
98d779fbStainless Bot2 years ago1189async def test_streaming_response_cancel(self, async_client: AsyncOpenAI) -> None:
1190async with async_client.beta.threads.runs.with_streaming_response.cancel(
86379b44Stainless Bot2 years ago1191"string",
1192thread_id="string",
1193) as response:
1194assert not response.is_closed
1195assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1196
1197run = await response.parse()
1198assert_matches_type(Run, run, path=["response"])
1199
1200assert cast(Any, response.is_closed) is True
1201
023a4e66Stainless Bot2 years ago1202@parametrize
98d779fbStainless Bot2 years ago1203async def test_path_params_cancel(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1204with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1205await async_client.beta.threads.runs.with_raw_response.cancel(
023a4e66Stainless Bot2 years ago1206"string",
1207thread_id="",
1208)
1209
1210with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1211await async_client.beta.threads.runs.with_raw_response.cancel(
023a4e66Stainless Bot2 years ago1212"",
1213thread_id="string",
1214)
1215
baa9f07fRobert Craigie2 years ago1216@parametrize
5429f696Stainless Bot2 years ago1217async def test_method_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago1218run = await async_client.beta.threads.runs.submit_tool_outputs(
baa9f07fRobert Craigie2 years ago1219"string",
1220thread_id="string",
1221tool_outputs=[{}, {}, {}],
1222)
1223assert_matches_type(Run, run, path=["response"])
1224
1225@parametrize
5429f696Stainless Bot2 years ago1226async def test_method_submit_tool_outputs_with_all_params_overload_1(self, async_client: AsyncOpenAI) -> None:
1227run = await async_client.beta.threads.runs.submit_tool_outputs(
1228"string",
1229thread_id="string",
1230tool_outputs=[
1231{
1232"tool_call_id": "string",
1233"output": "string",
1234},
1235{
1236"tool_call_id": "string",
1237"output": "string",
1238},
1239{
1240"tool_call_id": "string",
1241"output": "string",
1242},
1243],
1244stream=False,
1245)
1246assert_matches_type(Run, run, path=["response"])
1247
1248@parametrize
1249async def test_raw_response_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago1250response = await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
baa9f07fRobert Craigie2 years ago1251"string",
1252thread_id="string",
1253tool_outputs=[{}, {}, {}],
1254)
86379b44Stainless Bot2 years ago1255
1256assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1257assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1258run = response.parse()
1259assert_matches_type(Run, run, path=["response"])
86379b44Stainless Bot2 years ago1260
1261@parametrize
5429f696Stainless Bot2 years ago1262async def test_streaming_response_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago1263async with async_client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
86379b44Stainless Bot2 years ago1264"string",
1265thread_id="string",
1266tool_outputs=[{}, {}, {}],
1267) as response:
1268assert not response.is_closed
1269assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1270
1271run = await response.parse()
1272assert_matches_type(Run, run, path=["response"])
1273
1274assert cast(Any, response.is_closed) is True
023a4e66Stainless Bot2 years ago1275
1276@parametrize
5429f696Stainless Bot2 years ago1277async def test_path_params_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
1278with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
1279await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
1280"string",
1281thread_id="",
1282tool_outputs=[{}, {}, {}],
1283)
1284
1285with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
1286await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
1287"",
1288thread_id="string",
1289tool_outputs=[{}, {}, {}],
1290)
1291
1292@parametrize
1293async def test_method_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
1294run_stream = await async_client.beta.threads.runs.submit_tool_outputs(
1295"string",
1296thread_id="string",
1297stream=True,
1298tool_outputs=[{}, {}, {}],
1299)
1300await run_stream.response.aclose()
1301
1302@parametrize
1303async def test_raw_response_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
1304response = await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
1305"string",
1306thread_id="string",
1307stream=True,
1308tool_outputs=[{}, {}, {}],
1309)
1310
1311assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1312stream = response.parse()
1313await stream.close()
1314
1315@parametrize
1316async def test_streaming_response_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
1317async with async_client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
1318"string",
1319thread_id="string",
1320stream=True,
1321tool_outputs=[{}, {}, {}],
1322) as response:
1323assert not response.is_closed
1324assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1325
1326stream = await response.parse()
1327await stream.close()
1328
1329assert cast(Any, response.is_closed) is True
1330
1331@parametrize
1332async def test_path_params_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1333with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1334await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
023a4e66Stainless Bot2 years ago1335"string",
1336thread_id="",
5429f696Stainless Bot2 years ago1337stream=True,
023a4e66Stainless Bot2 years ago1338tool_outputs=[{}, {}, {}],
1339)
1340
1341with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1342await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
023a4e66Stainless Bot2 years ago1343"",
1344thread_id="string",
5429f696Stainless Bot2 years ago1345stream=True,
023a4e66Stainless Bot2 years ago1346tool_outputs=[{}, {}, {}],
1347)