openai/openai-python

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.42.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

1351lines · 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{
79a0b401Stainless Bot2 years ago41"content": "string",
092a8df7Stainless Bot1 years ago42"role": "user",
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{
79a0b401Stainless Bot2 years ago72"content": "string",
092a8df7Stainless Bot1 years ago73"role": "user",
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{
79a0b401Stainless Bot2 years ago103"content": "string",
092a8df7Stainless Bot1 years ago104"role": "user",
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={},
bf1ca86cRobert Craigie1 years ago138model="gpt-4o",
7399ffc8Stainless Bot2 years ago139parallel_tool_calls=True,
bf1ca86cRobert Craigie1 years ago140response_format="auto",
5429f696Stainless Bot2 years ago141stream=False,
27a4626aStainless Bot2 years ago142temperature=1,
f5247e30Stainless Bot2 years ago143tool_choice="none",
baa9f07fRobert Craigie2 years ago144tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago145top_p=1,
f5247e30Stainless Bot2 years ago146truncation_strategy={
147"type": "auto",
148"last_messages": 1,
149},
baa9f07fRobert Craigie2 years ago150)
151assert_matches_type(Run, run, path=["response"])
152
153@parametrize
5429f696Stainless Bot2 years ago154def test_raw_response_create_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago155response = client.beta.threads.runs.with_raw_response.create(
156"string",
157assistant_id="string",
158)
86379b44Stainless Bot2 years ago159
160assert response.is_closed is True
baa9f07fRobert Craigie2 years ago161assert response.http_request.headers.get("X-Stainless-Lang") == "python"
162run = response.parse()
163assert_matches_type(Run, run, path=["response"])
164
86379b44Stainless Bot2 years ago165@parametrize
5429f696Stainless Bot2 years ago166def test_streaming_response_create_overload_1(self, client: OpenAI) -> None:
86379b44Stainless Bot2 years ago167with client.beta.threads.runs.with_streaming_response.create(
168"string",
169assistant_id="string",
170) as response:
171assert not response.is_closed
172assert response.http_request.headers.get("X-Stainless-Lang") == "python"
173
174run = response.parse()
175assert_matches_type(Run, run, path=["response"])
176
177assert cast(Any, response.is_closed) is True
178
023a4e66Stainless Bot2 years ago179@parametrize
5429f696Stainless Bot2 years ago180def test_path_params_create_overload_1(self, client: OpenAI) -> None:
023a4e66Stainless Bot2 years ago181with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
182client.beta.threads.runs.with_raw_response.create(
183"",
184assistant_id="string",
185)
186
5429f696Stainless Bot2 years ago187@parametrize
188def test_method_create_overload_2(self, client: OpenAI) -> None:
189run_stream = client.beta.threads.runs.create(
190"string",
191assistant_id="string",
192stream=True,
193)
194run_stream.response.close()
195
196@parametrize
197def test_method_create_with_all_params_overload_2(self, client: OpenAI) -> None:
198run_stream = client.beta.threads.runs.create(
199"string",
200assistant_id="string",
201stream=True,
202additional_instructions="string",
e2d65bf7Stainless Bot2 years ago203additional_messages=[
204{
79a0b401Stainless Bot2 years ago205"content": "string",
092a8df7Stainless Bot1 years ago206"role": "user",
5b20698dStainless Bot2 years ago207"attachments": [
208{
209"file_id": "string",
f73996b7Stainless Bot2 years ago210"tools": [
211{"type": "code_interpreter"},
212{"type": "code_interpreter"},
213{"type": "code_interpreter"},
214],
5b20698dStainless Bot2 years ago215},
216{
217"file_id": "string",
f73996b7Stainless Bot2 years ago218"tools": [
219{"type": "code_interpreter"},
220{"type": "code_interpreter"},
221{"type": "code_interpreter"},
222],
5b20698dStainless Bot2 years ago223},
224{
225"file_id": "string",
f73996b7Stainless Bot2 years ago226"tools": [
227{"type": "code_interpreter"},
228{"type": "code_interpreter"},
229{"type": "code_interpreter"},
230],
5b20698dStainless Bot2 years ago231},
232],
e2d65bf7Stainless Bot2 years ago233"metadata": {},
234},
235{
79a0b401Stainless Bot2 years ago236"content": "string",
092a8df7Stainless Bot1 years ago237"role": "user",
5b20698dStainless Bot2 years ago238"attachments": [
239{
240"file_id": "string",
f73996b7Stainless Bot2 years ago241"tools": [
242{"type": "code_interpreter"},
243{"type": "code_interpreter"},
244{"type": "code_interpreter"},
245],
5b20698dStainless Bot2 years ago246},
247{
248"file_id": "string",
f73996b7Stainless Bot2 years ago249"tools": [
250{"type": "code_interpreter"},
251{"type": "code_interpreter"},
252{"type": "code_interpreter"},
253],
5b20698dStainless Bot2 years ago254},
255{
256"file_id": "string",
f73996b7Stainless Bot2 years ago257"tools": [
258{"type": "code_interpreter"},
259{"type": "code_interpreter"},
260{"type": "code_interpreter"},
261],
5b20698dStainless Bot2 years ago262},
263],
e2d65bf7Stainless Bot2 years ago264"metadata": {},
265},
266{
79a0b401Stainless Bot2 years ago267"content": "string",
092a8df7Stainless Bot1 years ago268"role": "user",
5b20698dStainless Bot2 years ago269"attachments": [
270{
271"file_id": "string",
f73996b7Stainless Bot2 years ago272"tools": [
273{"type": "code_interpreter"},
274{"type": "code_interpreter"},
275{"type": "code_interpreter"},
276],
5b20698dStainless Bot2 years ago277},
278{
279"file_id": "string",
f73996b7Stainless Bot2 years ago280"tools": [
281{"type": "code_interpreter"},
282{"type": "code_interpreter"},
283{"type": "code_interpreter"},
284],
5b20698dStainless Bot2 years ago285},
286{
287"file_id": "string",
f73996b7Stainless Bot2 years ago288"tools": [
289{"type": "code_interpreter"},
290{"type": "code_interpreter"},
291{"type": "code_interpreter"},
292],
5b20698dStainless Bot2 years ago293},
294],
e2d65bf7Stainless Bot2 years ago295"metadata": {},
296},
297],
5429f696Stainless Bot2 years ago298instructions="string",
f5247e30Stainless Bot2 years ago299max_completion_tokens=256,
300max_prompt_tokens=256,
5429f696Stainless Bot2 years ago301metadata={},
bf1ca86cRobert Craigie1 years ago302model="gpt-4o",
7399ffc8Stainless Bot2 years ago303parallel_tool_calls=True,
bf1ca86cRobert Craigie1 years ago304response_format="auto",
27a4626aStainless Bot2 years ago305temperature=1,
f5247e30Stainless Bot2 years ago306tool_choice="none",
5429f696Stainless Bot2 years ago307tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago308top_p=1,
f5247e30Stainless Bot2 years ago309truncation_strategy={
310"type": "auto",
311"last_messages": 1,
312},
5429f696Stainless Bot2 years ago313)
314run_stream.response.close()
315
316@parametrize
317def test_raw_response_create_overload_2(self, client: OpenAI) -> None:
318response = client.beta.threads.runs.with_raw_response.create(
319"string",
320assistant_id="string",
321stream=True,
322)
323
324assert response.http_request.headers.get("X-Stainless-Lang") == "python"
325stream = response.parse()
326stream.close()
327
328@parametrize
329def test_streaming_response_create_overload_2(self, client: OpenAI) -> None:
330with client.beta.threads.runs.with_streaming_response.create(
331"string",
332assistant_id="string",
333stream=True,
334) as response:
335assert not response.is_closed
336assert response.http_request.headers.get("X-Stainless-Lang") == "python"
337
338stream = response.parse()
339stream.close()
340
341assert cast(Any, response.is_closed) is True
342
343@parametrize
344def test_path_params_create_overload_2(self, client: OpenAI) -> None:
345with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
346client.beta.threads.runs.with_raw_response.create(
347"",
348assistant_id="string",
349stream=True,
350)
351
baa9f07fRobert Craigie2 years ago352@parametrize
353def test_method_retrieve(self, client: OpenAI) -> None:
354run = client.beta.threads.runs.retrieve(
355"string",
356thread_id="string",
357)
358assert_matches_type(Run, run, path=["response"])
359
360@parametrize
361def test_raw_response_retrieve(self, client: OpenAI) -> None:
362response = client.beta.threads.runs.with_raw_response.retrieve(
363"string",
364thread_id="string",
365)
86379b44Stainless Bot2 years ago366
367assert response.is_closed is True
baa9f07fRobert Craigie2 years ago368assert response.http_request.headers.get("X-Stainless-Lang") == "python"
369run = response.parse()
370assert_matches_type(Run, run, path=["response"])
371
86379b44Stainless Bot2 years ago372@parametrize
373def test_streaming_response_retrieve(self, client: OpenAI) -> None:
374with client.beta.threads.runs.with_streaming_response.retrieve(
375"string",
376thread_id="string",
377) as response:
378assert not response.is_closed
379assert response.http_request.headers.get("X-Stainless-Lang") == "python"
380
381run = response.parse()
382assert_matches_type(Run, run, path=["response"])
383
384assert cast(Any, response.is_closed) is True
385
023a4e66Stainless Bot2 years ago386@parametrize
387def test_path_params_retrieve(self, client: OpenAI) -> None:
388with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
389client.beta.threads.runs.with_raw_response.retrieve(
390"string",
391thread_id="",
392)
393
394with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
395client.beta.threads.runs.with_raw_response.retrieve(
396"",
397thread_id="string",
398)
399
baa9f07fRobert Craigie2 years ago400@parametrize
401def test_method_update(self, client: OpenAI) -> None:
402run = client.beta.threads.runs.update(
403"string",
404thread_id="string",
405)
406assert_matches_type(Run, run, path=["response"])
407
408@parametrize
409def test_method_update_with_all_params(self, client: OpenAI) -> None:
410run = client.beta.threads.runs.update(
411"string",
412thread_id="string",
413metadata={},
414)
415assert_matches_type(Run, run, path=["response"])
416
417@parametrize
418def test_raw_response_update(self, client: OpenAI) -> None:
419response = client.beta.threads.runs.with_raw_response.update(
420"string",
421thread_id="string",
422)
86379b44Stainless Bot2 years ago423
424assert response.is_closed is True
baa9f07fRobert Craigie2 years ago425assert response.http_request.headers.get("X-Stainless-Lang") == "python"
426run = response.parse()
427assert_matches_type(Run, run, path=["response"])
428
86379b44Stainless Bot2 years ago429@parametrize
430def test_streaming_response_update(self, client: OpenAI) -> None:
431with client.beta.threads.runs.with_streaming_response.update(
432"string",
433thread_id="string",
434) as response:
435assert not response.is_closed
436assert response.http_request.headers.get("X-Stainless-Lang") == "python"
437
438run = response.parse()
439assert_matches_type(Run, run, path=["response"])
440
441assert cast(Any, response.is_closed) is True
442
023a4e66Stainless Bot2 years ago443@parametrize
444def test_path_params_update(self, client: OpenAI) -> None:
445with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
446client.beta.threads.runs.with_raw_response.update(
447"string",
448thread_id="",
449)
450
451with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
452client.beta.threads.runs.with_raw_response.update(
453"",
454thread_id="string",
455)
456
baa9f07fRobert Craigie2 years ago457@parametrize
458def test_method_list(self, client: OpenAI) -> None:
459run = client.beta.threads.runs.list(
460"string",
461)
462assert_matches_type(SyncCursorPage[Run], run, path=["response"])
463
464@parametrize
465def test_method_list_with_all_params(self, client: OpenAI) -> None:
466run = client.beta.threads.runs.list(
467"string",
468after="string",
469before="string",
470limit=0,
471order="asc",
472)
473assert_matches_type(SyncCursorPage[Run], run, path=["response"])
474
475@parametrize
476def test_raw_response_list(self, client: OpenAI) -> None:
477response = client.beta.threads.runs.with_raw_response.list(
478"string",
479)
86379b44Stainless Bot2 years ago480
481assert response.is_closed is True
baa9f07fRobert Craigie2 years ago482assert response.http_request.headers.get("X-Stainless-Lang") == "python"
483run = response.parse()
484assert_matches_type(SyncCursorPage[Run], run, path=["response"])
485
86379b44Stainless Bot2 years ago486@parametrize
487def test_streaming_response_list(self, client: OpenAI) -> None:
488with client.beta.threads.runs.with_streaming_response.list(
489"string",
490) as response:
491assert not response.is_closed
492assert response.http_request.headers.get("X-Stainless-Lang") == "python"
493
494run = response.parse()
495assert_matches_type(SyncCursorPage[Run], run, path=["response"])
496
497assert cast(Any, response.is_closed) is True
498
023a4e66Stainless Bot2 years ago499@parametrize
500def test_path_params_list(self, client: OpenAI) -> None:
501with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
502client.beta.threads.runs.with_raw_response.list(
503"",
504)
505
baa9f07fRobert Craigie2 years ago506@parametrize
507def test_method_cancel(self, client: OpenAI) -> None:
508run = client.beta.threads.runs.cancel(
509"string",
510thread_id="string",
511)
512assert_matches_type(Run, run, path=["response"])
513
514@parametrize
515def test_raw_response_cancel(self, client: OpenAI) -> None:
516response = client.beta.threads.runs.with_raw_response.cancel(
517"string",
518thread_id="string",
519)
86379b44Stainless Bot2 years ago520
521assert response.is_closed is True
baa9f07fRobert Craigie2 years ago522assert response.http_request.headers.get("X-Stainless-Lang") == "python"
523run = response.parse()
524assert_matches_type(Run, run, path=["response"])
525
86379b44Stainless Bot2 years ago526@parametrize
527def test_streaming_response_cancel(self, client: OpenAI) -> None:
528with client.beta.threads.runs.with_streaming_response.cancel(
529"string",
530thread_id="string",
531) as response:
532assert not response.is_closed
533assert response.http_request.headers.get("X-Stainless-Lang") == "python"
534
535run = response.parse()
536assert_matches_type(Run, run, path=["response"])
537
538assert cast(Any, response.is_closed) is True
539
023a4e66Stainless Bot2 years ago540@parametrize
541def test_path_params_cancel(self, client: OpenAI) -> None:
542with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
543client.beta.threads.runs.with_raw_response.cancel(
544"string",
545thread_id="",
546)
547
548with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
549client.beta.threads.runs.with_raw_response.cancel(
550"",
551thread_id="string",
552)
553
baa9f07fRobert Craigie2 years ago554@parametrize
5429f696Stainless Bot2 years ago555def test_method_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago556run = client.beta.threads.runs.submit_tool_outputs(
557"string",
558thread_id="string",
559tool_outputs=[{}, {}, {}],
560)
561assert_matches_type(Run, run, path=["response"])
562
563@parametrize
5429f696Stainless Bot2 years ago564def test_method_submit_tool_outputs_with_all_params_overload_1(self, client: OpenAI) -> None:
565run = client.beta.threads.runs.submit_tool_outputs(
566"string",
567thread_id="string",
568tool_outputs=[
569{
092a8df7Stainless Bot1 years ago570"output": "output",
571"tool_call_id": "tool_call_id",
5429f696Stainless Bot2 years ago572},
573{
092a8df7Stainless Bot1 years ago574"output": "output",
575"tool_call_id": "tool_call_id",
5429f696Stainless Bot2 years ago576},
577{
092a8df7Stainless Bot1 years ago578"output": "output",
579"tool_call_id": "tool_call_id",
5429f696Stainless Bot2 years ago580},
581],
582stream=False,
583)
584assert_matches_type(Run, run, path=["response"])
585
586@parametrize
587def test_raw_response_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago588response = client.beta.threads.runs.with_raw_response.submit_tool_outputs(
589"string",
590thread_id="string",
591tool_outputs=[{}, {}, {}],
592)
86379b44Stainless Bot2 years ago593
594assert response.is_closed is True
baa9f07fRobert Craigie2 years ago595assert response.http_request.headers.get("X-Stainless-Lang") == "python"
596run = response.parse()
597assert_matches_type(Run, run, path=["response"])
598
86379b44Stainless Bot2 years ago599@parametrize
5429f696Stainless Bot2 years ago600def test_streaming_response_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
86379b44Stainless Bot2 years ago601with client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
602"string",
603thread_id="string",
604tool_outputs=[{}, {}, {}],
605) as response:
606assert not response.is_closed
607assert response.http_request.headers.get("X-Stainless-Lang") == "python"
608
609run = response.parse()
610assert_matches_type(Run, run, path=["response"])
611
612assert cast(Any, response.is_closed) is True
613
023a4e66Stainless Bot2 years ago614@parametrize
5429f696Stainless Bot2 years ago615def test_path_params_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
616with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
617client.beta.threads.runs.with_raw_response.submit_tool_outputs(
618"string",
619thread_id="",
620tool_outputs=[{}, {}, {}],
621)
622
623with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
624client.beta.threads.runs.with_raw_response.submit_tool_outputs(
625"",
626thread_id="string",
627tool_outputs=[{}, {}, {}],
628)
629
630@parametrize
631def test_method_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
632run_stream = client.beta.threads.runs.submit_tool_outputs(
633"string",
634thread_id="string",
635stream=True,
636tool_outputs=[{}, {}, {}],
637)
638run_stream.response.close()
639
640@parametrize
641def test_raw_response_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
642response = client.beta.threads.runs.with_raw_response.submit_tool_outputs(
643"string",
644thread_id="string",
645stream=True,
646tool_outputs=[{}, {}, {}],
647)
648
649assert response.http_request.headers.get("X-Stainless-Lang") == "python"
650stream = response.parse()
651stream.close()
652
653@parametrize
654def test_streaming_response_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
655with client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
656"string",
657thread_id="string",
658stream=True,
659tool_outputs=[{}, {}, {}],
660) as response:
661assert not response.is_closed
662assert response.http_request.headers.get("X-Stainless-Lang") == "python"
663
664stream = response.parse()
665stream.close()
666
667assert cast(Any, response.is_closed) is True
668
669@parametrize
670def test_path_params_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
023a4e66Stainless Bot2 years ago671with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
672client.beta.threads.runs.with_raw_response.submit_tool_outputs(
673"string",
674thread_id="",
5429f696Stainless Bot2 years ago675stream=True,
023a4e66Stainless Bot2 years ago676tool_outputs=[{}, {}, {}],
677)
678
679with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
680client.beta.threads.runs.with_raw_response.submit_tool_outputs(
681"",
682thread_id="string",
5429f696Stainless Bot2 years ago683stream=True,
023a4e66Stainless Bot2 years ago684tool_outputs=[{}, {}, {}],
685)
686
baa9f07fRobert Craigie2 years ago687
688class TestAsyncRuns:
98d779fbStainless Bot2 years ago689parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
baa9f07fRobert Craigie2 years ago690
691@parametrize
5429f696Stainless Bot2 years ago692async def test_method_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago693run = await async_client.beta.threads.runs.create(
baa9f07fRobert Craigie2 years ago694"string",
695assistant_id="string",
696)
697assert_matches_type(Run, run, path=["response"])
698
699@parametrize
5429f696Stainless Bot2 years ago700async def test_method_create_with_all_params_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago701run = await async_client.beta.threads.runs.create(
baa9f07fRobert Craigie2 years ago702"string",
703assistant_id="string",
53bca49eStainless Bot2 years ago704additional_instructions="string",
e2d65bf7Stainless Bot2 years ago705additional_messages=[
706{
79a0b401Stainless Bot2 years ago707"content": "string",
092a8df7Stainless Bot1 years ago708"role": "user",
5b20698dStainless Bot2 years ago709"attachments": [
710{
711"file_id": "string",
f73996b7Stainless Bot2 years ago712"tools": [
713{"type": "code_interpreter"},
714{"type": "code_interpreter"},
715{"type": "code_interpreter"},
716],
5b20698dStainless Bot2 years ago717},
718{
719"file_id": "string",
f73996b7Stainless Bot2 years ago720"tools": [
721{"type": "code_interpreter"},
722{"type": "code_interpreter"},
723{"type": "code_interpreter"},
724],
5b20698dStainless Bot2 years ago725},
726{
727"file_id": "string",
f73996b7Stainless Bot2 years ago728"tools": [
729{"type": "code_interpreter"},
730{"type": "code_interpreter"},
731{"type": "code_interpreter"},
732],
5b20698dStainless Bot2 years ago733},
734],
e2d65bf7Stainless Bot2 years ago735"metadata": {},
736},
737{
79a0b401Stainless Bot2 years ago738"content": "string",
092a8df7Stainless Bot1 years ago739"role": "user",
5b20698dStainless Bot2 years ago740"attachments": [
741{
742"file_id": "string",
f73996b7Stainless Bot2 years ago743"tools": [
744{"type": "code_interpreter"},
745{"type": "code_interpreter"},
746{"type": "code_interpreter"},
747],
5b20698dStainless Bot2 years ago748},
749{
750"file_id": "string",
f73996b7Stainless Bot2 years ago751"tools": [
752{"type": "code_interpreter"},
753{"type": "code_interpreter"},
754{"type": "code_interpreter"},
755],
5b20698dStainless Bot2 years ago756},
757{
758"file_id": "string",
f73996b7Stainless Bot2 years ago759"tools": [
760{"type": "code_interpreter"},
761{"type": "code_interpreter"},
762{"type": "code_interpreter"},
763],
5b20698dStainless Bot2 years ago764},
765],
e2d65bf7Stainless Bot2 years ago766"metadata": {},
767},
768{
79a0b401Stainless Bot2 years ago769"content": "string",
092a8df7Stainless Bot1 years ago770"role": "user",
5b20698dStainless Bot2 years ago771"attachments": [
772{
773"file_id": "string",
f73996b7Stainless Bot2 years ago774"tools": [
775{"type": "code_interpreter"},
776{"type": "code_interpreter"},
777{"type": "code_interpreter"},
778],
5b20698dStainless Bot2 years ago779},
780{
781"file_id": "string",
f73996b7Stainless Bot2 years ago782"tools": [
783{"type": "code_interpreter"},
784{"type": "code_interpreter"},
785{"type": "code_interpreter"},
786],
5b20698dStainless Bot2 years ago787},
788{
789"file_id": "string",
f73996b7Stainless Bot2 years ago790"tools": [
791{"type": "code_interpreter"},
792{"type": "code_interpreter"},
793{"type": "code_interpreter"},
794],
5b20698dStainless Bot2 years ago795},
796],
e2d65bf7Stainless Bot2 years ago797"metadata": {},
798},
799],
baa9f07fRobert Craigie2 years ago800instructions="string",
f5247e30Stainless Bot2 years ago801max_completion_tokens=256,
802max_prompt_tokens=256,
baa9f07fRobert Craigie2 years ago803metadata={},
bf1ca86cRobert Craigie1 years ago804model="gpt-4o",
7399ffc8Stainless Bot2 years ago805parallel_tool_calls=True,
bf1ca86cRobert Craigie1 years ago806response_format="auto",
5429f696Stainless Bot2 years ago807stream=False,
27a4626aStainless Bot2 years ago808temperature=1,
f5247e30Stainless Bot2 years ago809tool_choice="none",
baa9f07fRobert Craigie2 years ago810tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago811top_p=1,
f5247e30Stainless Bot2 years ago812truncation_strategy={
813"type": "auto",
814"last_messages": 1,
815},
baa9f07fRobert Craigie2 years ago816)
817assert_matches_type(Run, run, path=["response"])
818
819@parametrize
5429f696Stainless Bot2 years ago820async def test_raw_response_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago821response = await async_client.beta.threads.runs.with_raw_response.create(
baa9f07fRobert Craigie2 years ago822"string",
823assistant_id="string",
824)
86379b44Stainless Bot2 years ago825
826assert response.is_closed is True
baa9f07fRobert Craigie2 years ago827assert response.http_request.headers.get("X-Stainless-Lang") == "python"
828run = response.parse()
829assert_matches_type(Run, run, path=["response"])
830
86379b44Stainless Bot2 years ago831@parametrize
5429f696Stainless Bot2 years ago832async def test_streaming_response_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago833async with async_client.beta.threads.runs.with_streaming_response.create(
86379b44Stainless Bot2 years ago834"string",
835assistant_id="string",
836) as response:
837assert not response.is_closed
838assert response.http_request.headers.get("X-Stainless-Lang") == "python"
839
840run = await response.parse()
841assert_matches_type(Run, run, path=["response"])
842
843assert cast(Any, response.is_closed) is True
844
023a4e66Stainless Bot2 years ago845@parametrize
5429f696Stainless Bot2 years ago846async def test_path_params_create_overload_1(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago847with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago848await async_client.beta.threads.runs.with_raw_response.create(
023a4e66Stainless Bot2 years ago849"",
850assistant_id="string",
851)
852
5429f696Stainless Bot2 years ago853@parametrize
854async def test_method_create_overload_2(self, async_client: AsyncOpenAI) -> None:
855run_stream = await async_client.beta.threads.runs.create(
856"string",
857assistant_id="string",
858stream=True,
859)
860await run_stream.response.aclose()
861
862@parametrize
863async def test_method_create_with_all_params_overload_2(self, async_client: AsyncOpenAI) -> None:
864run_stream = await async_client.beta.threads.runs.create(
865"string",
866assistant_id="string",
867stream=True,
868additional_instructions="string",
e2d65bf7Stainless Bot2 years ago869additional_messages=[
870{
79a0b401Stainless Bot2 years ago871"content": "string",
092a8df7Stainless Bot1 years ago872"role": "user",
5b20698dStainless Bot2 years ago873"attachments": [
874{
875"file_id": "string",
f73996b7Stainless Bot2 years ago876"tools": [
877{"type": "code_interpreter"},
878{"type": "code_interpreter"},
879{"type": "code_interpreter"},
880],
5b20698dStainless Bot2 years ago881},
882{
883"file_id": "string",
f73996b7Stainless Bot2 years ago884"tools": [
885{"type": "code_interpreter"},
886{"type": "code_interpreter"},
887{"type": "code_interpreter"},
888],
5b20698dStainless Bot2 years ago889},
890{
891"file_id": "string",
f73996b7Stainless Bot2 years ago892"tools": [
893{"type": "code_interpreter"},
894{"type": "code_interpreter"},
895{"type": "code_interpreter"},
896],
5b20698dStainless Bot2 years ago897},
898],
e2d65bf7Stainless Bot2 years ago899"metadata": {},
900},
901{
79a0b401Stainless Bot2 years ago902"content": "string",
092a8df7Stainless Bot1 years ago903"role": "user",
5b20698dStainless Bot2 years ago904"attachments": [
905{
906"file_id": "string",
f73996b7Stainless Bot2 years ago907"tools": [
908{"type": "code_interpreter"},
909{"type": "code_interpreter"},
910{"type": "code_interpreter"},
911],
5b20698dStainless Bot2 years ago912},
913{
914"file_id": "string",
f73996b7Stainless Bot2 years ago915"tools": [
916{"type": "code_interpreter"},
917{"type": "code_interpreter"},
918{"type": "code_interpreter"},
919],
5b20698dStainless Bot2 years ago920},
921{
922"file_id": "string",
f73996b7Stainless Bot2 years ago923"tools": [
924{"type": "code_interpreter"},
925{"type": "code_interpreter"},
926{"type": "code_interpreter"},
927],
5b20698dStainless Bot2 years ago928},
929],
e2d65bf7Stainless Bot2 years ago930"metadata": {},
931},
932{
79a0b401Stainless Bot2 years ago933"content": "string",
092a8df7Stainless Bot1 years ago934"role": "user",
5b20698dStainless Bot2 years ago935"attachments": [
936{
937"file_id": "string",
f73996b7Stainless Bot2 years ago938"tools": [
939{"type": "code_interpreter"},
940{"type": "code_interpreter"},
941{"type": "code_interpreter"},
942],
5b20698dStainless Bot2 years ago943},
944{
945"file_id": "string",
f73996b7Stainless Bot2 years ago946"tools": [
947{"type": "code_interpreter"},
948{"type": "code_interpreter"},
949{"type": "code_interpreter"},
950],
5b20698dStainless Bot2 years ago951},
952{
953"file_id": "string",
f73996b7Stainless Bot2 years ago954"tools": [
955{"type": "code_interpreter"},
956{"type": "code_interpreter"},
957{"type": "code_interpreter"},
958],
5b20698dStainless Bot2 years ago959},
960],
e2d65bf7Stainless Bot2 years ago961"metadata": {},
962},
963],
5429f696Stainless Bot2 years ago964instructions="string",
f5247e30Stainless Bot2 years ago965max_completion_tokens=256,
966max_prompt_tokens=256,
5429f696Stainless Bot2 years ago967metadata={},
bf1ca86cRobert Craigie1 years ago968model="gpt-4o",
7399ffc8Stainless Bot2 years ago969parallel_tool_calls=True,
bf1ca86cRobert Craigie1 years ago970response_format="auto",
27a4626aStainless Bot2 years ago971temperature=1,
f5247e30Stainless Bot2 years ago972tool_choice="none",
5429f696Stainless Bot2 years ago973tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago974top_p=1,
f5247e30Stainless Bot2 years ago975truncation_strategy={
976"type": "auto",
977"last_messages": 1,
978},
5429f696Stainless Bot2 years ago979)
980await run_stream.response.aclose()
981
982@parametrize
983async def test_raw_response_create_overload_2(self, async_client: AsyncOpenAI) -> None:
984response = await async_client.beta.threads.runs.with_raw_response.create(
985"string",
986assistant_id="string",
987stream=True,
988)
989
990assert response.http_request.headers.get("X-Stainless-Lang") == "python"
991stream = response.parse()
992await stream.close()
993
994@parametrize
995async def test_streaming_response_create_overload_2(self, async_client: AsyncOpenAI) -> None:
996async with async_client.beta.threads.runs.with_streaming_response.create(
997"string",
998assistant_id="string",
999stream=True,
1000) as response:
1001assert not response.is_closed
1002assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1003
1004stream = await response.parse()
1005await stream.close()
1006
1007assert cast(Any, response.is_closed) is True
1008
1009@parametrize
1010async def test_path_params_create_overload_2(self, async_client: AsyncOpenAI) -> None:
1011with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
1012await async_client.beta.threads.runs.with_raw_response.create(
1013"",
1014assistant_id="string",
1015stream=True,
1016)
1017
baa9f07fRobert Craigie2 years ago1018@parametrize
98d779fbStainless Bot2 years ago1019async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None:
1020run = await async_client.beta.threads.runs.retrieve(
baa9f07fRobert Craigie2 years ago1021"string",
1022thread_id="string",
1023)
1024assert_matches_type(Run, run, path=["response"])
1025
1026@parametrize
98d779fbStainless Bot2 years ago1027async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None:
1028response = await async_client.beta.threads.runs.with_raw_response.retrieve(
baa9f07fRobert Craigie2 years ago1029"string",
1030thread_id="string",
1031)
86379b44Stainless Bot2 years ago1032
1033assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1034assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1035run = response.parse()
1036assert_matches_type(Run, run, path=["response"])
1037
86379b44Stainless Bot2 years ago1038@parametrize
98d779fbStainless Bot2 years ago1039async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None:
1040async with async_client.beta.threads.runs.with_streaming_response.retrieve(
86379b44Stainless Bot2 years ago1041"string",
1042thread_id="string",
1043) as response:
1044assert not response.is_closed
1045assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1046
1047run = await response.parse()
1048assert_matches_type(Run, run, path=["response"])
1049
1050assert cast(Any, response.is_closed) is True
1051
023a4e66Stainless Bot2 years ago1052@parametrize
98d779fbStainless Bot2 years ago1053async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1054with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1055await async_client.beta.threads.runs.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago1056"string",
1057thread_id="",
1058)
1059
1060with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1061await async_client.beta.threads.runs.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago1062"",
1063thread_id="string",
1064)
1065
baa9f07fRobert Craigie2 years ago1066@parametrize
98d779fbStainless Bot2 years ago1067async def test_method_update(self, async_client: AsyncOpenAI) -> None:
1068run = await async_client.beta.threads.runs.update(
baa9f07fRobert Craigie2 years ago1069"string",
1070thread_id="string",
1071)
1072assert_matches_type(Run, run, path=["response"])
1073
1074@parametrize
98d779fbStainless Bot2 years ago1075async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None:
1076run = await async_client.beta.threads.runs.update(
baa9f07fRobert Craigie2 years ago1077"string",
1078thread_id="string",
1079metadata={},
1080)
1081assert_matches_type(Run, run, path=["response"])
1082
1083@parametrize
98d779fbStainless Bot2 years ago1084async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None:
1085response = await async_client.beta.threads.runs.with_raw_response.update(
baa9f07fRobert Craigie2 years ago1086"string",
1087thread_id="string",
1088)
86379b44Stainless Bot2 years ago1089
1090assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1091assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1092run = response.parse()
1093assert_matches_type(Run, run, path=["response"])
1094
86379b44Stainless Bot2 years ago1095@parametrize
98d779fbStainless Bot2 years ago1096async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None:
1097async with async_client.beta.threads.runs.with_streaming_response.update(
86379b44Stainless Bot2 years ago1098"string",
1099thread_id="string",
1100) as response:
1101assert not response.is_closed
1102assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1103
1104run = await response.parse()
1105assert_matches_type(Run, run, path=["response"])
1106
1107assert cast(Any, response.is_closed) is True
1108
023a4e66Stainless Bot2 years ago1109@parametrize
98d779fbStainless Bot2 years ago1110async def test_path_params_update(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1111with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1112await async_client.beta.threads.runs.with_raw_response.update(
023a4e66Stainless Bot2 years ago1113"string",
1114thread_id="",
1115)
1116
1117with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1118await async_client.beta.threads.runs.with_raw_response.update(
023a4e66Stainless Bot2 years ago1119"",
1120thread_id="string",
1121)
1122
baa9f07fRobert Craigie2 years ago1123@parametrize
98d779fbStainless Bot2 years ago1124async def test_method_list(self, async_client: AsyncOpenAI) -> None:
1125run = await async_client.beta.threads.runs.list(
baa9f07fRobert Craigie2 years ago1126"string",
1127)
1128assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1129
1130@parametrize
98d779fbStainless Bot2 years ago1131async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None:
1132run = await async_client.beta.threads.runs.list(
baa9f07fRobert Craigie2 years ago1133"string",
1134after="string",
1135before="string",
1136limit=0,
1137order="asc",
1138)
1139assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1140
1141@parametrize
98d779fbStainless Bot2 years ago1142async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None:
1143response = await async_client.beta.threads.runs.with_raw_response.list(
baa9f07fRobert Craigie2 years ago1144"string",
1145)
86379b44Stainless Bot2 years ago1146
1147assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1148assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1149run = response.parse()
1150assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1151
86379b44Stainless Bot2 years ago1152@parametrize
98d779fbStainless Bot2 years ago1153async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None:
1154async with async_client.beta.threads.runs.with_streaming_response.list(
86379b44Stainless Bot2 years ago1155"string",
1156) as response:
1157assert not response.is_closed
1158assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1159
1160run = await response.parse()
1161assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1162
1163assert cast(Any, response.is_closed) is True
1164
023a4e66Stainless Bot2 years ago1165@parametrize
98d779fbStainless Bot2 years ago1166async def test_path_params_list(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1167with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1168await async_client.beta.threads.runs.with_raw_response.list(
023a4e66Stainless Bot2 years ago1169"",
1170)
1171
baa9f07fRobert Craigie2 years ago1172@parametrize
98d779fbStainless Bot2 years ago1173async def test_method_cancel(self, async_client: AsyncOpenAI) -> None:
1174run = await async_client.beta.threads.runs.cancel(
baa9f07fRobert Craigie2 years ago1175"string",
1176thread_id="string",
1177)
1178assert_matches_type(Run, run, path=["response"])
1179
1180@parametrize
98d779fbStainless Bot2 years ago1181async def test_raw_response_cancel(self, async_client: AsyncOpenAI) -> None:
1182response = await async_client.beta.threads.runs.with_raw_response.cancel(
baa9f07fRobert Craigie2 years ago1183"string",
1184thread_id="string",
1185)
86379b44Stainless Bot2 years ago1186
1187assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1188assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1189run = response.parse()
1190assert_matches_type(Run, run, path=["response"])
1191
86379b44Stainless Bot2 years ago1192@parametrize
98d779fbStainless Bot2 years ago1193async def test_streaming_response_cancel(self, async_client: AsyncOpenAI) -> None:
1194async with async_client.beta.threads.runs.with_streaming_response.cancel(
86379b44Stainless Bot2 years ago1195"string",
1196thread_id="string",
1197) as response:
1198assert not response.is_closed
1199assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1200
1201run = await response.parse()
1202assert_matches_type(Run, run, path=["response"])
1203
1204assert cast(Any, response.is_closed) is True
1205
023a4e66Stainless Bot2 years ago1206@parametrize
98d779fbStainless Bot2 years ago1207async def test_path_params_cancel(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1208with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1209await async_client.beta.threads.runs.with_raw_response.cancel(
023a4e66Stainless Bot2 years ago1210"string",
1211thread_id="",
1212)
1213
1214with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1215await async_client.beta.threads.runs.with_raw_response.cancel(
023a4e66Stainless Bot2 years ago1216"",
1217thread_id="string",
1218)
1219
baa9f07fRobert Craigie2 years ago1220@parametrize
5429f696Stainless Bot2 years ago1221async def test_method_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago1222run = await async_client.beta.threads.runs.submit_tool_outputs(
baa9f07fRobert Craigie2 years ago1223"string",
1224thread_id="string",
1225tool_outputs=[{}, {}, {}],
1226)
1227assert_matches_type(Run, run, path=["response"])
1228
1229@parametrize
5429f696Stainless Bot2 years ago1230async def test_method_submit_tool_outputs_with_all_params_overload_1(self, async_client: AsyncOpenAI) -> None:
1231run = await async_client.beta.threads.runs.submit_tool_outputs(
1232"string",
1233thread_id="string",
1234tool_outputs=[
1235{
092a8df7Stainless Bot1 years ago1236"output": "output",
1237"tool_call_id": "tool_call_id",
5429f696Stainless Bot2 years ago1238},
1239{
092a8df7Stainless Bot1 years ago1240"output": "output",
1241"tool_call_id": "tool_call_id",
5429f696Stainless Bot2 years ago1242},
1243{
092a8df7Stainless Bot1 years ago1244"output": "output",
1245"tool_call_id": "tool_call_id",
5429f696Stainless Bot2 years ago1246},
1247],
1248stream=False,
1249)
1250assert_matches_type(Run, run, path=["response"])
1251
1252@parametrize
1253async def test_raw_response_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago1254response = await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
baa9f07fRobert Craigie2 years ago1255"string",
1256thread_id="string",
1257tool_outputs=[{}, {}, {}],
1258)
86379b44Stainless Bot2 years ago1259
1260assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1261assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1262run = response.parse()
1263assert_matches_type(Run, run, path=["response"])
86379b44Stainless Bot2 years ago1264
1265@parametrize
5429f696Stainless Bot2 years ago1266async def test_streaming_response_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago1267async with async_client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
86379b44Stainless Bot2 years ago1268"string",
1269thread_id="string",
1270tool_outputs=[{}, {}, {}],
1271) as response:
1272assert not response.is_closed
1273assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1274
1275run = await response.parse()
1276assert_matches_type(Run, run, path=["response"])
1277
1278assert cast(Any, response.is_closed) is True
023a4e66Stainless Bot2 years ago1279
1280@parametrize
5429f696Stainless Bot2 years ago1281async def test_path_params_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
1282with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
1283await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
1284"string",
1285thread_id="",
1286tool_outputs=[{}, {}, {}],
1287)
1288
1289with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
1290await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
1291"",
1292thread_id="string",
1293tool_outputs=[{}, {}, {}],
1294)
1295
1296@parametrize
1297async def test_method_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
1298run_stream = await async_client.beta.threads.runs.submit_tool_outputs(
1299"string",
1300thread_id="string",
1301stream=True,
1302tool_outputs=[{}, {}, {}],
1303)
1304await run_stream.response.aclose()
1305
1306@parametrize
1307async def test_raw_response_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
1308response = await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
1309"string",
1310thread_id="string",
1311stream=True,
1312tool_outputs=[{}, {}, {}],
1313)
1314
1315assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1316stream = response.parse()
1317await stream.close()
1318
1319@parametrize
1320async def test_streaming_response_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
1321async with async_client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
1322"string",
1323thread_id="string",
1324stream=True,
1325tool_outputs=[{}, {}, {}],
1326) as response:
1327assert not response.is_closed
1328assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1329
1330stream = await response.parse()
1331await stream.close()
1332
1333assert cast(Any, response.is_closed) is True
1334
1335@parametrize
1336async def test_path_params_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1337with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1338await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
023a4e66Stainless Bot2 years ago1339"string",
1340thread_id="",
5429f696Stainless Bot2 years ago1341stream=True,
023a4e66Stainless Bot2 years ago1342tool_outputs=[{}, {}, {}],
1343)
1344
1345with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1346await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
023a4e66Stainless Bot2 years ago1347"",
1348thread_id="string",
5429f696Stainless Bot2 years ago1349stream=True,
023a4e66Stainless Bot2 years ago1350tool_outputs=[{}, {}, {}],
1351)