openai/openai-python

Public

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

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

1355lines · 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(
5d3111a8Stainless Bot1 years ago36thread_id="thread_id",
37assistant_id="assistant_id",
38include=["step_details.tool_calls[*].file_search.results[*].content"],
39additional_instructions="additional_instructions",
e2d65bf7Stainless Bot2 years ago40additional_messages=[
41{
79a0b401Stainless Bot2 years ago42"content": "string",
092a8df7Stainless Bot1 years ago43"role": "user",
5b20698dStainless Bot2 years ago44"attachments": [
45{
46"file_id": "string",
f73996b7Stainless Bot2 years ago47"tools": [
48{"type": "code_interpreter"},
49{"type": "code_interpreter"},
50{"type": "code_interpreter"},
51],
5b20698dStainless Bot2 years ago52},
53{
54"file_id": "string",
f73996b7Stainless Bot2 years ago55"tools": [
56{"type": "code_interpreter"},
57{"type": "code_interpreter"},
58{"type": "code_interpreter"},
59],
5b20698dStainless Bot2 years ago60},
61{
62"file_id": "string",
f73996b7Stainless Bot2 years ago63"tools": [
64{"type": "code_interpreter"},
65{"type": "code_interpreter"},
66{"type": "code_interpreter"},
67],
5b20698dStainless Bot2 years ago68},
69],
e2d65bf7Stainless Bot2 years ago70"metadata": {},
71},
72{
79a0b401Stainless Bot2 years ago73"content": "string",
092a8df7Stainless Bot1 years ago74"role": "user",
5b20698dStainless Bot2 years ago75"attachments": [
76{
77"file_id": "string",
f73996b7Stainless Bot2 years ago78"tools": [
79{"type": "code_interpreter"},
80{"type": "code_interpreter"},
81{"type": "code_interpreter"},
82],
5b20698dStainless Bot2 years ago83},
84{
85"file_id": "string",
f73996b7Stainless Bot2 years ago86"tools": [
87{"type": "code_interpreter"},
88{"type": "code_interpreter"},
89{"type": "code_interpreter"},
90],
5b20698dStainless Bot2 years ago91},
92{
93"file_id": "string",
f73996b7Stainless Bot2 years ago94"tools": [
95{"type": "code_interpreter"},
96{"type": "code_interpreter"},
97{"type": "code_interpreter"},
98],
5b20698dStainless Bot2 years ago99},
100],
e2d65bf7Stainless Bot2 years ago101"metadata": {},
102},
103{
79a0b401Stainless Bot2 years ago104"content": "string",
092a8df7Stainless Bot1 years ago105"role": "user",
5b20698dStainless Bot2 years ago106"attachments": [
107{
108"file_id": "string",
f73996b7Stainless Bot2 years ago109"tools": [
110{"type": "code_interpreter"},
111{"type": "code_interpreter"},
112{"type": "code_interpreter"},
113],
5b20698dStainless Bot2 years ago114},
115{
116"file_id": "string",
f73996b7Stainless Bot2 years ago117"tools": [
118{"type": "code_interpreter"},
119{"type": "code_interpreter"},
120{"type": "code_interpreter"},
121],
5b20698dStainless Bot2 years ago122},
123{
124"file_id": "string",
f73996b7Stainless Bot2 years ago125"tools": [
126{"type": "code_interpreter"},
127{"type": "code_interpreter"},
128{"type": "code_interpreter"},
129],
5b20698dStainless Bot2 years ago130},
131],
e2d65bf7Stainless Bot2 years ago132"metadata": {},
133},
134],
baa9f07fRobert Craigie2 years ago135instructions="string",
f5247e30Stainless Bot2 years ago136max_completion_tokens=256,
137max_prompt_tokens=256,
baa9f07fRobert Craigie2 years ago138metadata={},
bf1ca86cRobert Craigie1 years ago139model="gpt-4o",
7399ffc8Stainless Bot2 years ago140parallel_tool_calls=True,
bf1ca86cRobert Craigie1 years ago141response_format="auto",
5429f696Stainless Bot2 years ago142stream=False,
27a4626aStainless Bot2 years ago143temperature=1,
f5247e30Stainless Bot2 years ago144tool_choice="none",
baa9f07fRobert Craigie2 years ago145tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago146top_p=1,
f5247e30Stainless Bot2 years ago147truncation_strategy={
148"type": "auto",
149"last_messages": 1,
150},
baa9f07fRobert Craigie2 years ago151)
152assert_matches_type(Run, run, path=["response"])
153
154@parametrize
5429f696Stainless Bot2 years ago155def test_raw_response_create_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago156response = client.beta.threads.runs.with_raw_response.create(
157"string",
158assistant_id="string",
159)
86379b44Stainless Bot2 years ago160
161assert response.is_closed is True
baa9f07fRobert Craigie2 years ago162assert response.http_request.headers.get("X-Stainless-Lang") == "python"
163run = response.parse()
164assert_matches_type(Run, run, path=["response"])
165
86379b44Stainless Bot2 years ago166@parametrize
5429f696Stainless Bot2 years ago167def test_streaming_response_create_overload_1(self, client: OpenAI) -> None:
86379b44Stainless Bot2 years ago168with client.beta.threads.runs.with_streaming_response.create(
169"string",
170assistant_id="string",
171) as response:
172assert not response.is_closed
173assert response.http_request.headers.get("X-Stainless-Lang") == "python"
174
175run = response.parse()
176assert_matches_type(Run, run, path=["response"])
177
178assert cast(Any, response.is_closed) is True
179
023a4e66Stainless Bot2 years ago180@parametrize
5429f696Stainless Bot2 years ago181def test_path_params_create_overload_1(self, client: OpenAI) -> None:
023a4e66Stainless Bot2 years ago182with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
183client.beta.threads.runs.with_raw_response.create(
184"",
185assistant_id="string",
186)
187
5429f696Stainless Bot2 years ago188@parametrize
189def test_method_create_overload_2(self, client: OpenAI) -> None:
190run_stream = client.beta.threads.runs.create(
191"string",
192assistant_id="string",
193stream=True,
194)
195run_stream.response.close()
196
197@parametrize
198def test_method_create_with_all_params_overload_2(self, client: OpenAI) -> None:
199run_stream = client.beta.threads.runs.create(
200"string",
201assistant_id="string",
202stream=True,
5d3111a8Stainless Bot1 years ago203include=["step_details.tool_calls[*].file_search.results[*].content"],
204additional_instructions="additional_instructions",
e2d65bf7Stainless Bot2 years ago205additional_messages=[
206{
79a0b401Stainless Bot2 years ago207"content": "string",
092a8df7Stainless Bot1 years ago208"role": "user",
5b20698dStainless Bot2 years ago209"attachments": [
210{
211"file_id": "string",
f73996b7Stainless Bot2 years ago212"tools": [
213{"type": "code_interpreter"},
214{"type": "code_interpreter"},
215{"type": "code_interpreter"},
216],
5b20698dStainless Bot2 years ago217},
218{
219"file_id": "string",
f73996b7Stainless Bot2 years ago220"tools": [
221{"type": "code_interpreter"},
222{"type": "code_interpreter"},
223{"type": "code_interpreter"},
224],
5b20698dStainless Bot2 years ago225},
226{
227"file_id": "string",
f73996b7Stainless Bot2 years ago228"tools": [
229{"type": "code_interpreter"},
230{"type": "code_interpreter"},
231{"type": "code_interpreter"},
232],
5b20698dStainless Bot2 years ago233},
234],
e2d65bf7Stainless Bot2 years ago235"metadata": {},
236},
237{
79a0b401Stainless Bot2 years ago238"content": "string",
092a8df7Stainless Bot1 years ago239"role": "user",
5b20698dStainless Bot2 years ago240"attachments": [
241{
242"file_id": "string",
f73996b7Stainless Bot2 years ago243"tools": [
244{"type": "code_interpreter"},
245{"type": "code_interpreter"},
246{"type": "code_interpreter"},
247],
5b20698dStainless Bot2 years ago248},
249{
250"file_id": "string",
f73996b7Stainless Bot2 years ago251"tools": [
252{"type": "code_interpreter"},
253{"type": "code_interpreter"},
254{"type": "code_interpreter"},
255],
5b20698dStainless Bot2 years ago256},
257{
258"file_id": "string",
f73996b7Stainless Bot2 years ago259"tools": [
260{"type": "code_interpreter"},
261{"type": "code_interpreter"},
262{"type": "code_interpreter"},
263],
5b20698dStainless Bot2 years ago264},
265],
e2d65bf7Stainless Bot2 years ago266"metadata": {},
267},
268{
79a0b401Stainless Bot2 years ago269"content": "string",
092a8df7Stainless Bot1 years ago270"role": "user",
5b20698dStainless Bot2 years ago271"attachments": [
272{
273"file_id": "string",
f73996b7Stainless Bot2 years ago274"tools": [
275{"type": "code_interpreter"},
276{"type": "code_interpreter"},
277{"type": "code_interpreter"},
278],
5b20698dStainless Bot2 years ago279},
280{
281"file_id": "string",
f73996b7Stainless Bot2 years ago282"tools": [
283{"type": "code_interpreter"},
284{"type": "code_interpreter"},
285{"type": "code_interpreter"},
286],
5b20698dStainless Bot2 years ago287},
288{
289"file_id": "string",
f73996b7Stainless Bot2 years ago290"tools": [
291{"type": "code_interpreter"},
292{"type": "code_interpreter"},
293{"type": "code_interpreter"},
294],
5b20698dStainless Bot2 years ago295},
296],
e2d65bf7Stainless Bot2 years ago297"metadata": {},
298},
299],
5429f696Stainless Bot2 years ago300instructions="string",
f5247e30Stainless Bot2 years ago301max_completion_tokens=256,
302max_prompt_tokens=256,
5429f696Stainless Bot2 years ago303metadata={},
bf1ca86cRobert Craigie1 years ago304model="gpt-4o",
7399ffc8Stainless Bot2 years ago305parallel_tool_calls=True,
bf1ca86cRobert Craigie1 years ago306response_format="auto",
27a4626aStainless Bot2 years ago307temperature=1,
f5247e30Stainless Bot2 years ago308tool_choice="none",
5429f696Stainless Bot2 years ago309tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago310top_p=1,
f5247e30Stainless Bot2 years ago311truncation_strategy={
312"type": "auto",
313"last_messages": 1,
314},
5429f696Stainless Bot2 years ago315)
316run_stream.response.close()
317
318@parametrize
319def test_raw_response_create_overload_2(self, client: OpenAI) -> None:
320response = client.beta.threads.runs.with_raw_response.create(
321"string",
322assistant_id="string",
323stream=True,
324)
325
326assert response.http_request.headers.get("X-Stainless-Lang") == "python"
327stream = response.parse()
328stream.close()
329
330@parametrize
331def test_streaming_response_create_overload_2(self, client: OpenAI) -> None:
332with client.beta.threads.runs.with_streaming_response.create(
333"string",
334assistant_id="string",
335stream=True,
336) as response:
337assert not response.is_closed
338assert response.http_request.headers.get("X-Stainless-Lang") == "python"
339
340stream = response.parse()
341stream.close()
342
343assert cast(Any, response.is_closed) is True
344
345@parametrize
346def test_path_params_create_overload_2(self, client: OpenAI) -> None:
347with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
348client.beta.threads.runs.with_raw_response.create(
349"",
350assistant_id="string",
351stream=True,
352)
353
baa9f07fRobert Craigie2 years ago354@parametrize
355def test_method_retrieve(self, client: OpenAI) -> None:
356run = client.beta.threads.runs.retrieve(
357"string",
358thread_id="string",
359)
360assert_matches_type(Run, run, path=["response"])
361
362@parametrize
363def test_raw_response_retrieve(self, client: OpenAI) -> None:
364response = client.beta.threads.runs.with_raw_response.retrieve(
365"string",
366thread_id="string",
367)
86379b44Stainless Bot2 years ago368
369assert response.is_closed is True
baa9f07fRobert Craigie2 years ago370assert response.http_request.headers.get("X-Stainless-Lang") == "python"
371run = response.parse()
372assert_matches_type(Run, run, path=["response"])
373
86379b44Stainless Bot2 years ago374@parametrize
375def test_streaming_response_retrieve(self, client: OpenAI) -> None:
376with client.beta.threads.runs.with_streaming_response.retrieve(
377"string",
378thread_id="string",
379) as response:
380assert not response.is_closed
381assert response.http_request.headers.get("X-Stainless-Lang") == "python"
382
383run = response.parse()
384assert_matches_type(Run, run, path=["response"])
385
386assert cast(Any, response.is_closed) is True
387
023a4e66Stainless Bot2 years ago388@parametrize
389def test_path_params_retrieve(self, client: OpenAI) -> None:
390with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
391client.beta.threads.runs.with_raw_response.retrieve(
392"string",
393thread_id="",
394)
395
396with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
397client.beta.threads.runs.with_raw_response.retrieve(
398"",
399thread_id="string",
400)
401
baa9f07fRobert Craigie2 years ago402@parametrize
403def test_method_update(self, client: OpenAI) -> None:
404run = client.beta.threads.runs.update(
405"string",
406thread_id="string",
407)
408assert_matches_type(Run, run, path=["response"])
409
410@parametrize
411def test_method_update_with_all_params(self, client: OpenAI) -> None:
412run = client.beta.threads.runs.update(
413"string",
414thread_id="string",
415metadata={},
416)
417assert_matches_type(Run, run, path=["response"])
418
419@parametrize
420def test_raw_response_update(self, client: OpenAI) -> None:
421response = client.beta.threads.runs.with_raw_response.update(
422"string",
423thread_id="string",
424)
86379b44Stainless Bot2 years ago425
426assert response.is_closed is True
baa9f07fRobert Craigie2 years ago427assert response.http_request.headers.get("X-Stainless-Lang") == "python"
428run = response.parse()
429assert_matches_type(Run, run, path=["response"])
430
86379b44Stainless Bot2 years ago431@parametrize
432def test_streaming_response_update(self, client: OpenAI) -> None:
433with client.beta.threads.runs.with_streaming_response.update(
434"string",
435thread_id="string",
436) as response:
437assert not response.is_closed
438assert response.http_request.headers.get("X-Stainless-Lang") == "python"
439
440run = response.parse()
441assert_matches_type(Run, run, path=["response"])
442
443assert cast(Any, response.is_closed) is True
444
023a4e66Stainless Bot2 years ago445@parametrize
446def test_path_params_update(self, client: OpenAI) -> None:
447with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
448client.beta.threads.runs.with_raw_response.update(
449"string",
450thread_id="",
451)
452
453with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
454client.beta.threads.runs.with_raw_response.update(
455"",
456thread_id="string",
457)
458
baa9f07fRobert Craigie2 years ago459@parametrize
460def test_method_list(self, client: OpenAI) -> None:
461run = client.beta.threads.runs.list(
462"string",
463)
464assert_matches_type(SyncCursorPage[Run], run, path=["response"])
465
466@parametrize
467def test_method_list_with_all_params(self, client: OpenAI) -> None:
468run = client.beta.threads.runs.list(
469"string",
470after="string",
471before="string",
472limit=0,
473order="asc",
474)
475assert_matches_type(SyncCursorPage[Run], run, path=["response"])
476
477@parametrize
478def test_raw_response_list(self, client: OpenAI) -> None:
479response = client.beta.threads.runs.with_raw_response.list(
480"string",
481)
86379b44Stainless Bot2 years ago482
483assert response.is_closed is True
baa9f07fRobert Craigie2 years ago484assert response.http_request.headers.get("X-Stainless-Lang") == "python"
485run = response.parse()
486assert_matches_type(SyncCursorPage[Run], run, path=["response"])
487
86379b44Stainless Bot2 years ago488@parametrize
489def test_streaming_response_list(self, client: OpenAI) -> None:
490with client.beta.threads.runs.with_streaming_response.list(
491"string",
492) as response:
493assert not response.is_closed
494assert response.http_request.headers.get("X-Stainless-Lang") == "python"
495
496run = response.parse()
497assert_matches_type(SyncCursorPage[Run], run, path=["response"])
498
499assert cast(Any, response.is_closed) is True
500
023a4e66Stainless Bot2 years ago501@parametrize
502def test_path_params_list(self, client: OpenAI) -> None:
503with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
504client.beta.threads.runs.with_raw_response.list(
505"",
506)
507
baa9f07fRobert Craigie2 years ago508@parametrize
509def test_method_cancel(self, client: OpenAI) -> None:
510run = client.beta.threads.runs.cancel(
511"string",
512thread_id="string",
513)
514assert_matches_type(Run, run, path=["response"])
515
516@parametrize
517def test_raw_response_cancel(self, client: OpenAI) -> None:
518response = client.beta.threads.runs.with_raw_response.cancel(
519"string",
520thread_id="string",
521)
86379b44Stainless Bot2 years ago522
523assert response.is_closed is True
baa9f07fRobert Craigie2 years ago524assert response.http_request.headers.get("X-Stainless-Lang") == "python"
525run = response.parse()
526assert_matches_type(Run, run, path=["response"])
527
86379b44Stainless Bot2 years ago528@parametrize
529def test_streaming_response_cancel(self, client: OpenAI) -> None:
530with client.beta.threads.runs.with_streaming_response.cancel(
531"string",
532thread_id="string",
533) as response:
534assert not response.is_closed
535assert response.http_request.headers.get("X-Stainless-Lang") == "python"
536
537run = response.parse()
538assert_matches_type(Run, run, path=["response"])
539
540assert cast(Any, response.is_closed) is True
541
023a4e66Stainless Bot2 years ago542@parametrize
543def test_path_params_cancel(self, client: OpenAI) -> None:
544with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
545client.beta.threads.runs.with_raw_response.cancel(
546"string",
547thread_id="",
548)
549
550with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
551client.beta.threads.runs.with_raw_response.cancel(
552"",
553thread_id="string",
554)
555
baa9f07fRobert Craigie2 years ago556@parametrize
5429f696Stainless Bot2 years ago557def test_method_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago558run = client.beta.threads.runs.submit_tool_outputs(
559"string",
560thread_id="string",
561tool_outputs=[{}, {}, {}],
562)
563assert_matches_type(Run, run, path=["response"])
564
565@parametrize
5429f696Stainless Bot2 years ago566def test_method_submit_tool_outputs_with_all_params_overload_1(self, client: OpenAI) -> None:
567run = client.beta.threads.runs.submit_tool_outputs(
568"string",
569thread_id="string",
570tool_outputs=[
571{
092a8df7Stainless Bot1 years ago572"output": "output",
573"tool_call_id": "tool_call_id",
5429f696Stainless Bot2 years ago574},
575{
092a8df7Stainless Bot1 years ago576"output": "output",
577"tool_call_id": "tool_call_id",
5429f696Stainless Bot2 years ago578},
579{
092a8df7Stainless Bot1 years ago580"output": "output",
581"tool_call_id": "tool_call_id",
5429f696Stainless Bot2 years ago582},
583],
584stream=False,
585)
586assert_matches_type(Run, run, path=["response"])
587
588@parametrize
589def test_raw_response_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago590response = client.beta.threads.runs.with_raw_response.submit_tool_outputs(
591"string",
592thread_id="string",
593tool_outputs=[{}, {}, {}],
594)
86379b44Stainless Bot2 years ago595
596assert response.is_closed is True
baa9f07fRobert Craigie2 years ago597assert response.http_request.headers.get("X-Stainless-Lang") == "python"
598run = response.parse()
599assert_matches_type(Run, run, path=["response"])
600
86379b44Stainless Bot2 years ago601@parametrize
5429f696Stainless Bot2 years ago602def test_streaming_response_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
86379b44Stainless Bot2 years ago603with client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
604"string",
605thread_id="string",
606tool_outputs=[{}, {}, {}],
607) as response:
608assert not response.is_closed
609assert response.http_request.headers.get("X-Stainless-Lang") == "python"
610
611run = response.parse()
612assert_matches_type(Run, run, path=["response"])
613
614assert cast(Any, response.is_closed) is True
615
023a4e66Stainless Bot2 years ago616@parametrize
5429f696Stainless Bot2 years ago617def test_path_params_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
618with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
619client.beta.threads.runs.with_raw_response.submit_tool_outputs(
620"string",
621thread_id="",
622tool_outputs=[{}, {}, {}],
623)
624
625with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
626client.beta.threads.runs.with_raw_response.submit_tool_outputs(
627"",
628thread_id="string",
629tool_outputs=[{}, {}, {}],
630)
631
632@parametrize
633def test_method_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
634run_stream = client.beta.threads.runs.submit_tool_outputs(
635"string",
636thread_id="string",
637stream=True,
638tool_outputs=[{}, {}, {}],
639)
640run_stream.response.close()
641
642@parametrize
643def test_raw_response_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
644response = client.beta.threads.runs.with_raw_response.submit_tool_outputs(
645"string",
646thread_id="string",
647stream=True,
648tool_outputs=[{}, {}, {}],
649)
650
651assert response.http_request.headers.get("X-Stainless-Lang") == "python"
652stream = response.parse()
653stream.close()
654
655@parametrize
656def test_streaming_response_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
657with client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
658"string",
659thread_id="string",
660stream=True,
661tool_outputs=[{}, {}, {}],
662) as response:
663assert not response.is_closed
664assert response.http_request.headers.get("X-Stainless-Lang") == "python"
665
666stream = response.parse()
667stream.close()
668
669assert cast(Any, response.is_closed) is True
670
671@parametrize
672def test_path_params_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
023a4e66Stainless Bot2 years ago673with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
674client.beta.threads.runs.with_raw_response.submit_tool_outputs(
675"string",
676thread_id="",
5429f696Stainless Bot2 years ago677stream=True,
023a4e66Stainless Bot2 years ago678tool_outputs=[{}, {}, {}],
679)
680
681with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
682client.beta.threads.runs.with_raw_response.submit_tool_outputs(
683"",
684thread_id="string",
5429f696Stainless Bot2 years ago685stream=True,
023a4e66Stainless Bot2 years ago686tool_outputs=[{}, {}, {}],
687)
688
baa9f07fRobert Craigie2 years ago689
690class TestAsyncRuns:
98d779fbStainless Bot2 years ago691parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
baa9f07fRobert Craigie2 years ago692
693@parametrize
5429f696Stainless Bot2 years ago694async def test_method_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago695run = await async_client.beta.threads.runs.create(
baa9f07fRobert Craigie2 years ago696"string",
697assistant_id="string",
698)
699assert_matches_type(Run, run, path=["response"])
700
701@parametrize
5429f696Stainless Bot2 years ago702async def test_method_create_with_all_params_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago703run = await async_client.beta.threads.runs.create(
5d3111a8Stainless Bot1 years ago704thread_id="thread_id",
705assistant_id="assistant_id",
706include=["step_details.tool_calls[*].file_search.results[*].content"],
707additional_instructions="additional_instructions",
e2d65bf7Stainless Bot2 years ago708additional_messages=[
709{
79a0b401Stainless Bot2 years ago710"content": "string",
092a8df7Stainless Bot1 years ago711"role": "user",
5b20698dStainless Bot2 years ago712"attachments": [
713{
714"file_id": "string",
f73996b7Stainless Bot2 years ago715"tools": [
716{"type": "code_interpreter"},
717{"type": "code_interpreter"},
718{"type": "code_interpreter"},
719],
5b20698dStainless Bot2 years ago720},
721{
722"file_id": "string",
f73996b7Stainless Bot2 years ago723"tools": [
724{"type": "code_interpreter"},
725{"type": "code_interpreter"},
726{"type": "code_interpreter"},
727],
5b20698dStainless Bot2 years ago728},
729{
730"file_id": "string",
f73996b7Stainless Bot2 years ago731"tools": [
732{"type": "code_interpreter"},
733{"type": "code_interpreter"},
734{"type": "code_interpreter"},
735],
5b20698dStainless Bot2 years ago736},
737],
e2d65bf7Stainless Bot2 years ago738"metadata": {},
739},
740{
79a0b401Stainless Bot2 years ago741"content": "string",
092a8df7Stainless Bot1 years ago742"role": "user",
5b20698dStainless Bot2 years ago743"attachments": [
744{
745"file_id": "string",
f73996b7Stainless Bot2 years ago746"tools": [
747{"type": "code_interpreter"},
748{"type": "code_interpreter"},
749{"type": "code_interpreter"},
750],
5b20698dStainless Bot2 years ago751},
752{
753"file_id": "string",
f73996b7Stainless Bot2 years ago754"tools": [
755{"type": "code_interpreter"},
756{"type": "code_interpreter"},
757{"type": "code_interpreter"},
758],
5b20698dStainless Bot2 years ago759},
760{
761"file_id": "string",
f73996b7Stainless Bot2 years ago762"tools": [
763{"type": "code_interpreter"},
764{"type": "code_interpreter"},
765{"type": "code_interpreter"},
766],
5b20698dStainless Bot2 years ago767},
768],
e2d65bf7Stainless Bot2 years ago769"metadata": {},
770},
771{
79a0b401Stainless Bot2 years ago772"content": "string",
092a8df7Stainless Bot1 years ago773"role": "user",
5b20698dStainless Bot2 years ago774"attachments": [
775{
776"file_id": "string",
f73996b7Stainless Bot2 years ago777"tools": [
778{"type": "code_interpreter"},
779{"type": "code_interpreter"},
780{"type": "code_interpreter"},
781],
5b20698dStainless Bot2 years ago782},
783{
784"file_id": "string",
f73996b7Stainless Bot2 years ago785"tools": [
786{"type": "code_interpreter"},
787{"type": "code_interpreter"},
788{"type": "code_interpreter"},
789],
5b20698dStainless Bot2 years ago790},
791{
792"file_id": "string",
f73996b7Stainless Bot2 years ago793"tools": [
794{"type": "code_interpreter"},
795{"type": "code_interpreter"},
796{"type": "code_interpreter"},
797],
5b20698dStainless Bot2 years ago798},
799],
e2d65bf7Stainless Bot2 years ago800"metadata": {},
801},
802],
baa9f07fRobert Craigie2 years ago803instructions="string",
f5247e30Stainless Bot2 years ago804max_completion_tokens=256,
805max_prompt_tokens=256,
baa9f07fRobert Craigie2 years ago806metadata={},
bf1ca86cRobert Craigie1 years ago807model="gpt-4o",
7399ffc8Stainless Bot2 years ago808parallel_tool_calls=True,
bf1ca86cRobert Craigie1 years ago809response_format="auto",
5429f696Stainless Bot2 years ago810stream=False,
27a4626aStainless Bot2 years ago811temperature=1,
f5247e30Stainless Bot2 years ago812tool_choice="none",
baa9f07fRobert Craigie2 years ago813tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago814top_p=1,
f5247e30Stainless Bot2 years ago815truncation_strategy={
816"type": "auto",
817"last_messages": 1,
818},
baa9f07fRobert Craigie2 years ago819)
820assert_matches_type(Run, run, path=["response"])
821
822@parametrize
5429f696Stainless Bot2 years ago823async def test_raw_response_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago824response = await async_client.beta.threads.runs.with_raw_response.create(
baa9f07fRobert Craigie2 years ago825"string",
826assistant_id="string",
827)
86379b44Stainless Bot2 years ago828
829assert response.is_closed is True
baa9f07fRobert Craigie2 years ago830assert response.http_request.headers.get("X-Stainless-Lang") == "python"
831run = response.parse()
832assert_matches_type(Run, run, path=["response"])
833
86379b44Stainless Bot2 years ago834@parametrize
5429f696Stainless Bot2 years ago835async def test_streaming_response_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago836async with async_client.beta.threads.runs.with_streaming_response.create(
86379b44Stainless Bot2 years ago837"string",
838assistant_id="string",
839) as response:
840assert not response.is_closed
841assert response.http_request.headers.get("X-Stainless-Lang") == "python"
842
843run = await response.parse()
844assert_matches_type(Run, run, path=["response"])
845
846assert cast(Any, response.is_closed) is True
847
023a4e66Stainless Bot2 years ago848@parametrize
5429f696Stainless Bot2 years ago849async def test_path_params_create_overload_1(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago850with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago851await async_client.beta.threads.runs.with_raw_response.create(
023a4e66Stainless Bot2 years ago852"",
853assistant_id="string",
854)
855
5429f696Stainless Bot2 years ago856@parametrize
857async def test_method_create_overload_2(self, async_client: AsyncOpenAI) -> None:
858run_stream = await async_client.beta.threads.runs.create(
859"string",
860assistant_id="string",
861stream=True,
862)
863await run_stream.response.aclose()
864
865@parametrize
866async def test_method_create_with_all_params_overload_2(self, async_client: AsyncOpenAI) -> None:
867run_stream = await async_client.beta.threads.runs.create(
868"string",
869assistant_id="string",
870stream=True,
5d3111a8Stainless Bot1 years ago871include=["step_details.tool_calls[*].file_search.results[*].content"],
872additional_instructions="additional_instructions",
e2d65bf7Stainless Bot2 years ago873additional_messages=[
874{
79a0b401Stainless Bot2 years ago875"content": "string",
092a8df7Stainless Bot1 years ago876"role": "user",
5b20698dStainless Bot2 years ago877"attachments": [
878{
879"file_id": "string",
f73996b7Stainless Bot2 years ago880"tools": [
881{"type": "code_interpreter"},
882{"type": "code_interpreter"},
883{"type": "code_interpreter"},
884],
5b20698dStainless Bot2 years ago885},
886{
887"file_id": "string",
f73996b7Stainless Bot2 years ago888"tools": [
889{"type": "code_interpreter"},
890{"type": "code_interpreter"},
891{"type": "code_interpreter"},
892],
5b20698dStainless Bot2 years ago893},
894{
895"file_id": "string",
f73996b7Stainless Bot2 years ago896"tools": [
897{"type": "code_interpreter"},
898{"type": "code_interpreter"},
899{"type": "code_interpreter"},
900],
5b20698dStainless Bot2 years ago901},
902],
e2d65bf7Stainless Bot2 years ago903"metadata": {},
904},
905{
79a0b401Stainless Bot2 years ago906"content": "string",
092a8df7Stainless Bot1 years ago907"role": "user",
5b20698dStainless Bot2 years ago908"attachments": [
909{
910"file_id": "string",
f73996b7Stainless Bot2 years ago911"tools": [
912{"type": "code_interpreter"},
913{"type": "code_interpreter"},
914{"type": "code_interpreter"},
915],
5b20698dStainless Bot2 years ago916},
917{
918"file_id": "string",
f73996b7Stainless Bot2 years ago919"tools": [
920{"type": "code_interpreter"},
921{"type": "code_interpreter"},
922{"type": "code_interpreter"},
923],
5b20698dStainless Bot2 years ago924},
925{
926"file_id": "string",
f73996b7Stainless Bot2 years ago927"tools": [
928{"type": "code_interpreter"},
929{"type": "code_interpreter"},
930{"type": "code_interpreter"},
931],
5b20698dStainless Bot2 years ago932},
933],
e2d65bf7Stainless Bot2 years ago934"metadata": {},
935},
936{
79a0b401Stainless Bot2 years ago937"content": "string",
092a8df7Stainless Bot1 years ago938"role": "user",
5b20698dStainless Bot2 years ago939"attachments": [
940{
941"file_id": "string",
f73996b7Stainless Bot2 years ago942"tools": [
943{"type": "code_interpreter"},
944{"type": "code_interpreter"},
945{"type": "code_interpreter"},
946],
5b20698dStainless Bot2 years ago947},
948{
949"file_id": "string",
f73996b7Stainless Bot2 years ago950"tools": [
951{"type": "code_interpreter"},
952{"type": "code_interpreter"},
953{"type": "code_interpreter"},
954],
5b20698dStainless Bot2 years ago955},
956{
957"file_id": "string",
f73996b7Stainless Bot2 years ago958"tools": [
959{"type": "code_interpreter"},
960{"type": "code_interpreter"},
961{"type": "code_interpreter"},
962],
5b20698dStainless Bot2 years ago963},
964],
e2d65bf7Stainless Bot2 years ago965"metadata": {},
966},
967],
5429f696Stainless Bot2 years ago968instructions="string",
f5247e30Stainless Bot2 years ago969max_completion_tokens=256,
970max_prompt_tokens=256,
5429f696Stainless Bot2 years ago971metadata={},
bf1ca86cRobert Craigie1 years ago972model="gpt-4o",
7399ffc8Stainless Bot2 years ago973parallel_tool_calls=True,
bf1ca86cRobert Craigie1 years ago974response_format="auto",
27a4626aStainless Bot2 years ago975temperature=1,
f5247e30Stainless Bot2 years ago976tool_choice="none",
5429f696Stainless Bot2 years ago977tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago978top_p=1,
f5247e30Stainless Bot2 years ago979truncation_strategy={
980"type": "auto",
981"last_messages": 1,
982},
5429f696Stainless Bot2 years ago983)
984await run_stream.response.aclose()
985
986@parametrize
987async def test_raw_response_create_overload_2(self, async_client: AsyncOpenAI) -> None:
988response = await async_client.beta.threads.runs.with_raw_response.create(
989"string",
990assistant_id="string",
991stream=True,
992)
993
994assert response.http_request.headers.get("X-Stainless-Lang") == "python"
995stream = response.parse()
996await stream.close()
997
998@parametrize
999async def test_streaming_response_create_overload_2(self, async_client: AsyncOpenAI) -> None:
1000async with async_client.beta.threads.runs.with_streaming_response.create(
1001"string",
1002assistant_id="string",
1003stream=True,
1004) as response:
1005assert not response.is_closed
1006assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1007
1008stream = await response.parse()
1009await stream.close()
1010
1011assert cast(Any, response.is_closed) is True
1012
1013@parametrize
1014async def test_path_params_create_overload_2(self, async_client: AsyncOpenAI) -> None:
1015with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
1016await async_client.beta.threads.runs.with_raw_response.create(
1017"",
1018assistant_id="string",
1019stream=True,
1020)
1021
baa9f07fRobert Craigie2 years ago1022@parametrize
98d779fbStainless Bot2 years ago1023async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None:
1024run = await async_client.beta.threads.runs.retrieve(
baa9f07fRobert Craigie2 years ago1025"string",
1026thread_id="string",
1027)
1028assert_matches_type(Run, run, path=["response"])
1029
1030@parametrize
98d779fbStainless Bot2 years ago1031async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None:
1032response = await async_client.beta.threads.runs.with_raw_response.retrieve(
baa9f07fRobert Craigie2 years ago1033"string",
1034thread_id="string",
1035)
86379b44Stainless Bot2 years ago1036
1037assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1038assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1039run = response.parse()
1040assert_matches_type(Run, run, path=["response"])
1041
86379b44Stainless Bot2 years ago1042@parametrize
98d779fbStainless Bot2 years ago1043async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None:
1044async with async_client.beta.threads.runs.with_streaming_response.retrieve(
86379b44Stainless Bot2 years ago1045"string",
1046thread_id="string",
1047) as response:
1048assert not response.is_closed
1049assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1050
1051run = await response.parse()
1052assert_matches_type(Run, run, path=["response"])
1053
1054assert cast(Any, response.is_closed) is True
1055
023a4e66Stainless Bot2 years ago1056@parametrize
98d779fbStainless Bot2 years ago1057async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1058with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1059await async_client.beta.threads.runs.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago1060"string",
1061thread_id="",
1062)
1063
1064with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1065await async_client.beta.threads.runs.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago1066"",
1067thread_id="string",
1068)
1069
baa9f07fRobert Craigie2 years ago1070@parametrize
98d779fbStainless Bot2 years ago1071async def test_method_update(self, async_client: AsyncOpenAI) -> None:
1072run = await async_client.beta.threads.runs.update(
baa9f07fRobert Craigie2 years ago1073"string",
1074thread_id="string",
1075)
1076assert_matches_type(Run, run, path=["response"])
1077
1078@parametrize
98d779fbStainless Bot2 years ago1079async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None:
1080run = await async_client.beta.threads.runs.update(
baa9f07fRobert Craigie2 years ago1081"string",
1082thread_id="string",
1083metadata={},
1084)
1085assert_matches_type(Run, run, path=["response"])
1086
1087@parametrize
98d779fbStainless Bot2 years ago1088async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None:
1089response = await async_client.beta.threads.runs.with_raw_response.update(
baa9f07fRobert Craigie2 years ago1090"string",
1091thread_id="string",
1092)
86379b44Stainless Bot2 years ago1093
1094assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1095assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1096run = response.parse()
1097assert_matches_type(Run, run, path=["response"])
1098
86379b44Stainless Bot2 years ago1099@parametrize
98d779fbStainless Bot2 years ago1100async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None:
1101async with async_client.beta.threads.runs.with_streaming_response.update(
86379b44Stainless Bot2 years ago1102"string",
1103thread_id="string",
1104) as response:
1105assert not response.is_closed
1106assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1107
1108run = await response.parse()
1109assert_matches_type(Run, run, path=["response"])
1110
1111assert cast(Any, response.is_closed) is True
1112
023a4e66Stainless Bot2 years ago1113@parametrize
98d779fbStainless Bot2 years ago1114async def test_path_params_update(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1115with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1116await async_client.beta.threads.runs.with_raw_response.update(
023a4e66Stainless Bot2 years ago1117"string",
1118thread_id="",
1119)
1120
1121with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1122await async_client.beta.threads.runs.with_raw_response.update(
023a4e66Stainless Bot2 years ago1123"",
1124thread_id="string",
1125)
1126
baa9f07fRobert Craigie2 years ago1127@parametrize
98d779fbStainless Bot2 years ago1128async def test_method_list(self, async_client: AsyncOpenAI) -> None:
1129run = await async_client.beta.threads.runs.list(
baa9f07fRobert Craigie2 years ago1130"string",
1131)
1132assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1133
1134@parametrize
98d779fbStainless Bot2 years ago1135async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None:
1136run = await async_client.beta.threads.runs.list(
baa9f07fRobert Craigie2 years ago1137"string",
1138after="string",
1139before="string",
1140limit=0,
1141order="asc",
1142)
1143assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1144
1145@parametrize
98d779fbStainless Bot2 years ago1146async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None:
1147response = await async_client.beta.threads.runs.with_raw_response.list(
baa9f07fRobert Craigie2 years ago1148"string",
1149)
86379b44Stainless Bot2 years ago1150
1151assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1152assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1153run = response.parse()
1154assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1155
86379b44Stainless Bot2 years ago1156@parametrize
98d779fbStainless Bot2 years ago1157async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None:
1158async with async_client.beta.threads.runs.with_streaming_response.list(
86379b44Stainless Bot2 years ago1159"string",
1160) as response:
1161assert not response.is_closed
1162assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1163
1164run = await response.parse()
1165assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
1166
1167assert cast(Any, response.is_closed) is True
1168
023a4e66Stainless Bot2 years ago1169@parametrize
98d779fbStainless Bot2 years ago1170async def test_path_params_list(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1171with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1172await async_client.beta.threads.runs.with_raw_response.list(
023a4e66Stainless Bot2 years ago1173"",
1174)
1175
baa9f07fRobert Craigie2 years ago1176@parametrize
98d779fbStainless Bot2 years ago1177async def test_method_cancel(self, async_client: AsyncOpenAI) -> None:
1178run = await async_client.beta.threads.runs.cancel(
baa9f07fRobert Craigie2 years ago1179"string",
1180thread_id="string",
1181)
1182assert_matches_type(Run, run, path=["response"])
1183
1184@parametrize
98d779fbStainless Bot2 years ago1185async def test_raw_response_cancel(self, async_client: AsyncOpenAI) -> None:
1186response = await async_client.beta.threads.runs.with_raw_response.cancel(
baa9f07fRobert Craigie2 years ago1187"string",
1188thread_id="string",
1189)
86379b44Stainless Bot2 years ago1190
1191assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1192assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1193run = response.parse()
1194assert_matches_type(Run, run, path=["response"])
1195
86379b44Stainless Bot2 years ago1196@parametrize
98d779fbStainless Bot2 years ago1197async def test_streaming_response_cancel(self, async_client: AsyncOpenAI) -> None:
1198async with async_client.beta.threads.runs.with_streaming_response.cancel(
86379b44Stainless Bot2 years ago1199"string",
1200thread_id="string",
1201) as response:
1202assert not response.is_closed
1203assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1204
1205run = await response.parse()
1206assert_matches_type(Run, run, path=["response"])
1207
1208assert cast(Any, response.is_closed) is True
1209
023a4e66Stainless Bot2 years ago1210@parametrize
98d779fbStainless Bot2 years ago1211async def test_path_params_cancel(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1212with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1213await async_client.beta.threads.runs.with_raw_response.cancel(
023a4e66Stainless Bot2 years ago1214"string",
1215thread_id="",
1216)
1217
1218with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1219await async_client.beta.threads.runs.with_raw_response.cancel(
023a4e66Stainless Bot2 years ago1220"",
1221thread_id="string",
1222)
1223
baa9f07fRobert Craigie2 years ago1224@parametrize
5429f696Stainless Bot2 years ago1225async def test_method_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago1226run = await async_client.beta.threads.runs.submit_tool_outputs(
baa9f07fRobert Craigie2 years ago1227"string",
1228thread_id="string",
1229tool_outputs=[{}, {}, {}],
1230)
1231assert_matches_type(Run, run, path=["response"])
1232
1233@parametrize
5429f696Stainless Bot2 years ago1234async def test_method_submit_tool_outputs_with_all_params_overload_1(self, async_client: AsyncOpenAI) -> None:
1235run = await async_client.beta.threads.runs.submit_tool_outputs(
1236"string",
1237thread_id="string",
1238tool_outputs=[
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{
092a8df7Stainless Bot1 years ago1248"output": "output",
1249"tool_call_id": "tool_call_id",
5429f696Stainless Bot2 years ago1250},
1251],
1252stream=False,
1253)
1254assert_matches_type(Run, run, path=["response"])
1255
1256@parametrize
1257async def test_raw_response_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago1258response = await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
baa9f07fRobert Craigie2 years ago1259"string",
1260thread_id="string",
1261tool_outputs=[{}, {}, {}],
1262)
86379b44Stainless Bot2 years ago1263
1264assert response.is_closed is True
baa9f07fRobert Craigie2 years ago1265assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1266run = response.parse()
1267assert_matches_type(Run, run, path=["response"])
86379b44Stainless Bot2 years ago1268
1269@parametrize
5429f696Stainless Bot2 years ago1270async def test_streaming_response_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago1271async with async_client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
86379b44Stainless Bot2 years ago1272"string",
1273thread_id="string",
1274tool_outputs=[{}, {}, {}],
1275) as response:
1276assert not response.is_closed
1277assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1278
1279run = await response.parse()
1280assert_matches_type(Run, run, path=["response"])
1281
1282assert cast(Any, response.is_closed) is True
023a4e66Stainless Bot2 years ago1283
1284@parametrize
5429f696Stainless Bot2 years ago1285async def test_path_params_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
1286with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
1287await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
1288"string",
1289thread_id="",
1290tool_outputs=[{}, {}, {}],
1291)
1292
1293with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
1294await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
1295"",
1296thread_id="string",
1297tool_outputs=[{}, {}, {}],
1298)
1299
1300@parametrize
1301async def test_method_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
1302run_stream = await async_client.beta.threads.runs.submit_tool_outputs(
1303"string",
1304thread_id="string",
1305stream=True,
1306tool_outputs=[{}, {}, {}],
1307)
1308await run_stream.response.aclose()
1309
1310@parametrize
1311async def test_raw_response_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
1312response = await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
1313"string",
1314thread_id="string",
1315stream=True,
1316tool_outputs=[{}, {}, {}],
1317)
1318
1319assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1320stream = response.parse()
1321await stream.close()
1322
1323@parametrize
1324async def test_streaming_response_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
1325async with async_client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
1326"string",
1327thread_id="string",
1328stream=True,
1329tool_outputs=[{}, {}, {}],
1330) as response:
1331assert not response.is_closed
1332assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1333
1334stream = await response.parse()
1335await stream.close()
1336
1337assert cast(Any, response.is_closed) is True
1338
1339@parametrize
1340async def test_path_params_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago1341with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago1342await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
023a4e66Stainless Bot2 years ago1343"string",
1344thread_id="",
5429f696Stainless Bot2 years ago1345stream=True,
023a4e66Stainless Bot2 years ago1346tool_outputs=[{}, {}, {}],
1347)
1348
1349with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago1350await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
023a4e66Stainless Bot2 years ago1351"",
1352thread_id="string",
5429f696Stainless Bot2 years ago1353stream=True,
023a4e66Stainless Bot2 years ago1354tool_outputs=[{}, {}, {}],
1355)