Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/openai/resources/beta/threads/runs/runs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations
from typing import Optional, Any

def create_and_poll(
self,
thread_id: str,
**kwargs: Any,
) -> Any:
"""
Create a run and poll until it is completed.
Supports timeout propagation for all underlying requests.
"""
timeout = kwargs.pop("timeout", None)

# Step 1: Create the run
run = self.create(thread_id=thread_id, timeout=timeout, **kwargs)

# Step 2: Poll until completion
while run.status in ("queued", "in_progress"):
run = self.retrieve(
thread_id=thread_id,
run_id=run.id,
timeout=timeout
)
return run


import typing_extensions
from typing import List, Union, Iterable, Optional
Expand Down