repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
openai-python | examples/mtls_httpx.py | .py | #!/usr/bin/env -S rye run python
import os
import ssl
from openai import OpenAI, DefaultHttpxClient
ssl_context = ssl.create_default_context(
cafile=os.environ.get("OPENAI_MTLS_CA_BUNDLE"),
)
ssl_context.load_cert_chain(
# Leaf certificate first; if intermediate-chain support is enabled, follow
# it with... | 31 | 833 |
openai-python | examples/audio.py | .py | #!/usr/bin/env rye run python
from pathlib import Path
from openai import OpenAI
# gets OPENAI_API_KEY from your environment variables
openai = OpenAI()
speech_file_path = Path(__file__).parent / "speech.mp3"
def main() -> None:
# Create text-to-speech audio file
with openai.audio.speech.with_streaming_re... | 39 | 933 |
openai-python | examples/azure.py | .py | from openai import AzureOpenAI
# may change in the future
# https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#rest-api-versioning
api_version = "2023-07-01-preview"
# gets the API Key from environment variable AZURE_OPENAI_API_KEY
client = AzureOpenAI(
api_version=api_version,
# https://lea... | 44 | 1,428 |
openai-python | examples/streaming.py | .py | #!/usr/bin/env -S poetry run python
import asyncio
from openai import OpenAI, AsyncOpenAI
# This script assumes you have the OPENAI_API_KEY environment variable set to a valid OpenAI API key.
#
# You can run this script from the root directory like so:
# `python examples/streaming.py`
def sync_main() -> None:
... | 57 | 1,594 |
openai-python | examples/mtls_httpx2_async.py | .py | #!/usr/bin/env -S rye run python
import os
import ssl
import asyncio
from openai import AsyncOpenAI, DefaultAsyncHttpx2Client
async def main() -> None:
ssl_context = ssl.create_default_context(
cafile=os.environ.get("OPENAI_MTLS_CA_BUNDLE"),
)
ssl_context.load_cert_chain(
# Leaf certific... | 37 | 1,019 |
openai-python | examples/speech_to_text.py | .py | #!/usr/bin/env rye run python
import asyncio
from openai import AsyncOpenAI
from openai.helpers import Microphone
# gets OPENAI_API_KEY from your environment variables
openai = AsyncOpenAI()
async def main() -> None:
print("Recording for the next 10 seconds...")
recording = await Microphone(timeout=10).rec... | 26 | 561 |
openai-python | examples/realtime/azure_realtime.py | .py | import os
import asyncio
from azure.identity.aio import DefaultAzureCredential, get_bearer_token_provider
from openai import AsyncOpenAI
# Azure OpenAI Realtime Docs
# How-to: https://learn.microsoft.com/azure/ai-services/openai/how-to/realtime-audio
# Supported models and API versions: https://learn.microsoft.com/... | 80 | 3,237 |
openai-python | examples/realtime/push_to_talk_app.py | .py | #!/usr/bin/env uv run
####################################################################
# Sample TUI app with a push to talk interface to the Realtime API #
# If you have `uv` installed and the `OPENAI_API_KEY` #
# environment variable set, you can run this example with just #
# ... | 292 | 9,486 |
openai-python | examples/realtime/realtime.py | .py | #!/usr/bin/env rye run python
import asyncio
from openai import AsyncOpenAI
# Azure OpenAI Realtime Docs
# How-to: https://learn.microsoft.com/azure/ai-services/openai/how-to/realtime-audio
# Supported models and API versions: https://learn.microsoft.com/azure/ai-services/openai/how-to/realtime-audio#supported-model... | 55 | 1,902 |
openai-python | examples/realtime/audio_util.py | .py | from __future__ import annotations
import io
import base64
import asyncio
import threading
from typing import Callable, Awaitable
import numpy as np
import pyaudio
import sounddevice as sd
from pydub import AudioSegment
from openai.resources.realtime.realtime import AsyncRealtimeConnection
CHUNK_LENGTH_S = 0.05 # ... | 143 | 4,266 |
openai-python | examples/responses/structured_outputs_tools.py | .py | from enum import Enum
from typing import List, Union
import rich
from pydantic import BaseModel
import openai
from openai import OpenAI
class Table(str, Enum):
orders = "orders"
customers = "customers"
products = "products"
class Column(str, Enum):
id = "id"
status = "status"
expected_deli... | 74 | 1,431 |
openai-python | examples/responses/multi_agent_websocket.py | .py | from __future__ import annotations
from openai import OpenAI
from openai.types.beta import BetaResponseOutputItem
PROMPT = """Compare these fictional proposals on speed, cost, reliability, and security.
Proposal Alpha: 2-week launch, $40k, managed vendor, 99.9% SLA, data leaves the VPC.
Proposal Beta: 6-week launch, ... | 47 | 1,705 |
openai-python | examples/responses/websocket.py | .py | from __future__ import annotations
import json
import argparse
from typing import TYPE_CHECKING, Dict, Union, Literal, Optional, TypedDict, NamedTuple, cast
from openai import OpenAI
from openai.types.responses import (
FunctionToolParam,
ToolChoiceOptions,
ResponseInputParam,
ResponseFailedEvent,
... | 437 | 13,643 |
openai-python | examples/responses/background_async.py | .py | import asyncio
from typing import List
import rich
from pydantic import BaseModel
from openai._client import AsyncOpenAI
class Step(BaseModel):
explanation: str
output: str
class MathResponse(BaseModel):
steps: List[Step]
final_answer: str
async def main() -> None:
client = AsyncOpenAI()
... | 53 | 1,149 |
openai-python | examples/responses/background_streaming.py | .py | #!/usr/bin/env -S rye run python
from typing import List
import rich
from pydantic import BaseModel
from openai import OpenAI
class Step(BaseModel):
explanation: str
output: str
class MathResponse(BaseModel):
steps: List[Step]
final_answer: str
client = OpenAI()
id = None
with client.responses.s... | 49 | 1,002 |
openai-python | examples/responses/structured_outputs.py | .py | from typing import List
import rich
from pydantic import BaseModel
from openai import OpenAI
class Step(BaseModel):
explanation: str
output: str
class MathResponse(BaseModel):
steps: List[Step]
final_answer: str
client = OpenAI()
rsp = client.responses.parse(
input="solve 8x + 31 = 2",
... | 56 | 1,050 |
openai-python | examples/responses/multi_agent_streaming.py | .py | from __future__ import annotations
from openai import OpenAI
from openai.types.beta import BetaResponseOutputItem
PROMPT = """Compare these fictional proposals on speed, cost, reliability, and security.
Proposal Alpha: 2-week launch, $40k, managed vendor, 99.9% SLA, data leaves the VPC.
Proposal Beta: 6-week launch, ... | 41 | 1,447 |
openai-python | examples/responses/streaming.py | .py | from typing import List
import rich
from pydantic import BaseModel
from openai import OpenAI
class Step(BaseModel):
explanation: str
output: str
class MathResponse(BaseModel):
steps: List[Step]
final_answer: str
client = OpenAI()
with client.responses.stream(
input="solve 8x + 31 = 2",
... | 31 | 526 |
openai-python | examples/responses/streaming_tools.py | .py | from enum import Enum
from typing import List, Union
import rich
from pydantic import BaseModel
import openai
from openai import OpenAI
class Table(str, Enum):
orders = "orders"
customers = "customers"
products = "products"
class Column(str, Enum):
id = "id"
status = "status"
expected_deli... | 69 | 1,264 |
openai-python | examples/responses/background_streaming_async.py | .py | import asyncio
from typing import List
import rich
from pydantic import BaseModel
from openai import AsyncOpenAI
class Step(BaseModel):
explanation: str
output: str
class MathResponse(BaseModel):
steps: List[Step]
final_answer: str
async def main() -> None:
client = AsyncOpenAI()
id = No... | 54 | 1,201 |
openai-python | examples/responses/background.py | .py | from typing import List
import rich
from pydantic import BaseModel
from openai import OpenAI
class Step(BaseModel):
explanation: str
output: str
class MathResponse(BaseModel):
steps: List[Step]
final_answer: str
client = OpenAI()
id = None
with client.responses.create(
input="solve 8x + 31 ... | 47 | 901 |
openai-python | src/openai/_constants.py | .py | import httpx2
RAW_RESPONSE_HEADER = "X-Stainless-Raw-Response"
OVERRIDE_CAST_TO_HEADER = "____stainless_override_cast_to"
# default timeout is 10 minutes
DEFAULT_TIMEOUT = httpx2.Timeout(timeout=600, connect=5.0)
DEFAULT_MAX_RETRIES = 2
DEFAULT_CONNECTION_LIMITS = httpx2.Limits(max_connections=1000, max_keepalive_con... | 14 | 414 |
openai-python | src/openai/_compat.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast, overload
from datetime import date, datetime
from typing_extensions import Self, Literal, TypedDict
import pydantic
from pydantic.fields import FieldInfo
from ._types import IncEx, StrBytesIntFloat
_T ... | 239 | 7,213 |
openai-python | src/openai/_files.py | .py | from __future__ import annotations
import io
import os
import pathlib
from typing import Sequence, cast, overload
from typing_extensions import TypeVar, TypeGuard
import anyio
from ._types import (
FileTypes,
FileContent,
RequestFiles,
HttpxFileTypes,
Base64FileInput,
HttpxFileContent,
Ht... | 174 | 5,520 |
openai-python | src/openai/_version.py | .py | __title__ = "openai"
__version__ = "3.1.0" # x-release-please-version
| 3 | 71 |
openai-python | src/openai/_qs.py | .py | from __future__ import annotations
from typing import Any, List, Tuple, Union, Mapping, TypeVar
from urllib.parse import parse_qs, urlencode
from typing_extensions import get_args
from ._types import NotGiven, ArrayFormat, NestedFormat, not_given
from ._utils import flatten
_T = TypeVar("_T")
PrimitiveData = Union[... | 150 | 4,833 |
openai-python | src/openai/_exceptions.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional, cast
from typing_extensions import Literal
import httpx2
from ._utils import is_dict
from ._models import construct_type
from .types.shared.oauth_error_code import OAuthErrorCode
if TYPE_CHECKING:
from .types.chat import ChatCom... | 206 | 6,387 |
openai-python | src/openai/_models.py | .py | from __future__ import annotations
import os
import inspect
import weakref
from typing import (
IO,
TYPE_CHECKING,
Any,
Type,
Tuple,
Union,
Generic,
TypeVar,
Callable,
Iterable,
Optional,
AsyncIterable,
cast,
)
from datetime import date, datetime
from typing_extensio... | 1,006 | 36,923 |
openai-python | src/openai/_base_client.py | .py | from __future__ import annotations
import sys
import json
import math
import time
import uuid
import email
import asyncio
import inspect
import logging
import platform
import warnings
import email.utils
from types import TracebackType
from random import random
from typing import (
TYPE_CHECKING,
Any,
Dict,... | 2,280 | 79,071 |
openai-python | src/openai/_streaming.py | .py | # Note: initially copied from https://github.com/florimondmanca/httpx-sse/blob/master/src/httpx_sse/_decoders.py
from __future__ import annotations
import json
import inspect
from types import TracebackType
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Iterator, Optional, AsyncIterator, cast
from typing_ext... | 428 | 14,613 |
openai-python | src/openai/_send_queue.py | .py | from __future__ import annotations
import typing
import threading
from ._exceptions import WebSocketQueueFullError
class SendQueue:
"""Bounded byte-size queue for outgoing WebSocket messages.
Messages are stored as pre-serialized strings. The queue enforces a
maximum byte budget so that unbounded buffe... | 89 | 2,947 |
openai-python | src/openai/_resource.py | .py | from __future__ import annotations
import time
from typing import TYPE_CHECKING
import anyio
if TYPE_CHECKING:
from ._client import OpenAI, AsyncOpenAI
class SyncAPIResource:
_client: OpenAI
def __init__(self, client: OpenAI) -> None:
self._client = client
self._get = client.get
... | 42 | 1,013 |
openai-python | src/openai/_httpx2.py | .py | from __future__ import annotations
import sys
from typing import Any, Protocol, cast
import httpx2
from ._constants import DEFAULT_TIMEOUT, DEFAULT_CONNECTION_LIMITS
class _LegacyHttpxModule(Protocol):
Auth: type[httpx2.Auth]
Client: type[httpx2.Client]
AsyncClient: type[httpx2.AsyncClient]
URL: ty... | 142 | 4,873 |
openai-python | src/openai/_legacy_response.py | .py | from __future__ import annotations
import os
import inspect
import logging
import datetime
import functools
from typing import (
TYPE_CHECKING,
Any,
Union,
Generic,
TypeVar,
Callable,
Iterator,
AsyncIterator,
cast,
overload,
)
from typing_extensions import Awaitable, ParamSpec, ... | 494 | 16,482 |
openai-python | src/openai/_types.py | .py | from __future__ import annotations
from os import PathLike
from typing import (
IO,
TYPE_CHECKING,
Any,
Dict,
List,
Type,
Tuple,
Union,
Mapping,
TypeVar,
Callable,
Iterable,
Iterator,
Optional,
Sequence,
AsyncIterable,
)
from typing_extensions import (
... | 280 | 7,916 |
openai-python | src/openai/pagination.py | .py | from typing import Any, List, Generic, TypeVar, Optional, cast
from typing_extensions import Protocol, override, runtime_checkable
from ._base_client import BasePage, PageInfo, BaseSyncPage, BaseAsyncPage
__all__ = [
"SyncPage",
"AsyncPage",
"SyncCursorPage",
"AsyncCursorPage",
"SyncConversationCu... | 249 | 6,130 |
openai-python | src/openai/_response.py | .py | from __future__ import annotations
import os
import inspect
import logging
import datetime
import functools
from types import TracebackType
from typing import (
TYPE_CHECKING,
Any,
Union,
Generic,
TypeVar,
Callable,
Iterator,
AsyncIterator,
cast,
overload,
)
from typing_extensio... | 854 | 29,799 |
openai-python | src/openai/_provider.py | .py | from __future__ import annotations
from typing import Callable, Protocol, Awaitable
from weakref import WeakKeyDictionary
from dataclasses import dataclass
import httpx2
from ._models import FinalRequestOptions
from ._exceptions import OpenAIError
class _Provider:
"""Opaque configuration returned by an OpenAI-... | 66 | 2,499 |
openai-python | src/openai/_event_handler.py | .py | from __future__ import annotations
import threading
from typing import Any, Callable
EventHandler = Callable[..., Any]
class EventHandlerRegistry:
"""Thread-safe (optional) registry of event handlers."""
def __init__(self, *, use_lock: bool = False) -> None:
self._handlers: dict[str, list[EventHand... | 84 | 2,771 |
openai-python | src/openai/_extras/sounddevice_proxy.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any
from typing_extensions import override
from .._utils import LazyProxy
from ._common import MissingDependencyError, format_instructions
if TYPE_CHECKING:
import sounddevice as sounddevice # type: ignore
SOUNDDEVICE_INSTRUCTIONS = format_i... | 29 | 725 |
openai-python | src/openai/_extras/_common.py | .py | from .._exceptions import OpenAIError
INSTRUCTIONS = """
OpenAI error:
missing `{library}`
This feature requires additional dependencies:
$ pip install openai[{extra}]
"""
def format_instructions(*, library: str, extra: str) -> str:
return INSTRUCTIONS.format(library=library, extra=extra)
class Mi... | 22 | 364 |
openai-python | src/openai/_extras/numpy_proxy.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any
from typing_extensions import override
from .._utils import LazyProxy
from ._common import MissingDependencyError, format_instructions
if TYPE_CHECKING:
import numpy as numpy
NUMPY_INSTRUCTIONS = format_instructions(library="numpy", extra... | 38 | 805 |
openai-python | src/openai/_extras/pandas_proxy.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any
from typing_extensions import override
from .._utils import LazyProxy
from ._common import MissingDependencyError, format_instructions
if TYPE_CHECKING:
import pandas as pandas
PANDAS_INSTRUCTIONS = format_instructions(library="pandas", e... | 29 | 637 |
openai-python | src/openai/resources/beta/realtime/__init__.py | .py | from .realtime import (
Realtime,
AsyncRealtime,
RealtimeWithRawResponse,
AsyncRealtimeWithRawResponse,
RealtimeWithStreamingResponse,
AsyncRealtimeWithStreamingResponse,
)
from .sessions import (
Sessions,
AsyncSessions,
SessionsWithRawResponse,
AsyncSessionsWithRawResponse,
... | 46 | 1,325 |
openai-python | src/openai/resources/beta/realtime/sessions.py | .py | from __future__ import annotations
from typing import List, Union, Iterable
from typing_extensions import Literal
import httpx2
from .... import _legacy_response
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import maybe_transform, async_maybe_transform
from ...._compat import cach... | 423 | 22,014 |
openai-python | src/openai/resources/beta/realtime/realtime.py | .py | from __future__ import annotations
import json
import logging
from types import TracebackType
from typing import TYPE_CHECKING, Any, Iterator, cast
from typing_extensions import AsyncIterator
import httpx2
from pydantic import BaseModel
from .sessions import (
Sessions,
AsyncSessions,
SessionsWithRawResp... | 1,094 | 43,674 |
openai-python | src/openai/resources/beta/realtime/transcription_sessions.py | .py | from __future__ import annotations
from typing import List
from typing_extensions import Literal
import httpx2
from .... import _legacy_response
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import maybe_transform, async_maybe_transform
from ...._compat import cached_property
from ... | 281 | 14,040 |
openai-python | src/openai/auth/__init__.py | .py | from __future__ import annotations
from ._workload import (
WorkloadIdentity as WorkloadIdentity,
SubjectTokenProvider as SubjectTokenProvider,
WorkloadIdentityAuth as WorkloadIdentityAuth,
gcp_id_token_provider as gcp_id_token_provider,
k8s_service_account_token_provider as k8s_service_account_tok... | 20 | 630 |
openai-python | src/openai/auth/_workload.py | .py | from __future__ import annotations
import time
import threading
from typing import Any, Callable, TypedDict, cast
from pathlib import Path
from typing_extensions import Literal, NotRequired
import httpx2
from .._httpx2 import DefaultHttpx2Client, _loaded_legacy_httpx
from .._exceptions import OAuthError, OpenAIError... | 317 | 13,056 |
openai-python | src/openai/_vendor/httpx_aiohttp/transport.py | .py | from __future__ import annotations
import contextlib
import ssl
import typing
import typing as t
from importlib import metadata
from logging import warning
import aiohttp
import httpx2 as httpx
from aiohttp import BasicAuth, ClientTimeout
from aiohttp.client import ClientResponse, ClientSession
AIOHTTP_EXC_MAP = {
... | 202 | 7,109 |
openai-python | src/openai/_vendor/httpx_aiohttp/__init__.py | .py | """Variant of httpx_aiohttp for `httpx2 <https://github.com/pydantic/httpx2>`_.
Requires the optional ``httpx2`` dependency: ``pip install httpx-aiohttp[httpx2]``.
"""
from .client import Httpx2AiohttpClient
from .transport import AiohttpTransport
__all__ = ["AiohttpTransport", "Httpx2AiohttpClient"]
| 10 | 305 |
openai-python | src/openai/_vendor/httpx_aiohttp/client.py | .py | from __future__ import annotations
import ssl
import typing as t
import httpx2 as httpx
SOCKET_OPTION = t.Union[
t.Tuple[int, int, int],
t.Tuple[int, int, t.Union[bytes, bytearray]],
t.Tuple[int, int, None, int],
]
class Httpx2AiohttpClient(httpx.AsyncClient):
def _init_transport(
self,
... | 63 | 1,805 |
openai-python | src/openai/lib/_bedrock_auth.py | .py | # pyright: reportMissingTypeStubs=false
from __future__ import annotations
import os
import hashlib
from typing import Any, Literal, Mapping, Callable, Protocol, cast
from dataclasses import field, dataclass
from .._exceptions import OpenAIError
AwsCredentialsProvider = Callable[[], object]
class _BotocoreSession... | 187 | 7,220 |
openai-python | src/openai/lib/bedrock.py | .py | from __future__ import annotations
import os
import re
import hashlib
import inspect
from typing import Any, Literal, Mapping, Callable, Optional, Awaitable, cast
from dataclasses import field, replace, dataclass
from typing_extensions import Self, override
import httpx2
from ..auth import WorkloadIdentity
from .._t... | 862 | 37,549 |
openai-python | src/openai/lib/_validators.py | .py | # pyright: basic
from __future__ import annotations
import os
import sys
from typing import Any, TypeVar, Callable, Optional, NamedTuple
from typing_extensions import TypeAlias
from .._extras import pandas as pd
class Remediation(NamedTuple):
name: str
immediate_msg: Optional[str] = None
necessary_msg: ... | 810 | 35,288 |
openai-python | src/openai/lib/_realtime.py | .py | from __future__ import annotations
import json
from typing_extensions import override
import httpx2
from openai import _legacy_response
from openai._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from openai._utils import maybe_transform, async_maybe_transform
from openai._base_client import make... | 93 | 3,983 |
openai-python | src/openai/lib/_old_api.py | .py | from __future__ import annotations
from typing import TYPE_CHECKING, Any
from typing_extensions import override
from .._utils import LazyProxy
from .._exceptions import OpenAIError
INSTRUCTIONS = """
You tried to access openai.{symbol}, but this is no longer supported in openai>=1.0.0 - see the README at https://gi... | 73 | 1,947 |
openai-python | src/openai/lib/azure.py | .py | from __future__ import annotations
import os
import inspect
from typing import Any, Union, Mapping, TypeVar, Callable, Awaitable, cast, overload
from typing_extensions import Self, override
import httpx2
from ..auth import WorkloadIdentity
from .._types import NOT_GIVEN, Omit, Query, Headers, Timeout, NotGiven
from ... | 746 | 31,085 |
openai-python | src/openai/lib/_pydantic.py | .py | from __future__ import annotations
import inspect
from typing import Any, TypeVar
from typing_extensions import TypeGuard
import pydantic
from .._types import NOT_GIVEN
from .._utils import is_dict as _is_dict, is_list
from .._compat import PYDANTIC_V1, model_json_schema
_T = TypeVar("_T")
def to_strict_json_sche... | 156 | 5,623 |
openai-python | src/openai/lib/_tools.py | .py | from __future__ import annotations
from typing import Any, Dict, cast
import pydantic
from ._pydantic import to_strict_json_schema
from ..types.chat import ChatCompletionFunctionToolParam
from ..types.shared_params import FunctionDefinition
from ..types.responses.function_tool_param import FunctionToolParam as Respo... | 67 | 1,969 |
openai-python | src/openai/lib/streaming/_assistants.py | .py | from __future__ import annotations
import asyncio
from types import TracebackType
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Callable, Iterable, Iterator, cast
from typing_extensions import Awaitable, AsyncIterable, AsyncIterator, assert_never
from ..._utils import is_dict, is_list, consume_sync_iterato... | 1,042 | 40,787 |
openai-python | src/openai/lib/streaming/__init__.py | .py | from ._assistants import (
AssistantEventHandler as AssistantEventHandler,
AssistantEventHandlerT as AssistantEventHandlerT,
AssistantStreamManager as AssistantStreamManager,
AsyncAssistantEventHandler as AsyncAssistantEventHandler,
AsyncAssistantEventHandlerT as AsyncAssistantEventHandlerT,
Asy... | 9 | 379 |
openai-python | src/openai/lib/streaming/_deltas.py | .py | from __future__ import annotations
from ..._utils import is_dict, is_list
def accumulate_delta(acc: dict[object, object], delta: dict[object, object]) -> dict[object, object]:
for key, delta_value in delta.items():
if key not in acc:
acc[key] = delta_value
continue
acc_va... | 65 | 2,502 |
openai-python | src/openai/lib/streaming/chat/__init__.py | .py | from ._types import (
ParsedChoiceSnapshot as ParsedChoiceSnapshot,
ParsedChatCompletionSnapshot as ParsedChatCompletionSnapshot,
ParsedChatCompletionMessageSnapshot as ParsedChatCompletionMessageSnapshot,
)
from ._events import (
ChunkEvent as ChunkEvent,
ContentDoneEvent as ContentDoneEvent,
R... | 28 | 1,305 |
openai-python | src/openai/lib/streaming/chat/_events.py | .py | from typing import List, Union, Generic, Optional
from typing_extensions import Literal
from ._types import ParsedChatCompletionSnapshot
from ...._models import BaseModel, GenericModel
from ..._parsing import ResponseFormatT
from ....types.chat import ChatCompletionChunk, ChatCompletionTokenLogprob
class ChunkEvent(... | 124 | 2,618 |
openai-python | src/openai/lib/streaming/chat/_completions.py | .py | from __future__ import annotations
import inspect
from types import TracebackType
from typing import TYPE_CHECKING, Any, Generic, Callable, Iterable, Awaitable, AsyncIterator, cast
from typing_extensions import Self, Iterator, assert_never
from jiter import from_json
from ._types import ParsedChoiceSnapshot, ParsedC... | 770 | 30,704 |
openai-python | src/openai/lib/streaming/chat/_types.py | .py | from __future__ import annotations
from typing_extensions import TypeAlias
from ....types.chat import ParsedChoice, ParsedChatCompletion, ParsedChatCompletionMessage
ParsedChatCompletionSnapshot: TypeAlias = ParsedChatCompletion[object]
"""Snapshot type representing an in-progress accumulation of
a `ParsedChatComple... | 21 | 739 |
openai-python | src/openai/lib/streaming/responses/_responses.py | .py | from __future__ import annotations
import inspect
from types import TracebackType
from typing import Any, List, Generic, Iterable, Awaitable, cast
from typing_extensions import Self, Callable, Iterator, AsyncIterator
from ._types import ParsedResponseSnapshot
from ._events import (
ResponseStreamEvent,
Respon... | 373 | 13,614 |
openai-python | src/openai/lib/streaming/responses/__init__.py | .py | from ._events import (
ResponseTextDoneEvent as ResponseTextDoneEvent,
ResponseTextDeltaEvent as ResponseTextDeltaEvent,
ResponseFunctionCallArgumentsDeltaEvent as ResponseFunctionCallArgumentsDeltaEvent,
)
from ._responses import (
ResponseStream as ResponseStream,
AsyncResponseStream as AsyncRespo... | 14 | 543 |
openai-python | src/openai/lib/streaming/responses/_events.py | .py | from __future__ import annotations
from typing import Optional
from typing_extensions import Union, Generic, TypeVar, Annotated, TypeAlias
from ...._utils import PropertyInfo
from ...._compat import GenericModel
from ....types.responses import (
ParsedResponse,
ResponseErrorEvent,
ResponseFailedEvent,
... | 149 | 5,576 |
openai-python | src/openai/lib/streaming/responses/_types.py | .py | from __future__ import annotations
from typing_extensions import TypeAlias
from ....types.responses import ParsedResponse
ParsedResponseSnapshot: TypeAlias = ParsedResponse[object]
"""Snapshot type representing an in-progress accumulation of
a `ParsedResponse` object.
"""
| 11 | 276 |
openai-python | src/openai/lib/_parsing/_responses.py | .py | from __future__ import annotations
import json
from typing import TYPE_CHECKING, List, Iterable, cast
from typing_extensions import TypeVar, assert_never
import pydantic
from .._tools import ResponsesPydanticFunctionTool
from ..._types import Omit
from ..._utils import is_given
from ..._compat import PYDANTIC_V1, mo... | 188 | 6,566 |
openai-python | src/openai/lib/_parsing/__init__.py | .py | from ._completions import (
ResponseFormatT as ResponseFormatT,
has_parseable_input,
has_parseable_input as has_parseable_input,
maybe_parse_content as maybe_parse_content,
validate_input_tools as validate_input_tools,
parse_chat_completion as parse_chat_completion,
get_input_tool_by_name as... | 12 | 483 |
openai-python | src/openai/lib/_parsing/_completions.py | .py | from __future__ import annotations
import json
import logging
from typing import TYPE_CHECKING, Any, Iterable, cast
from typing_extensions import TypeVar, TypeGuard, assert_never
import pydantic
from .._tools import PydanticFunctionTool
from ..._types import Omit, omit
from ..._utils import is_dict, is_given
from ..... | 289 | 10,000 |
openai-python | src/openai/types/webhooks/safety_identifier_blocked_webhook_event.py | .py | from typing import Optional
from typing_extensions import Literal
from ..._models import BaseModel
__all__ = ["SafetyIdentifierBlockedWebhookEvent", "Data"]
class Data(BaseModel):
"""Event data payload."""
safety_category: str
"""The safety category that triggered the block, such as `bio` or `cyber`.""... | 45 | 1,291 |
openai-python | src/openai/types/beta/realtime/realtime_server_event.py | .py | from typing import Union
from typing_extensions import Literal, Annotated, TypeAlias
from ...._utils import PropertyInfo
from ...._models import BaseModel
from .error_event import ErrorEvent
from .conversation_item import ConversationItem
from .response_done_event import ResponseDoneEvent
from .session_created_event i... | 132 | 5,321 |
openai-python | src/openai/types/beta/realtime/session_created_event.py | .py | from typing_extensions import Literal
from .session import Session
from ...._models import BaseModel
__all__ = ["SessionCreatedEvent"]
class SessionCreatedEvent(BaseModel):
event_id: str
"""The unique ID of the server event."""
session: Session
"""Realtime session object configuration."""
type... | 18 | 402 |
openai-python | src/openai/types/beta/realtime/conversation_item_with_reference.py | .py | from typing import List, Optional
from typing_extensions import Literal
from ...._models import BaseModel
__all__ = ["ConversationItemWithReference", "Content"]
class Content(BaseModel):
id: Optional[str] = None
"""
ID of a previous conversation item to reference (for `item_reference` content
types ... | 86 | 3,201 |
openai-python | src/openai/types/beta/realtime/realtime_client_event.py | .py | from typing import Union, Optional
from typing_extensions import Literal, Annotated, TypeAlias
from ...._utils import PropertyInfo
from ...._models import BaseModel
from .session_update_event import SessionUpdateEvent
from .response_cancel_event import ResponseCancelEvent
from .response_create_event import ResponseCre... | 46 | 1,752 |
openai-python | src/openai/types/beta/realtime/conversation_item_truncate_event_param.py | .py | from __future__ import annotations
from typing_extensions import Literal, Required, TypedDict
__all__ = ["ConversationItemTruncateEventParam"]
class ConversationItemTruncateEventParam(TypedDict, total=False):
audio_end_ms: Required[int]
"""Inclusive duration up to which audio is truncated, in milliseconds.
... | 30 | 896 |
openai-python | src/openai/types/beta/realtime/response_audio_delta_event.py | .py | from typing_extensions import Literal
from ...._models import BaseModel
__all__ = ["ResponseAudioDeltaEvent"]
class ResponseAudioDeltaEvent(BaseModel):
content_index: int
"""The index of the content part in the item's content array."""
delta: str
"""Base64-encoded audio data delta."""
event_id... | 29 | 655 |
openai-python | src/openai/types/beta/realtime/session_update_event.py | .py | from typing import List, Union, Optional
from typing_extensions import Literal, TypeAlias
from ...._models import BaseModel
__all__ = [
"SessionUpdateEvent",
"Session",
"SessionClientSecret",
"SessionClientSecretExpiresAfter",
"SessionInputAudioNoiseReduction",
"SessionInputAudioTranscription"... | 311 | 11,150 |
openai-python | src/openai/types/beta/realtime/session_create_params.py | .py | from __future__ import annotations
from typing import List, Union, Iterable
from typing_extensions import Literal, Required, TypeAlias, TypedDict
__all__ = [
"SessionCreateParams",
"ClientSecret",
"ClientSecretExpiresAfter",
"InputAudioNoiseReduction",
"InputAudioTranscription",
"Tool",
"T... | 297 | 10,164 |
openai-python | src/openai/types/beta/realtime/response_text_delta_event.py | .py | from typing_extensions import Literal
from ...._models import BaseModel
__all__ = ["ResponseTextDeltaEvent"]
class ResponseTextDeltaEvent(BaseModel):
content_index: int
"""The index of the content part in the item's content array."""
delta: str
"""The text delta."""
event_id: str
"""The un... | 29 | 634 |
openai-python | src/openai/types/beta/realtime/realtime_response_usage.py | .py | from typing import Optional
from ...._models import BaseModel
__all__ = ["RealtimeResponseUsage", "InputTokenDetails", "OutputTokenDetails"]
class InputTokenDetails(BaseModel):
audio_tokens: Optional[int] = None
"""The number of audio tokens used in the Response."""
cached_tokens: Optional[int] = None
... | 51 | 1,454 |
openai-python | src/openai/types/beta/realtime/conversation_item_retrieve_event_param.py | .py | from __future__ import annotations
from typing_extensions import Literal, Required, TypedDict
__all__ = ["ConversationItemRetrieveEventParam"]
class ConversationItemRetrieveEventParam(TypedDict, total=False):
item_id: Required[str]
"""The ID of the item to retrieve."""
type: Required[Literal["conversat... | 17 | 492 |
openai-python | src/openai/types/beta/realtime/input_audio_buffer_commit_event_param.py | .py | from __future__ import annotations
from typing_extensions import Literal, Required, TypedDict
__all__ = ["InputAudioBufferCommitEventParam"]
class InputAudioBufferCommitEventParam(TypedDict, total=False):
type: Required[Literal["input_audio_buffer.commit"]]
"""The event type, must be `input_audio_buffer.com... | 14 | 416 |
openai-python | src/openai/types/beta/realtime/input_audio_buffer_committed_event.py | .py | from typing import Optional
from typing_extensions import Literal
from ...._models import BaseModel
__all__ = ["InputAudioBufferCommittedEvent"]
class InputAudioBufferCommittedEvent(BaseModel):
event_id: str
"""The unique ID of the server event."""
item_id: str
"""The ID of the user message item th... | 24 | 646 |
openai-python | src/openai/types/beta/realtime/input_audio_buffer_append_event_param.py | .py | from __future__ import annotations
from typing_extensions import Literal, Required, TypedDict
__all__ = ["InputAudioBufferAppendEventParam"]
class InputAudioBufferAppendEventParam(TypedDict, total=False):
audio: Required[str]
"""Base64-encoded audio bytes.
This must be in the format specified by the `i... | 21 | 595 |
openai-python | src/openai/types/beta/realtime/response_output_item_done_event.py | .py | from typing_extensions import Literal
from ...._models import BaseModel
from .conversation_item import ConversationItem
__all__ = ["ResponseOutputItemDoneEvent"]
class ResponseOutputItemDoneEvent(BaseModel):
event_id: str
"""The unique ID of the server event."""
item: ConversationItem
"""The item t... | 24 | 622 |
openai-python | src/openai/types/beta/realtime/response_content_part_done_event.py | .py | from typing import Optional
from typing_extensions import Literal
from ...._models import BaseModel
__all__ = ["ResponseContentPartDoneEvent", "Part"]
class Part(BaseModel):
audio: Optional[str] = None
"""Base64-encoded audio data (if type is "audio")."""
text: Optional[str] = None
"""The text cont... | 44 | 1,103 |
openai-python | src/openai/types/beta/realtime/response_function_call_arguments_done_event.py | .py | from typing_extensions import Literal
from ...._models import BaseModel
__all__ = ["ResponseFunctionCallArgumentsDoneEvent"]
class ResponseFunctionCallArgumentsDoneEvent(BaseModel):
arguments: str
"""The final arguments as a JSON string."""
call_id: str
"""The ID of the function call."""
event... | 29 | 706 |
openai-python | src/openai/types/beta/realtime/response_audio_transcript_delta_event.py | .py | from typing_extensions import Literal
from ...._models import BaseModel
__all__ = ["ResponseAudioTranscriptDeltaEvent"]
class ResponseAudioTranscriptDeltaEvent(BaseModel):
content_index: int
"""The index of the content part in the item's content array."""
delta: str
"""The transcript delta."""
... | 29 | 686 |
openai-python | src/openai/types/beta/realtime/conversation_item_param.py | .py | from __future__ import annotations
from typing import Iterable
from typing_extensions import Literal, TypedDict
from .conversation_item_content_param import ConversationItemContentParam
__all__ = ["ConversationItemParam"]
class ConversationItemParam(TypedDict, total=False):
id: str
"""
The unique ID of... | 61 | 2,120 |
openai-python | src/openai/types/beta/realtime/conversation_item.py | .py | from typing import List, Optional
from typing_extensions import Literal
from ...._models import BaseModel
from .conversation_item_content import ConversationItemContent
__all__ = ["ConversationItem"]
class ConversationItem(BaseModel):
id: Optional[str] = None
"""
The unique ID of the item, this can be g... | 60 | 2,240 |
openai-python | src/openai/types/beta/realtime/conversation_item_delete_event_param.py | .py | from __future__ import annotations
from typing_extensions import Literal, Required, TypedDict
__all__ = ["ConversationItemDeleteEventParam"]
class ConversationItemDeleteEventParam(TypedDict, total=False):
item_id: Required[str]
"""The ID of the item to delete."""
type: Required[Literal["conversation.it... | 17 | 482 |
openai-python | src/openai/types/beta/realtime/transcription_session_update_param.py | .py | from __future__ import annotations
from typing import List
from typing_extensions import Literal, Required, TypedDict
__all__ = [
"TranscriptionSessionUpdateParam",
"Session",
"SessionClientSecret",
"SessionClientSecretExpiresAt",
"SessionInputAudioNoiseReduction",
"SessionInputAudioTranscript... | 184 | 6,366 |
openai-python | src/openai/types/beta/realtime/conversation_item_create_event.py | .py | from typing import Optional
from typing_extensions import Literal
from ...._models import BaseModel
from .conversation_item import ConversationItem
__all__ = ["ConversationItemCreateEvent"]
class ConversationItemCreateEvent(BaseModel):
item: ConversationItem
"""The item to add to the conversation."""
t... | 28 | 994 |
openai-python | src/openai/types/beta/realtime/input_audio_buffer_speech_started_event.py | .py | from typing_extensions import Literal
from ...._models import BaseModel
__all__ = ["InputAudioBufferSpeechStartedEvent"]
class InputAudioBufferSpeechStartedEvent(BaseModel):
audio_start_ms: int
"""
Milliseconds from the start of all audio written to the buffer during the
session when speech was firs... | 25 | 774 |
openai-python | src/openai/types/beta/realtime/transcription_session_update.py | .py | from typing import List, Optional
from typing_extensions import Literal
from ...._models import BaseModel
__all__ = [
"TranscriptionSessionUpdate",
"Session",
"SessionClientSecret",
"SessionClientSecretExpiresAt",
"SessionInputAudioNoiseReduction",
"SessionInputAudioTranscription",
"Sessio... | 184 | 6,607 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.