instruction
stringclasses
100 values
code
stringlengths
78
193k
response
stringlengths
259
170k
file
stringlengths
59
203
Help me write clear docstrings
from html.parser import HTMLParser import json import re from loguru import logger class JSONLDExtractor(HTMLParser): def __init__(self): super().__init__() self.in_jsonld = False self.data = [] # List of all parsed JSON-LD objects self.current_script = [] def handle_startt...
--- +++ @@ -1,3 +1,16 @@+""" +Pure Python metadata extractor - no lxml, no memory leaks. + +This module provides a fast, memory-efficient alternative to extruct for common +e-commerce metadata extraction. It handles: +- JSON-LD (covers 80%+ of modern sites) +- OpenGraph meta tags +- Basic microdata attributes + +Uses P...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/processors/restock_diff/pure_python_extractor.py
Generate docstrings with parameter types
import os import time from loguru import logger from changedetectionio import diff, strtobool from changedetectionio.diff import ( REMOVED_STYLE, ADDED_STYLE, REMOVED_INNER_STYLE, ADDED_INNER_STYLE, REMOVED_PLACEMARKER_OPEN, REMOVED_PLACEMARKER_CLOSED, ADDED_PLACEMARKER_OPEN, ADDED_PLACEMARKER_CLOSED, ...
--- +++ @@ -1,3 +1,9 @@+""" +History/diff rendering for text_json_diff processor. + +This module handles the visualization of text/HTML/JSON changes by rendering +a side-by-side or unified diff view with syntax highlighting and change markers. +""" import os import time @@ -15,6 +21,23 @@ def build_diff_cell_vi...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/processors/text_json_diff/difference.py
Help me document legacy Python code
# HTML to TEXT/JSON DIFFERENCE self.fetcher import hashlib import json import os import re import urllib3 from changedetectionio.conditions import execute_ruleset_against_all_plugins from changedetectionio.content_fetchers.exceptions import checksumFromPreviousCheckWasTheSame from ..base import difference_detection_p...
--- +++ @@ -44,6 +44,7 @@ class FilterConfig: + """Consolidates all filter and rule configurations from watch, tags, and global settings.""" def __init__(self, watch, datastore): self.watch = watch @@ -54,6 +55,7 @@ self._subtractive_selectors_cache = None def _get_merged_rules(sel...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/processors/text_json_diff/processor.py
Write docstrings for this repository
from ..base import difference_detection_processor from ..exceptions import ProcessorException from . import Restock from loguru import logger from changedetectionio.content_fetchers.exceptions import checksumFromPreviousCheckWasTheSame import urllib3 import time urllib3.disable_warnings(urllib3.exceptions.InsecureReq...
--- +++ @@ -129,6 +129,16 @@ def _extract_itemprop_availability_worker(pipe_conn): + """ + Subprocess worker for itemprop extraction (Linux memory management). + + Uses spawn multiprocessing to isolate extruct/lxml memory allocations. + When the subprocess exits, the OS reclaims ALL memory including lxm...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/processors/restock_diff/processor.py
Provide docstrings following PEP 257
from blinker import signal from loguru import logger from typing import Dict, List, Any, Optional import heapq import queue import threading # Janus is no longer required - we use pure threading.Queue for multi-loop support # try: # import janus # except ImportError: # pass # Not needed anymore class Rechec...
--- +++ @@ -13,6 +13,30 @@ class RecheckPriorityQueue: + """ + Thread-safe priority queue supporting multiple async event loops. + + ARCHITECTURE: + - Multiple async workers, each with its own event loop in its own thread + - Hybrid sync/async design for maximum scalability + - Sync interface for ...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/queue_handlers.py
Add documentation for all methods
import shutil from changedetectionio.strtobool import strtobool from changedetectionio.validate_url import is_safe_valid_url from flask import ( flash ) from flask_babel import gettext from ..model import App, Watch from copy import deepcopy from os import path, unlink import json import os import re import sec...
--- +++ @@ -62,6 +62,12 @@ self.reload_state(datastore_path=datastore_path, include_default_watches=include_default_watches, version_tag=version_tag) def save_version_copy_json_db(self, version_tag): + """ + Create version-tagged backup of changedetection.json. + + This is called on ...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/store/__init__.py
Add professional docstrings to my codebase
from abc import ABC, abstractmethod from threading import Lock from loguru import logger class DataStore(ABC): lock = Lock() datastore_path = None @abstractmethod def reload_state(self, datastore_path, include_default_watches, version_tag): pass @abstractmethod def add_watch(self, ...
--- +++ @@ -1,3 +1,8 @@+""" +Base classes for the datastore. + +This module defines the abstract interfaces that all datastore implementations must follow. +""" from abc import ABC, abstractmethod from threading import Lock @@ -5,27 +10,74 @@ class DataStore(ABC): + """ + Abstract base class for all datas...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/store/base.py
Annotate my code with docstrings
import glob import json import os import tempfile import time from loguru import logger from .base import DataStore from .. import strtobool # Try to import orjson for faster JSON serialization try: import orjson HAS_ORJSON = True except ImportError: HAS_ORJSON = False # Fsync configuration: Force file ...
--- +++ @@ -1,3 +1,11 @@+""" +File-based datastore with individual watch persistence and immediate commits. + +This module provides the FileSavingDataStore abstract class that implements: +- Individual watch.json file persistence +- Immediate commit-based persistence (watch.commit(), datastore.commit()) +- Atomic file ...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/store/file_saving_datastore.py
Add docstrings for production code
import timeago from flask_socketio import SocketIO from flask_babel import gettext, get_locale import time import os from loguru import logger from blinker import signal from changedetectionio import strtobool from changedetectionio.languages import get_timeago_locale class SignalHandler: def __init__(self, so...
--- +++ @@ -12,6 +12,7 @@ class SignalHandler: + """A standalone class to receive signals""" def __init__(self, socketio_instance, datastore): self.socketio_instance = socketio_instance @@ -43,6 +44,7 @@ def handle_watch_small_status_update(self, *args, **kwargs): + """Small simple...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/realtime/socket_server.py
Add docstrings to existing functions
from loguru import logger import re def cdata_in_document_to_text(html_content: str, render_anchor_tag_content=False) -> str: from xml.sax.saxutils import escape as xml_escape from .html_tools import html_to_text pattern = '<!\[CDATA\[(\s*(?:.(?<!\]\]>)\s*)*)\]\]>' def repl(m): text = m.gro...
--- +++ @@ -1,9 +1,22 @@+""" +RSS/Atom feed processing tools for changedetection.io +""" from loguru import logger import re def cdata_in_document_to_text(html_content: str, render_anchor_tag_content=False) -> str: + """ + Process CDATA sections in HTML/XML content - inline replacement. + + Args: + ...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/rss_tools.py
Generate docstrings with parameter types
from flask_socketio import emit from loguru import logger from blinker import signal def register_watch_operation_handlers(socketio, datastore): @socketio.on('watch_operation') def handle_watch_operation(data): try: op = data.get('op') uuid = data.get('uuid') ...
--- +++ @@ -4,9 +4,11 @@ def register_watch_operation_handlers(socketio, datastore): + """Register Socket.IO event handlers for watch operations""" @socketio.on('watch_operation') def handle_watch_operation(data): + """Handle watch operations like pause, mute, recheck via Socket.IO""" ...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/realtime/events.py
Write docstrings describing functionality
import asyncio import os import threading import time from concurrent.futures import ThreadPoolExecutor from loguru import logger # Global worker state - each worker has its own thread and event loop worker_threads = [] # List of WorkerThread objects # Track currently processing UUIDs for async workers - maps {uuid...
--- +++ @@ -1,3 +1,9 @@+""" +Worker management module for changedetection.io + +Handles asynchronous workers for dynamic worker scaling. +Each worker runs in its own thread with its own event loop for isolation. +""" import asyncio import os @@ -29,6 +35,7 @@ class WorkerThread: + """Container for a worker t...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/worker_pool.py
Add docstrings to improve collaboration
from wtforms import Field from markupsafe import Markup from flask_babel import lazy_gettext as _l class TernaryNoneBooleanWidget: def __call__(self, field, **kwargs): html = ['<div class="ternary-radio-group pure-form">'] field_id = kwargs.pop('id', field.id) boolean_mode = getatt...
--- +++ @@ -3,6 +3,10 @@ from flask_babel import lazy_gettext as _l class TernaryNoneBooleanWidget: + """ + A widget that renders a horizontal radio button group with either two options (Yes/No) + or three options (Yes/No/Default), depending on the field's boolean_mode setting. + """ def __call__(se...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/widgets/ternary_boolean.py
Create docstrings for API functions
import ipaddress import socket from functools import lru_cache from loguru import logger from urllib.parse import urlparse, urlunparse, parse_qsl, urlencode def normalize_url_encoding(url): try: # Parse the URL into components (scheme, netloc, path, params, query, fragment) parsed = urlparse(url) ...
--- +++ @@ -6,6 +6,30 @@ def normalize_url_encoding(url): + """ + Safely encode a URL's query parameters, regardless of whether they're already encoded. + + Why this is necessary: + URLs can arrive in various states - some with already encoded query parameters (%20 for spaces), + some with unencoded ...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/validate_url.py
Add docstrings that explain inputs and outputs
from blinker import signal from .processors.exceptions import ProcessorException import changedetectionio.content_fetchers.exceptions as content_fetchers_exceptions from changedetectionio.processors.text_json_diff.processor import FilterNotFoundInResponse from changedetectionio import html_tools from changedetectionio ...
--- +++ @@ -21,6 +21,20 @@ DEFER_SLEEP_TIME_ALREADY_QUEUED = 0.3 if IN_PYTEST else 10.0 async def async_update_worker(worker_id, q, notification_q, app, datastore, executor=None): + """ + Async worker function that processes watch check jobs from the queue. + + Args: + worker_id: Unique identifier fo...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/worker.py
Generate NumPy-style docstrings
from functools import lru_cache import arrow from enum import IntEnum class Weekday(IntEnum): Monday = 0 Tuesday = 1 Wednesday = 2 Thursday = 3 Friday = 4 Saturday = 5 Sunday = 6 def am_i_inside_time( day_of_week: str, time_str: str, timezone_str: str, dur...
--- +++ @@ -5,6 +5,7 @@ class Weekday(IntEnum): + """Enumeration for days of the week.""" Monday = 0 Tuesday = 1 Wednesday = 2 @@ -19,6 +20,18 @@ timezone_str: str, duration: int = 15, ) -> bool: + """ + Determines if the current time falls within a specified time range. + ...
https://raw.githubusercontent.com/dgtlmoon/changedetection.io/HEAD/changedetectionio/time_handler.py
Can you add docstrings to this Python file?
#!/usr/bin/env python3 import json import sys from pathlib import Path import yaml def list_servers(configs_dir: Path) -> list[dict]: servers = [] for config_file in sorted(configs_dir.glob("*/.config.yml")): with open(config_file) as f: config = yaml.safe_load(f) if config: ...
--- +++ @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +"""List deployed Algo VPN servers as JSON.""" import json import sys @@ -8,6 +9,7 @@ def list_servers(configs_dir: Path) -> list[dict]: + """Scan configs directory for deployed server metadata.""" servers = [] for config_file in sorted(configs_dir.glo...
https://raw.githubusercontent.com/trailofbits/algo/HEAD/scripts/list_servers.py
Help me comply with documentation standards
#!/usr/bin/python # x25519_pubkey.py - Ansible module to derive a base64-encoded WireGuard-compatible public key # from a base64-encoded 32-byte X25519 private key. # # Why: community.crypto does not provide raw public key derivation for X25519 keys. import base64 from ansible.module_utils.basic import AnsibleModule...
--- +++ @@ -30,6 +30,12 @@ def run_module(): + """ + Main execution function for the x25519_pubkey Ansible module. + + Handles parameter validation, private key processing, public key derivation, + and optional file output with idempotent behavior. + """ module_args = { "private_key_b64...
https://raw.githubusercontent.com/trailofbits/algo/HEAD/library/x25519_pubkey.py
Write Python docstrings for this snippet
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import os from typing import TYPE_CHECKING, Any, Mapping, Callable, Awaitable from typing_extensions import Self, override import httpx from . import _exceptions from ._qs import Querystring from...
--- +++ @@ -125,6 +125,14 @@ # part of our public interface in the future. _strict_response_validation: bool = False, ) -> None: + """Construct a new synchronous OpenAI client instance. + + This automatically infers the following arguments from their corresponding environment variabl...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_client.py
Add documentation for all methods
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Optional from typing_extensions import Literal import httpx from .. import _legacy_response from ..types import batch_list_params, batch_create_params from .._types import Body...
--- +++ @@ -23,13 +23,25 @@ class Batches(SyncAPIResource): + """Create large batches of API requests to run asynchronously.""" @cached_property def with_raw_response(self) -> BatchesWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/batches.py
Generate docstrings for exported functions
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, ...
--- +++ @@ -43,6 +43,17 @@ class LegacyAPIResponse(Generic[R]): + """This is a legacy class as it will be replaced by `APIResponse` + and `AsyncAPIResponse` in the `_response.py` file in the next major + release. + + For the sync client this will mostly be the same with the exception + of `content` &...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_legacy_response.py
Add docstrings to improve readability
from __future__ import annotations import os import re import inspect import functools from typing import ( TYPE_CHECKING, Any, Tuple, Mapping, TypeVar, Callable, Iterable, Sequence, cast, overload, ) from pathlib import Path from datetime import date, datetime from typing_exten...
--- +++ @@ -45,6 +45,12 @@ *, paths: Sequence[Sequence[str]], ) -> list[tuple[str, FileTypes]]: + """Recursively extract files from the given dictionary based on specified paths. + + A path may look like this ['foo', 'files', '<array>', 'data']. + + Note: this mutates the given dictionary. + """ ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_utils/_utils.py
Add docstrings for better understanding
from __future__ import annotations import sys import json 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, Type, ...
--- +++ @@ -118,6 +118,10 @@ class PageInfo: + """Stores the necessary information to build the request to retrieve the next page. + + Either `url` or `params` must be set. + """ url: URL | NotGiven params: Query | NotGiven @@ -165,6 +169,16 @@ class BasePage(GenericModel, Generic[_T]): + ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_base_client.py
Create docstrings for reusable components
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import logging from typing import TYPE_CHECKING, Union, Mapping, cast from typing_extensions import Literal, overload, assert_never import httpx from ... import _legacy_response from ..._types im...
--- +++ @@ -27,13 +27,25 @@ class Translations(SyncAPIResource): + """Turn audio into text or text into audio.""" @cached_property def with_raw_response(self) -> TranslationsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the ra...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/audio/translations.py
Document all endpoints with docstrings
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...
--- +++ @@ -44,6 +44,13 @@ class ChatCompletionStream(Generic[ResponseFormatT]): + """Wrapper over the Chat Completions streaming API that adds helpful + events such as `content.done`, supports automatically parsing + responses & tool calls and accumulates a `ChatCompletion` object + from each individua...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/lib/streaming/chat/_completions.py
Create structured documentation for my script
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import typing_extensions from typing import Union, Iterable, Optional from typing_extensions import Literal import httpx from ... import _legacy_response from ..._types import Body, Omit, Query, ...
--- +++ @@ -33,13 +33,25 @@ class Assistants(SyncAPIResource): + """Build Assistants that can call models and use tools.""" @cached_property def with_raw_response(self) -> AssistantsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/beta/assistants.py
Document functions with clear intent
from __future__ import annotations from abc import ABC, abstractmethod from typing import Generic, TypeVar, Iterable, cast from typing_extensions import override T = TypeVar("T") class LazyProxy(Generic[T], ABC): # Note: we have to special case proxies that themselves return proxies # to support using a pr...
--- +++ @@ -8,6 +8,10 @@ class LazyProxy(Generic[T], ABC): + """Implements data methods to pretend that an instance is another instance. + + This includes forwarding attribute access and other methods. + """ # Note: we have to special case proxies that themselves return proxies # to support usi...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_utils/_proxy.py
Add documentation for all methods
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 ( ...
--- +++ @@ -127,6 +127,24 @@ # Sentinel class used until PEP 0661 is accepted class NotGiven: + """ + For parameters with a meaningful None value, we need to distinguish between + the user explicitly passing None, and the user not passing the parameter at + all. + + User code shouldn't need to use not...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_types.py
Insert docstrings into my code
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from .speech import ( Speech, AsyncSpeech, SpeechWithRawResponse, AsyncSpeechWithRawResponse, SpeechWithStreamingResponse, AsyncSpeechWithStreamingResponse, ) from ..._compa...
--- +++ @@ -35,44 +35,72 @@ class Audio(SyncAPIResource): @cached_property def transcriptions(self) -> Transcriptions: + """Turn audio into text or text into audio.""" return Transcriptions(self._client) @cached_property def translations(self) -> Translations: + """Turn audi...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/audio/audio.py
Write docstrings for backend logic
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import logging from typing import TYPE_CHECKING, List, Union, Mapping, Optional, cast from typing_extensions import Literal, overload, assert_never import httpx from ... import _legacy_response f...
--- +++ @@ -42,13 +42,25 @@ class Transcriptions(SyncAPIResource): + """Turn audio into text or text into audio.""" @cached_property def with_raw_response(self) -> TranscriptionsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + th...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/audio/transcriptions.py
Annotate my code with docstrings
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...
--- +++ @@ -68,9 +68,17 @@ self.close() def close(self) -> None: + """ + Close the response and release the connection. + + Automatically called if the response body is read to completion. + """ self._response.close() def get_final_response(self) -> ParsedRespo...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/lib/streaming/responses/_responses.py
Generate missing documentation strings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Union from typing_extensions import Literal import httpx from ... import _legacy_response from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from ..._u...
--- +++ @@ -26,13 +26,25 @@ class Speech(SyncAPIResource): + """Turn audio into text or text into audio.""" @cached_property def with_raw_response(self) -> SpeechWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response o...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/audio/speech.py
Add clean documentation to messy code
from __future__ import annotations import io import base64 import pathlib from typing import Any, Mapping, TypeVar, cast from datetime import date, datetime from typing_extensions import Literal, get_args, override, get_type_hints as _get_type_hints import anyio import pydantic from ._utils import ( is_list, ...
--- +++ @@ -42,6 +42,15 @@ class PropertyInfo: + """Metadata class to be used in Annotated types to provide information about a given type. + + For example: + + class MyParams(TypedDict): + account_holder_name: Annotated[str, PropertyInfo(alias='accountHolderName')] + + This means that {'account_...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_utils/_transform.py
Document my Python code with docstrings
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 import httpx from ..._utils import is_dict, is_list, consum...
--- +++ @@ -90,13 +90,20 @@ return self.__current_message_snapshot def close(self) -> None: + """ + Close the response and release the connection. + + Automatically called when the context manager exits. + """ if self.__stream: self.__stream.close() ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/lib/streaming/_assistants.py
Write docstrings that follow conventions
# 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...
--- +++ @@ -21,6 +21,7 @@ class Stream(Generic[_T]): + """Provides the core interface to iterate over a synchronous stream response.""" response: httpx.Response _options: Optional[FinalRequestOptions] = None @@ -120,10 +121,16 @@ self.close() def close(self) -> None: + """ + ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_streaming.py
Generate docstrings for script automation
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import httpx from .... import _legacy_response from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from ...._utils import maybe_transform, async_maybe_transform from ...._...
--- +++ @@ -30,10 +30,21 @@ class Sessions(SyncAPIResource): @cached_property def with_raw_response(self) -> SessionsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For mo...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/beta/chatkit/sessions.py
Add docstrings for internal functions
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...
--- +++ @@ -146,6 +146,25 @@ exclude_none: bool = False, warnings: bool = True, ) -> dict[str, object]: + """Recursively generate a dictionary representation of the model, optionally specifying which fields to include or exclude. + + By default, fields that were not set by the API wi...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_models.py
Generate consistent documentation across files
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 httpx from .._types import NOT_GIVEN, Omit, Query, Timeout, NotGiven from .._utils import is_given, is_mapping from .._c...
--- +++ @@ -69,6 +69,10 @@ @override def _prepare_url(self, url: str) -> httpx.URL: + """Adjust the URL if the client was configured with an Azure endpoint + deployment + and the API feature being called is **not** a deployments-based endpoint + (i.e. requires /deployments/deployment-nam...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/lib/azure.py
Add docstrings to improve collaboration
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...
--- +++ @@ -30,6 +30,9 @@ path: tuple[str, ...], root: dict[str, object], ) -> dict[str, Any]: + """Mutates the given JSON schema to ensure it conforms to the `strict` standard + that the API expects. + """ if not is_dict(json_schema): raise TypeError(f"Expected {json_schema} to be a di...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/lib/_pydantic.py
Create simple docstrings for beginners
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import TYPE_CHECKING, Any, Optional, cast from typing_extensions import Literal import httpx from ._utils import is_dict from ._models import construct_type if TYPE_CHECKING: fro...
--- +++ @@ -78,6 +78,7 @@ class APIStatusError(APIError): + """Raised when an API response has a status code of 4xx or 5xx.""" response: httpx.Response status_code: int @@ -156,4 +157,5 @@ ) -class InvalidWebhookSignatureError(ValueError):+class InvalidWebhookSignatureError(ValueError): +...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_exceptions.py
Add documentation for all methods
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 .....
--- +++ @@ -43,6 +43,7 @@ def is_strict_chat_completion_tool_param( tool: ChatCompletionToolUnionParam, ) -> TypeGuard[ChatCompletionFunctionToolParam]: + """Check if the given tool is a strict ChatCompletionFunctionToolParam.""" if not tool["type"] == "function": return False if tool["funct...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/lib/_parsing/_completions.py
Improve documentation using docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 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"...
--- +++ @@ -23,6 +23,7 @@ class SyncPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]): + """Note: no pagination actually occurs yet, this is for forwards-compatibility.""" data: List[_T] object: str @@ -36,10 +37,15 @@ @override def next_page_info(self) -> None: + """ + This ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/pagination.py
Add detailed documentation for each class
from __future__ import annotations import re from typing import Dict, Union, Optional from datetime import date, datetime, timezone, timedelta from .._types import StrBytesIntFloat date_expr = r"(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})" time_expr = ( r"(?P<hour>\d{1,2}):(?P<minute>\d{1,2})" r"(?:...
--- +++ @@ -1,3 +1,7 @@+""" +This file contains code from https://github.com/pydantic/pydantic/blob/main/pydantic/v1/datetime_parse.py +without the Pydantic v1 specific errors. +""" from __future__ import annotations @@ -63,6 +67,15 @@ def parse_datetime(value: Union[datetime, StrBytesIntFloat]) -> datetime: +...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_utils/_datetime_parse.py
Generate documentation strings for clarity
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Any, cast from typing_extensions import Literal import httpx from .... import _legacy_response from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from...
--- +++ @@ -26,10 +26,21 @@ class Threads(SyncAPIResource): @cached_property def with_raw_response(self) -> ThreadsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/beta/chatkit/threads.py
Write docstrings for utility functions
from __future__ import annotations import sys import typing import typing_extensions from typing import Any, TypeVar, Iterable, cast from collections import abc as _c_abc from typing_extensions import ( TypeIs, Required, Annotated, get_args, get_origin, ) from ._utils import lru_cache from .._type...
--- +++ @@ -32,6 +32,7 @@ def is_iterable_type(typ: type) -> bool: + """If the given type is `typing.Iterable[T]`""" origin = get_origin(typ) or typ return origin == Iterable or origin == _c_abc.Iterable @@ -56,6 +57,17 @@ def is_type_alias_type(tp: Any, /) -> TypeIs[typing_extensions.TypeAliasTy...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_utils/_typing.py
Auto-generate documentation strings for this file
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from ..._compat import cached_property from .assistants import ( Assistants, AsyncAssistants, AssistantsWithRawResponse, AsyncAssistantsWithRawResponse, AssistantsWithStreamingR...
--- +++ @@ -52,18 +52,31 @@ @cached_property def assistants(self) -> Assistants: + """Build Assistants that can call models and use tools.""" return Assistants(self._client) @cached_property def threads(self) -> Threads: + """Build Assistants that can call models and use to...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/beta/beta.py
Include argument descriptions in docstrings
from __future__ import annotations import inspect from typing import Any, Callable def function_has_argument(func: Callable[..., Any], arg_name: str) -> bool: sig = inspect.signature(func) return arg_name in sig.parameters def assert_signatures_in_sync( source_func: Callable[..., Any], check_func: ...
--- +++ @@ -5,6 +5,7 @@ def function_has_argument(func: Callable[..., Any], arg_name: str) -> bool: + """Returns whether or not the given function has a specific parameter""" sig = inspect.signature(func) return arg_name in sig.parameters @@ -16,6 +17,7 @@ exclude_params: set[str] = set(), d...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_utils/_reflection.py
Generate helpful docstrings for debugging
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from .threads import ( Threads, AsyncThreads, ThreadsWithRawResponse, AsyncThreadsWithRawResponse, ThreadsWithStreamingResponse, AsyncThreadsWithStreamingResponse, ) from .s...
--- +++ @@ -35,10 +35,21 @@ @cached_property def with_raw_response(self) -> ChatKitWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.g...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/beta/chatkit/chatkit.py
Add docstrings to incomplete code
# 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: ...
--- +++ @@ -23,6 +23,9 @@ def num_examples_validator(df: pd.DataFrame) -> Remediation: + """ + This validator will only print out the number of examples and recommend to the user to increase the number of examples if less than 100. + """ MIN_EXAMPLES = 100 optional_suggestion = ( "" @@ -...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/lib/_validators.py
Insert docstrings into my code
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...
--- +++ @@ -84,6 +84,7 @@ @property def http_request(self) -> httpx.Request: + """Returns the httpx Request instance associated with the current response.""" return self.http_response.request @property @@ -92,6 +93,7 @@ @property def url(self) -> httpx.URL: + """Retur...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/_response.py
Add detailed documentation for each class
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 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 httpx from pydantic import BaseM...
--- +++ @@ -73,10 +73,21 @@ @cached_property def with_raw_response(self) -> RealtimeWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www....
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/beta/realtime/realtime.py
Add docstrings to improve collaboration
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import List from typing_extensions import Literal import httpx from .... import _legacy_response from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ...._utils impor...
--- +++ @@ -23,10 +23,21 @@ class TranscriptionSessions(SyncAPIResource): @cached_property def with_raw_response(self) -> TranscriptionSessionsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/beta/realtime/transcription_sessions.py
Help me write clear docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import List, Union, Iterable from typing_extensions import Literal import httpx from .... import _legacy_response from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven from...
--- +++ @@ -23,10 +23,21 @@ class Sessions(SyncAPIResource): @cached_property def with_raw_response(self) -> SessionsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For mo...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/beta/realtime/sessions.py
Generate consistent docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import httpx from ... import _legacy_response from ..._types import Body, Query, Headers, NotGiven, not_given from ..._compat import cached_property from ..._resource import SyncAPIResource, Async...
--- +++ @@ -22,10 +22,21 @@ class Content(SyncAPIResource): @cached_property def with_raw_response(self) -> ContentWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/skills/content.py
Generate helpful docstrings for debugging
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from .graders import ( Graders, AsyncGraders, GradersWithRawResponse, AsyncGradersWithRawResponse, GradersWithStreamingResponse, AsyncGradersWithStreamingResponse, ) from .....
--- +++ @@ -19,28 +19,52 @@ class Alpha(SyncAPIResource): @cached_property def graders(self) -> Graders: + """Manage fine-tuning jobs to tailor a model to your specific training data.""" return Graders(self._client) @cached_property def with_raw_response(self) -> AlphaWithRawRespon...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/fine_tuning/alpha/alpha.py
Help me document legacy Python code
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import typing_extensions from typing import List from typing_extensions import Literal import httpx from ..... import _legacy_response from ....._types import Body, Omit, Query, Headers, NotGiven...
--- +++ @@ -24,13 +24,25 @@ class Steps(SyncAPIResource): + """Build Assistants that can call models and use tools.""" @cached_property def with_raw_response(self) -> StepsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/beta/threads/runs/steps.py
Provide clean and structured docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Iterable, Optional import httpx from ... import _legacy_response from .items import ( Items, AsyncItems, ItemsWithRawResponse, AsyncItemsWithRawResponse, It...
--- +++ @@ -31,17 +31,30 @@ class Conversations(SyncAPIResource): + """Manage conversations and conversation items.""" @cached_property def items(self) -> Items: + """Manage conversations and conversation items.""" return Items(self._client) @cached_property def with_raw_r...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/conversations/conversations.py
Add detailed documentation for each class
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import typing_extensions from typing import Union, Iterable, Optional from functools import partial from typing_extensions import Literal, overload import httpx from .... import _legacy_response ...
--- +++ @@ -60,21 +60,35 @@ class Threads(SyncAPIResource): + """Build Assistants that can call models and use tools.""" @cached_property def runs(self) -> Runs: + """Build Assistants that can call models and use tools.""" return Runs(self._client) @cached_property def mes...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/beta/threads/threads.py
Add docstrings for utility scripts
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import typing_extensions from typing import Union, Iterable, Optional from typing_extensions import Literal import httpx from .... import _legacy_response from ...._types import Body, Omit, Query...
--- +++ @@ -29,13 +29,25 @@ class Messages(SyncAPIResource): + """Build Assistants that can call models and use tools.""" @cached_property def with_raw_response(self) -> MessagesWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + th...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/beta/threads/messages.py
Generate docstrings for this script
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Optional from typing_extensions import Literal import httpx from .... import _legacy_response from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from ...
--- +++ @@ -35,17 +35,30 @@ class Runs(SyncAPIResource): + """Manage and run evals in the OpenAI platform.""" @cached_property def output_items(self) -> OutputItems: + """Manage and run evals in the OpenAI platform.""" return OutputItems(self._client) @cached_property def ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/evals/runs/runs.py
Add docstrings to my Python code
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import List, Union, Optional from typing_extensions import Literal import httpx from ... import _legacy_response from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, ...
--- +++ @@ -41,10 +41,21 @@ class Calls(SyncAPIResource): @cached_property def with_raw_response(self) -> CallsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more inf...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/realtime/calls.py
Fully document this Python code with docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Dict, Union, Iterable, Optional from typing_extensions import Literal import httpx from .... import _legacy_response from ...._types import Body, Omit, Query, Headers, NotGiven...
--- +++ @@ -35,17 +35,30 @@ class Jobs(SyncAPIResource): + """Manage fine-tuning jobs to tailor a model to your specific training data.""" @cached_property def checkpoints(self) -> Checkpoints: + """Manage fine-tuning jobs to tailor a model to your specific training data.""" return Ch...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/fine_tuning/jobs/jobs.py
Add docstrings for utility scripts
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import typing_extensions from typing import List, Union, Iterable, Optional from functools import partial from typing_extensions import Literal, overload import httpx from ..... import _legacy_re...
--- +++ @@ -59,17 +59,30 @@ class Runs(SyncAPIResource): + """Build Assistants that can call models and use tools.""" @cached_property def steps(self) -> Steps: + """Build Assistants that can call models and use tools.""" return Steps(self._client) @cached_property def wit...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/beta/threads/runs/runs.py
Fully document this Python code with docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from ...._compat import cached_property from .permissions import ( Permissions, AsyncPermissions, PermissionsWithRawResponse, AsyncPermissionsWithRawResponse, PermissionsWithStr...
--- +++ @@ -19,28 +19,52 @@ class Checkpoints(SyncAPIResource): @cached_property def permissions(self) -> Permissions: + """Manage fine-tuning jobs to tailor a model to your specific training data.""" return Permissions(self._client) @cached_property def with_raw_response(self) -> ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/fine_tuning/checkpoints/checkpoints.py
Generate documentation strings for clarity
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import httpx from .. import _legacy_response from .._types import Body, Query, Headers, NotGiven, not_given from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIR...
--- +++ @@ -21,13 +21,25 @@ class Models(SyncAPIResource): + """List and describe the various models available in the API.""" @cached_property def with_raw_response(self) -> ModelsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/models.py
Add docstrings following best practices
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 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 httpx from pydantic import BaseM...
--- +++ @@ -72,10 +72,21 @@ @cached_property def with_raw_response(self) -> RealtimeWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www....
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/realtime/realtime.py
Write docstrings for data processing functions
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import httpx from .... import _legacy_response from ...._types import Body, Query, Headers, NotGiven, not_given from ...._compat import cached_property from ...._resource import SyncAPIResource, A...
--- +++ @@ -22,10 +22,21 @@ class Content(SyncAPIResource): @cached_property def with_raw_response(self) -> ContentWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/skills/versions/content.py
Write Python docstrings for this snippet
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Dict, Union, Iterable, Optional from typing_extensions import Literal, overload import httpx from .. import _legacy_response from ..types import completion_create_params from ....
--- +++ @@ -25,13 +25,27 @@ class Completions(SyncAPIResource): + """ + Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position. + """ @cached_property def with_raw_response(self) -> CompletionsWithRaw...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/completions.py
Help me document legacy Python code
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import json import logging from copy import copy from types import TracebackType from typing import TYPE_CHECKING, Any, List, Type, Union, Iterable, Iterator, Optional, AsyncIterator, cast from fun...
--- +++ @@ -92,10 +92,21 @@ @cached_property def with_raw_response(self) -> ResponsesWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/responses/responses.py
Add docstrings that explain logic
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import inspect from typing import Dict, List, Type, Union, Iterable, Optional, cast from functools import partial from typing_extensions import Literal, overload import httpx import pydantic from...
--- +++ @@ -58,17 +58,34 @@ class Completions(SyncAPIResource): + """ + Given a list of messages comprising a conversation, the model will return a response. + """ @cached_property def messages(self) -> Messages: + """ + Given a list of messages comprising a conversation, the mode...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/chat/completions/completions.py
Help me document legacy Python code
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Union, Iterable import httpx from .. import _legacy_response from ..types import moderation_create_params from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNot...
--- +++ @@ -22,13 +22,27 @@ class Moderations(SyncAPIResource): + """ + Given text and/or image inputs, classifies if those inputs are potentially harmful. + """ @cached_property def with_raw_response(self) -> ModerationsWithRawResponse: + """ + This property can be used as a pref...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/moderations.py
Document all public functions with docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import typing_extensions from typing_extensions import Literal import httpx from .... import _legacy_response from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, no...
--- +++ @@ -29,13 +29,25 @@ class Permissions(SyncAPIResource): + """Manage fine-tuning jobs to tailor a model to your specific training data.""" @cached_property def with_raw_response(self) -> PermissionsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/fine_tuning/checkpoints/permissions.py
Add minimal docstrings for each function
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import httpx from .... import _legacy_response from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from ...._utils import maybe_transform from ...._compat import cached_pr...
--- +++ @@ -22,13 +22,25 @@ class Checkpoints(SyncAPIResource): + """Manage fine-tuning jobs to tailor a model to your specific training data.""" @cached_property def with_raw_response(self) -> CheckpointsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/fine_tuning/jobs/checkpoints.py
Help me document legacy Python code
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing_extensions import Literal import httpx from .... import _legacy_response from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from ...._utils import maybe_tran...
--- +++ @@ -22,13 +22,25 @@ class OutputItems(SyncAPIResource): + """Manage and run evals in the OpenAI platform.""" @cached_property def with_raw_response(self) -> OutputItemsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/evals/runs/output_items.py
Turn comments into proper docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Union, Mapping, cast from typing_extensions import Literal import httpx from ... import _legacy_response from ...types import skill_list_params, skill_create_params, skill_upda...
--- +++ @@ -59,10 +59,21 @@ @cached_property def with_raw_response(self) -> SkillsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.gi...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/skills/skills.py
Fully document this Python code with docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing_extensions import Literal import httpx from .... import _legacy_response from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from ...._utils import maybe_tran...
--- +++ @@ -21,13 +21,27 @@ class Messages(SyncAPIResource): + """ + Given a list of messages comprising a conversation, the model will return a response. + """ @cached_property def with_raw_response(self) -> MessagesWithRawResponse: + """ + This property can be used as a prefix f...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/chat/completions/messages.py
Document my Python code with docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Union, Mapping, Optional, cast from typing_extensions import Literal, overload import httpx from .. import _legacy_response from ..types import image_edit_params, image_generat...
--- +++ @@ -25,13 +25,25 @@ class Images(SyncAPIResource): + """Given a prompt and/or an input image, the model will generate a new image.""" @cached_property def with_raw_response(self) -> ImagesWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/images.py
Help me write clear docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import array import base64 from typing import Union, Iterable, cast from typing_extensions import Literal import httpx from .. import _legacy_response from ..types import embedding_create_params ...
--- +++ @@ -25,13 +25,27 @@ class Embeddings(SyncAPIResource): + """ + Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. + """ @cached_property def with_raw_response(self) -> EmbeddingsWithRawResponse: + """ + This ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/embeddings.py
Document my Python code with docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from ..._compat import cached_property from .jobs.jobs import ( Jobs, AsyncJobs, JobsWithRawResponse, AsyncJobsWithRawResponse, JobsWithStreamingResponse, AsyncJobsWithStrea...
--- +++ @@ -35,6 +35,7 @@ class FineTuning(SyncAPIResource): @cached_property def jobs(self) -> Jobs: + """Manage fine-tuning jobs to tailor a model to your specific training data.""" return Jobs(self._client) @cached_property @@ -47,16 +48,28 @@ @cached_property def with_raw...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/fine_tuning/fine_tuning.py
Add inline docstrings for readability
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Any, List, cast from typing_extensions import Literal import httpx from ... import _legacy_response from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given ...
--- +++ @@ -25,10 +25,21 @@ class InputItems(SyncAPIResource): @cached_property def with_raw_response(self) -> InputItemsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + Fo...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/responses/input_items.py
Generate docstrings with examples
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from .completions.completions import ( Completions, AsyncCompletions, CompletionsWithRa...
--- +++ @@ -19,28 +19,56 @@ class Chat(SyncAPIResource): @cached_property def completions(self) -> Completions: + """ + Given a list of messages comprising a conversation, the model will return a response. + """ return Completions(self._client) @cached_property def wi...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/chat/chat.py
Add return value explanations in docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Mapping, cast from typing_extensions import Literal import httpx from .... import _legacy_response from .content import ( Content, AsyncContent, ContentWithRawRespo...
--- +++ @@ -38,10 +38,21 @@ @cached_property def with_raw_response(self) -> FilesWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.git...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/containers/files/files.py
Add well-formatted docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import httpx from .... import _legacy_response from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from ...._utils import maybe_transform, async_maybe_transform from ...._...
--- +++ @@ -19,13 +19,25 @@ class Graders(SyncAPIResource): + """Manage fine-tuning jobs to tailor a model to your specific training data.""" @cached_property def with_raw_response(self) -> GradersWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/fine_tuning/alpha/graders.py
Document helper functions with docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Iterable, Optional from typing_extensions import Literal import httpx from ... import _legacy_response from ...types import eval_list_params, eval_create_params, eval_update_pa...
--- +++ @@ -35,17 +35,30 @@ class Evals(SyncAPIResource): + """Manage and run evals in the OpenAI platform.""" @cached_property def runs(self) -> Runs: + """Manage and run evals in the OpenAI platform.""" return Runs(self._client) @cached_property def with_raw_response(sel...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/evals/evals.py
Generate docstrings for this script
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Union, Mapping, cast from typing_extensions import Literal import httpx from .... import _legacy_response from .content import ( Content, AsyncContent, ContentWithR...
--- +++ @@ -47,10 +47,21 @@ @cached_property def with_raw_response(self) -> VersionsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www....
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/skills/versions/versions.py
Add detailed documentation for each class
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import time import typing_extensions from typing import Mapping, cast from typing_extensions import Literal import httpx from .. import _legacy_response from ..types import FilePurpose, file_list...
--- +++ @@ -33,13 +33,27 @@ class Files(SyncAPIResource): + """ + Files are used to upload documents that can be used with features like Assistants and Fine-tuning. + """ @cached_property def with_raw_response(self) -> FilesWithRawResponse: + """ + This property can be used as a p...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/files.py
Annotate my code with docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Any, List, Iterable, cast from typing_extensions import Literal import httpx from ... import _legacy_response from ..._types import Body, Omit, Query, Headers, NotGiven, omit, ...
--- +++ @@ -26,13 +26,25 @@ class Items(SyncAPIResource): + """Manage conversations and conversation items.""" @cached_property def with_raw_response(self) -> ItemsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/conversations/items.py
Create structured documentation for my script
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import httpx from ... import _legacy_response from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from ..._utils import maybe_transform, async_maybe_transform from ..._comp...
--- +++ @@ -20,10 +20,21 @@ class ClientSecrets(SyncAPIResource): @cached_property def with_raw_response(self) -> ClientSecretsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/realtime/client_secrets.py
Add docstrings for utility scripts
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Union, Iterable, Optional from typing_extensions import Literal import httpx from ... import _legacy_response from ..._types import Body, Omit, Query, Headers, NotGiven, omit, ...
--- +++ @@ -26,10 +26,21 @@ class InputTokens(SyncAPIResource): @cached_property def with_raw_response(self) -> InputTokensWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/responses/input_tokens.py
Add standardized docstrings across the file
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Mapping, cast import httpx from ... import _legacy_response from ..._types import Body, Query, Headers, NotGiven, FileTypes, not_given from ..._utils import extract_files, mayb...
--- +++ @@ -20,13 +20,25 @@ class Parts(SyncAPIResource): + """Use Uploads to upload large files in multiple parts.""" @cached_property def with_raw_response(self) -> PartsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/uploads/parts.py
Generate descriptive docstrings automatically
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import io import os import logging import builtins from typing import overload from pathlib import Path import anyio import httpx from ... import _legacy_response from .parts import ( Parts, ...
--- +++ @@ -41,17 +41,30 @@ class Uploads(SyncAPIResource): + """Use Uploads to upload large files in multiple parts.""" @cached_property def parts(self) -> Parts: + """Use Uploads to upload large files in multiple parts.""" return Parts(self._client) @cached_property def ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/uploads/uploads.py
Create Google-style docstrings for my code
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import httpx from .... import _legacy_response from ...._types import Body, Query, Headers, NotGiven, not_given from ...._compat import cached_property from ...._resource import SyncAPIResource, A...
--- +++ @@ -22,10 +22,21 @@ class Content(SyncAPIResource): @cached_property def with_raw_response(self) -> ContentWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/containers/files/content.py
Document functions with clear intent
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Iterable from typing_extensions import Literal import httpx from ... import _legacy_response from ...types import container_list_params, container_create_params from ..._types ...
--- +++ @@ -38,10 +38,21 @@ @cached_property def with_raw_response(self) -> ContainersWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://ww...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/containers/containers.py
Generate consistent docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import asyncio from typing import Dict, Iterable, Optional from typing_extensions import Union, Literal from concurrent.futures import Future, ThreadPoolExecutor, as_completed import httpx import ...
--- +++ @@ -31,10 +31,21 @@ class FileBatches(SyncAPIResource): @cached_property def with_raw_response(self) -> FileBatchesWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/vector_stores/file_batches.py
Document all public functions with docstrings
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import List, Optional from typing_extensions import Literal from ..._models import BaseModel __all__ = ["TranscriptionTextDoneEvent", "Logprob", "Usage", "UsageInputTokenDetails"] class Logprob(BaseModel): token: ...
--- +++ @@ -20,6 +20,7 @@ class UsageInputTokenDetails(BaseModel): + """Details about the input tokens billed for this request.""" audio_tokens: Optional[int] = None """Number of audio tokens billed for this request.""" @@ -29,6 +30,7 @@ class Usage(BaseModel): + """Usage statistics for models...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/types/audio/transcription_text_done_event.py
Create docstrings for each class method
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import Union, Iterable, Optional from typing_extensions import Literal, Required, TypeAlias, TypedDict from ..._types import SequenceNotStr from ..shared.chat_model import ChatModel fr...
--- +++ @@ -141,6 +141,10 @@ class ToolResourcesFileSearchVectorStoreChunkingStrategyAuto(TypedDict, total=False): + """The default strategy. + + This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. + """ type: Required[Literal["auto"]] """Always ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/types/beta/assistant_create_params.py
Add docstrings to improve collaboration
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations from typing import TYPE_CHECKING, Dict, Union, Optional from typing_extensions import Literal, assert_never import httpx from ... import _legacy_response from ...types import FileChunkingStrategy...
--- +++ @@ -28,10 +28,21 @@ class Files(SyncAPIResource): @cached_property def with_raw_response(self) -> FilesWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more inf...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/vector_stores/files.py
Add docstrings including usage examples
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import List, Union, Optional from typing_extensions import Literal, Annotated, TypeAlias from ..._utils import PropertyInfo from ..._models import BaseModel __all__ = ["Transcription", "Logprob", "Usage", "UsageTokens",...
--- +++ @@ -21,6 +21,7 @@ class UsageTokensInputTokenDetails(BaseModel): + """Details about the input tokens billed for this request.""" audio_tokens: Optional[int] = None """Number of audio tokens billed for this request.""" @@ -30,6 +31,7 @@ class UsageTokens(BaseModel): + """Usage statistic...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/types/audio/transcription.py
Generate docstrings with examples
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations import hmac import json import time import base64 import hashlib from typing import cast from ..._types import HeadersLike from ..._utils import get_required_header from ..._models import construc...
--- +++ @@ -27,6 +27,7 @@ *, secret: str | None = None, ) -> UnwrapWebhookEvent: + """Validates that the given payload was sent by OpenAI and parses the payload.""" if secret is None: secret = self._client.webhook_secret @@ -48,6 +49,14 @@ secret: str | None ...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/resources/webhooks/webhooks.py
Create docstrings for each class method
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import List, Optional from typing_extensions import Literal from ..._models import BaseModel from .transcription_word import TranscriptionWord from .transcription_segment import TranscriptionSegment __all__ = ["Transcri...
--- +++ @@ -11,6 +11,7 @@ class Usage(BaseModel): + """Usage statistics for models billed by audio input duration.""" seconds: float """Duration of the input audio in seconds.""" @@ -20,6 +21,9 @@ class TranscriptionVerbose(BaseModel): + """ + Represents a verbose json transcription respons...
https://raw.githubusercontent.com/openai/openai-python/HEAD/src/openai/types/audio/transcription_verbose.py