Skip to content

[UNOFFICIAL] Doc release for v1.13.0 library release #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions .github/workflows/create-releases.yml

This file was deleted.

8 changes: 6 additions & 2 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# workflow for re-running publishing to PyPI in case it fails for some reason
# you can run this workflow by navigating to https://www.github.com/openai/openai-python/actions/workflows/publish-pypi.yml
# This workflow is triggered when a GitHub release is created.
# It can also be run manually to re-publish to PyPI in case it failed for some reason.
# You can run this workflow by navigating to https://www.github.com/openai/openai-python/actions/workflows/publish-pypi.yml
name: Publish PyPI
on:
workflow_dispatch:

release:
types: [published]

jobs:
publish:
name: publish
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ jobs:
run: |
bash ./bin/check-release-environment
env:
STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }}
PYPI_TOKEN: ${{ secrets.OPENAI_PYPI_TOKEN || secrets.PYPI_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ codegen.log

# Ignore the MkDocs build artifact directory
site/

# Random ignores
.DS_Store
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.12.0"
".": "1.13.0"
}
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## 1.13.0 (2024-02-19)

Full Changelog: [v1.12.0...v1.13.0](https://github.com/openai/openai-python/compare/v1.12.0...v1.13.0)

### Features

* **api:** updates ([#1146](https://github.com/openai/openai-python/issues/1146)) ([79b7675](https://github.com/openai/openai-python/commit/79b7675e51fb7d269a6ea281a568bc7812ba2ace))


### Bug Fixes

* **api:** remove non-GA instance_id param ([#1164](https://github.com/openai/openai-python/issues/1164)) ([1abe139](https://github.com/openai/openai-python/commit/1abe139b1a5f5cc41263738fc12856056dce5697))


### Chores

* **ci:** move github release logic to github app ([#1155](https://github.com/openai/openai-python/issues/1155)) ([67cfac2](https://github.com/openai/openai-python/commit/67cfac2564dfb718da0465e34b90ac6928fa962a))
* **client:** use correct accept headers for binary data ([#1161](https://github.com/openai/openai-python/issues/1161)) ([e536437](https://github.com/openai/openai-python/commit/e536437ae0b2cb0ddf2d74618722005d37403f32))
* **internal:** refactor release environment script ([#1158](https://github.com/openai/openai-python/issues/1158)) ([7fe8ec3](https://github.com/openai/openai-python/commit/7fe8ec3bf04ecf85e3bd5adf0d9992c051f87b81))

## 1.12.0 (2024-02-08)

Full Changelog: [v1.11.1...v1.12.0](https://github.com/openai/openai-python/compare/v1.11.1...v1.12.0)
Expand Down
8 changes: 2 additions & 6 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

errors=()

if [ -z "${STAINLESS_API_KEY}" ]; then
errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organization secrets on GitHub.")
fi

if [ -z "${PYPI_TOKEN}" ]; then
errors+=("The OPENAI_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
fi

len=${#errors[@]}
lenErrors=${#errors[@]}

if [[ len -gt 0 ]]; then
if [[ lenErrors -gt 0 ]]; then
echo -e "Found the following errors in the release environment:\n"

for error in "${errors[@]}"; do
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Welcome to Marsh's totally unofficial and totally unsupported documentation for

## About these docs

These docs are officially unofficial and unsupported, but you're welcome to use and improve them until OpenAI brings up their own (1) or they ask me to take them down.
These docs are officially unofficial, but you're welcome to use and improve them until OpenAI brings up their own (1) or they ask me to take them down.
{ .annotate }

1. I'll likely decommission this site when OpenAI [publishes their own Python API reference](https://community.openai.com/t/where-is-the-documentation-for-the-python-openai-sdk/583643).
Expand All @@ -30,4 +30,4 @@ That said, I use these docs myself and thus intend to keep them (mostly) current

1. That means you might encounter inaccuracies or you might not find what you think should be here. In either case, you should refer to [openai/openai-python](https://github.com/openai/openai-python) as the source of truth.

:material-hand-wave: *Enjoy!* —[Marsh](https://github.com/mmacy)
:material-peace: *Enjoy!* —[Marsh](https://github.com/mmacy)
86 changes: 86 additions & 0 deletions docs/reference/include/openai.resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""Snippets in this docstring are ingested by other documentation (including library docstrings) during the MkDocs build process.

# --8<-- [start:audio]
The `audio` module provides classes for handling various audio processing operations, including transcription of audio to text, translation of spoken content, and speech synthesis.

This module supports synchronous and asynchronous operations, and offers interfaces for direct interaction with audio data, as well as handling of raw and streaming responses. Designed for applications that require audio input processing like automated transcription services, real-time translation of spoken language, and generating spoken content from text.
# --8<-- [end:audio]

# --8<-- [start:beta]
The `beta` modules provides a unified interface for accessing beta features of the API, encapsulating synchronous and asynchronous access to resources in beta.

The module aggregates the beta functionalities related to features like yet considered generally available (GA), offering a simplified entry point for interacting with these resources. It is designed to facilitate easy access to the cutting-edge features still under development, enabling developers to experiment with and leverage new capabilities before they become GA.
# --8<-- [end:beta]

# --8<-- [start:chat]
The `chat` module provides classes for creating and managing chat sessions that leverage OpenAI's language models to generate conversational responses.

The module supports both synchronous and asynchronous operations, offering interfaces for direct interaction with the completion endpoints tailored for chat applications. Designed for developers looking to integrate AI-powered chat functionalities into their applicationsand features like raw and streaming response handling for more flexible integration.
# --8<-- [end:chat]

# --8<-- [start:chat_completions]
The `chat.completions` module provides access to the chat completions endpoint of the OpenAI API. It supports
the latest models including `gpt-4`, `gpt-4-turbo-preview`, `gpt-4-vision-preview`, `gpt-4-32k`, `gpt-3.5-turbo`,
and their respective dated model releases, along with fine-tuned versions of `gpt-3.5-turbo`.

This module interacts with the `/v1/chat/completions` endpoint and replaces the the legacy [`resources.completions`][src.openai.resources.completions] module. You're *strongly encouraged* to migrate existing applications that use the legacy `resources.completions` module to this one before the expected [deprecation](https://platform.openai.com/docs/deprecations) of the `/v1/completions` endpoint.
# --8<-- [end:chat_completions]

# --8<-- [start:completions]
The `completions` module provides access to the legacy completions endpoint of the OpenAI API. Use the [`chat.completions`][src.openai.resources.chat.completions] module instead for new applications.

This module interacts with a [legacy](https://platform.openai.com/docs/deprecations) endpoint, `/v1/completions`, indicating that the endpoint no longer receives updates and is expected to be deprecated. This module is for use only in applications that require compatibility with the legacy endpoint and should **not** be used for new projects.

You're *strongly encouraged* to migrate existing applications to the [`chat.completions`][src.openai.resources.chat.completions] module⁠—which interacts with the current (non-legacy) `/v1/chat/completions` endpoint—prior to the [deprecation](https://platform.openai.com/docs/deprecations) of the `/v1/completions` endpoint.
# --8<-- [end:completions]

# --8<-- [start:embeddings]
The `embeddings` module provides classes for creating embeddings from text inputs using OpenAI's models and supports both synchronous and asynchronous operations as well as the handling of raw responses and streaming response capabilities.

The module is appropriate for use in applications that require semantic analysis of text, like similarity searches, text clustering, and other natural language processing tasks that can benefit from high-dimensional vector representations of text.
# --8<-- [end:embeddings]

# --8<-- [start:files]
The `files` module provides classes for uploading, retrieving, listing, and deleting files used across various OpenAI API endpoints.

The module supports both synchronous and asynchronous operations, along with handling of raw responses and streaming of file content. Designed for use cases that involve managing large datasets or files for purposes like fine-tuning models or using assistants, this module facilitates the efficient handling of file-related operations on the OpenAI platform.
# --8<-- [end:files]

# --8<-- [start:fine_tuning]
The `fine_tuning` module provides classes for handling fine-tuning operations, including the initiation, management, and retrieval of fine-tuning jobs.

The module supports synchronous and asynchronous operations, offering interfaces for working with jobs directly, as well as with raw or streaming responses. Designed for use in applications requiring custom model training on specific datasets to improve model performance for tailored tasks.
# --8<-- [end:fine_tuning]

# --8<-- [start:fine_tuning_jobs]
The `jobs` module provides synchronous and asynchronous access to fine-tuning job resources and enables you to create, retrieve, list, and cancel fine-tuning jobs and list the events associated with them.

Fine-tuning jobs allow you to customize pre-trained models with your own datasets, optimizing performance for specific tasks or improving understanding of particular data types. The classes in the `jobs` module includes methods for managing fine-tuning jobs, like creating a new job, fetching details of an existing job, listing all jobs, canceling a job, and listing events associated with a job.
# --8<-- [end:fine_tuning_jobs]

# --8<-- [start:images]
The `image` module provides functionality for creating variations of images, editing images based on textual prompts, and generating new images from prompts using specified models.

The module supports both synchronous and asynchronous operations, with capabilities for handling raw responses and streaming. Suitable for applications requiring dynamic image generation or modification through the OpenAI API, this module leverages models like DALL-E to interpret text prompts into visual content.
# --8<-- [end:images]

# --8<-- [start:models]
The `models` module facilitates the retrieval, listing, and deletion of models on the OpenAI platform and supports both synchronous and asynchronous operations.

The module enables developers to interact with models, providing functionalities like fetching detailed information about a specific model, listing all available models, and deleting fine-tuned models.
# --8<-- [end:models]

# --8<-- [start:moderations]
The `moderations` module provides functionality to submit text for moderation to determine whether it violates OpenAI's content policy.

Moderation is particularly useful for developers looking to ensure the content generated or processed by their applications adheres to OpenAI's content policy. By leveraging the content moderation models provided by OpenAI, applications can automatically classify and filter out text that might be considered harmful or inappropriate.
# --8<-- [end:moderations]

# --8<-- [start:assistants]
The `assistants` module offers functionalities to create, retrieve, update, list, and delete Assistants. Assistants are AI models configured to perform specific tasks based on instructions, files, and other parameters.
# --8<-- [end:assistants]

# --8<-- [start:threads]
The `threads` module facilitates the creation, retrieval, update, deletion, and execution of Threads. Threads represent a series of messages or interactions with an assistant and support a conversational context or a sequence of operations.
# --8<-- [end:threads]
"""
28 changes: 28 additions & 0 deletions docs/reference/include/openai_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Snippets in this docstring are ingested by other documentation (including library docstrings) during the MkDocs build process.

# --8<-- [start:openai]
The [openai](https://pypi.org/project/openai/) package is the core library to install in Python projects that need
to call the [OpenAI REST API](https://platform.openai.com/docs/api-reference). It inclues modules for working with OpenAI
resources that provide access to its AI [models](https://platform.openai.com/docs/models),
including large language models (LLMs) like GPT-4 and models for working with images and audio. The `openai` package
provides both synchronous and asynchronous API clients, options to configure their behavior, and modules that provide
Python code with an API surface to interact with the OpenAI platform.

To get started, check out the documentation for the module representing the [resource][src.openai.resources] you're interested in using for your
project. For example, the [`resources.chat.completions`][src.openai.resources.chat.completions] module is what you'd use
for conversational chat-style interactions with an LLM like [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo).
Or, maybe you need the [`resources.audio`][src.openai.resources.audio] module for performing audio transcription, translation, and
speech synthesis in your app.

Documentation for the library's main API client classes, [`OpenAI`][src.openai.OpenAI] and
[`AsyncOpenAI`][src.openai.AsyncOpenAI], is another good place to start. The clients are the primary contact point for
your code that needs to work with any of the resources available on OpenAI API endpoints.

For more information about the REST API this package talks to or to find client libraries for other programming
languages, see:

- [REST API reference documentation](https://platform.openai.com/docs/api-reference) for the OpenAPI REST API (platform.openai.com)
- [OpenAPI Description (OAD)](https://github.com/openai/openai-openapi) file for the OpenAPI REST API (GitHub)
- More [client libraries](https://platform.openai.com/docs/libraries) for the OpenAI API (platform.openai.com)
# --8<-- [end:openai]
"""
4 changes: 3 additions & 1 deletion docs/reference/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# openai

::: src.openai
::: src.openai
options:
docstring_section_style: spacy
6 changes: 4 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ watch: [README.md, src/openai]
theme:
name: material
icon:
repo: fontawesome/brands/github
repo: fontawesome/brands/git-alt

palette:
- media: "(prefers-color-scheme: light)"
Expand Down Expand Up @@ -68,6 +68,8 @@ markdown_extensions:
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences
- pymdownx.tasklist:
custom_checkbox: true

plugins:
- search
Expand Down Expand Up @@ -98,7 +100,7 @@ plugins:
inherited_members: false
merge_init_into_class: true
separate_signature: true
show_bases: true
show_bases: false
show_if_no_docstring: true
show_root_full_path: false
show_root_heading: false
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openai"
version = "1.12.0"
version = "1.13.0"
description = "The official Python library for the openai API"
readme = "README.md"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/openai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# File generated from our OpenAPI spec by Stainless.

""" --8<-- 'docs/reference/include/openai_init.py:openai' """
from __future__ import annotations

import os as _os
Expand Down
6 changes: 2 additions & 4 deletions src/openai/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ def __init__(


class BasePage(GenericModel, Generic[_T]):
"""
Defines the core interface for pagination.
"""Defines the core interface for pagination.

Type Args:
ModelT: The pydantic model that represents an item in the response.
Expand Down Expand Up @@ -419,8 +418,7 @@ def _build_headers(self, options: FinalRequestOptions) -> httpx.Headers:
return headers

def _prepare_url(self, url: str) -> URL:
"""
Merge a URL argument together with any 'base_url' on the client,
"""Merge a URL argument together with any 'base_url' on the client,
to create the URL used for the outgoing request.
"""
# Copied from httpx's `_merge_url` method.
Expand Down
Loading