Skip to content

Commit 54d8af2

Browse files
committed
Align docs with AIML examples and update release config
Refactored comments in _version.py to clarify versioning scheme and added release automation marker. Cleaned up release-please-config.json by removing prerelease and extra file settings for improved configuration clarity.
1 parent 2e7055f commit 54d8af2

8 files changed

Lines changed: 146 additions & 149 deletions

File tree

README.md

Lines changed: 93 additions & 114 deletions
Large diffs are not rendered by default.

api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Shared Types
22

3+
> The examples below reference the upstream `openai` namespace. When using the AI/ML API package, you can import the same
4+
> classes and helpers from `aimlapi` while preserving compatibility with the OpenAI SDK surface.
5+
36
```python
47
from openai.types import (
58
AllModels,

helpers.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Structured Outputs Parsing Helpers
22

3-
The OpenAI API supports extracting JSON from the model with the `response_format` request param, for more details on the API, see [this guide](https://platform.openai.com/docs/guides/structured-outputs).
3+
The AI/ML API supports extracting JSON from the model with the `response_format` request param (see [the guide](https://docs.aimlapi.com/guides/structured-outputs)) and remains fully compatible with the upstream OpenAI client surface.
44

55
The SDK provides a `client.chat.completions.parse()` method which is a wrapper over the `client.chat.completions.create()` that
66
provides richer integrations with Python specific types & returns a `ParsedChatCompletion` object, which is a subclass of the standard `ChatCompletion` class.
@@ -13,7 +13,7 @@ into a JSON schema, send it to the API and parse the response content back into
1313
```py
1414
from typing import List
1515
from pydantic import BaseModel
16-
from openai import OpenAI
16+
from aimlapi import AIMLAPI
1717

1818
class Step(BaseModel):
1919
explanation: str
@@ -23,7 +23,7 @@ class MathResponse(BaseModel):
2323
steps: List[Step]
2424
final_answer: str
2525

26-
client = OpenAI()
26+
client = AIMLAPI()
2727
completion = client.chat.completions.parse(
2828
model="gpt-4o-2024-08-06",
2929
messages=[
@@ -45,7 +45,7 @@ else:
4545

4646
The `.parse()` method will also automatically parse `function` tool calls if:
4747

48-
- You use the `openai.pydantic_function_tool()` helper method
48+
- You use the `aimlapi.pydantic_function_tool()` helper method
4949
- You mark your tool schema with `"strict": True`
5050

5151
For example:
@@ -54,7 +54,7 @@ For example:
5454
from enum import Enum
5555
from typing import List, Union
5656
from pydantic import BaseModel
57-
import openai
57+
import aimlapi
5858

5959
class Table(str, Enum):
6060
orders = "orders"
@@ -96,7 +96,7 @@ class Query(BaseModel):
9696
conditions: List[Condition]
9797
order_by: OrderBy
9898

99-
client = openai.OpenAI()
99+
client = aimlapi.AIMLAPI()
100100
completion = client.chat.completions.parse(
101101
model="gpt-4o-2024-08-06",
102102
messages=[
@@ -110,7 +110,7 @@ completion = client.chat.completions.parse(
110110
},
111111
],
112112
tools=[
113-
openai.pydantic_function_tool(Query),
113+
aimlapi.pydantic_function_tool(Query),
114114
],
115115
)
116116

@@ -140,9 +140,9 @@ It also supports all aforementioned [parsing helpers](#structured-outputs-parsin
140140
Unlike `.create(stream=True)`, the `.stream()` method requires usage within a context manager to prevent accidental leakage of the response:
141141

142142
```py
143-
from openai import AsyncOpenAI
143+
from aimlapi import AsyncAIMLAPI
144144

145-
client = AsyncOpenAI()
145+
client = AsyncAIMLAPI()
146146

147147
async with client.chat.completions.stream(
148148
model='gpt-4o-2024-08-06',
@@ -223,7 +223,7 @@ Emitted when a function tool call's arguments are complete.
223223
- `name`: The name of the function being called
224224
- `index`: The index of the tool call
225225
- `arguments`: The full raw JSON string of arguments
226-
- `parsed_arguments`: The fully parsed arguments object. If you used `openai.pydantic_function_tool()` this will be an instance of the given model.
226+
- `parsed_arguments`: The fully parsed arguments object. If you used `aimlapi.pydantic_function_tool()` this will be an instance of the given model.
227227

228228
#### LogprobsContentDeltaEvent
229229

@@ -294,11 +294,11 @@ You can subscribe to events by creating an event handler class and overloading t
294294

295295
```python
296296
from typing_extensions import override
297-
from openai import AssistantEventHandler, OpenAI
298-
from openai.types.beta.threads import Text, TextDelta
299-
from openai.types.beta.threads.runs import ToolCall, ToolCallDelta
297+
from aimlapi import AIMLAPI, AssistantEventHandler
298+
from aimlapi.types.beta.threads import Text, TextDelta
299+
from aimlapi.types.beta.threads.runs import ToolCall, ToolCallDelta
300300

301-
client = openai.OpenAI()
301+
client = AIMLAPI()
302302

303303
# First, we create a EventHandler class to define
304304
# how we want to handle the events in the response stream.

pyproject.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
2-
name = "openai"
2+
name = "aimlapi"
33
version = "2.8.1"
4-
description = "The official Python library for the openai API"
4+
description = "AI/ML API Python SDK"
55
dynamic = ["readme"]
66
license = "Apache-2.0"
77
authors = [
8-
{ name = "OpenAI", email = "support@openai.com" },
8+
{ name = "AI/ML API", email = "help@aimlapi.com" },
99
]
1010
dependencies = [
1111
"httpx>=0.23.0, <1",
@@ -36,11 +36,11 @@ classifiers = [
3636
]
3737

3838
[project.urls]
39-
Homepage = "https://github.com/openai/openai-python"
40-
Repository = "https://github.com/openai/openai-python"
39+
Homepage = "https://docs.aimlapi.com"
40+
Repository = "https://github.com/aimlapi/aimlapi-python"
4141

4242
[project.scripts]
43-
openai = "openai.cli:main"
43+
aimlapi = "aimlapi.cli._cli:main"
4444

4545
[project.optional-dependencies]
4646
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.9"]
@@ -92,7 +92,7 @@ format = { chain = [
9292
"check:ruff" = "ruff check ."
9393
"fix:ruff" = "ruff check --fix ."
9494

95-
"check:importable" = "python -c 'import openai'"
95+
"check:importable" = "python -c 'import aimlapi'"
9696

9797
typecheck = { chain = [
9898
"typecheck:pyright",
@@ -112,7 +112,7 @@ include = [
112112
]
113113

114114
[tool.hatch.build.targets.wheel]
115-
packages = ["src/openai"]
115+
packages = ["src/openai", "src/aimlapi"]
116116

117117
[tool.hatch.build.targets.sdist]
118118
# Basically everything except hidden files/directories (such as .github, .devcontainers, .python-version, etc)
@@ -138,7 +138,7 @@ path = "README.md"
138138
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
139139
# replace relative links with absolute links
140140
pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
141-
replacement = '[\1](https://github.com/openai/openai-python/tree/main/\g<2>)'
141+
replacement = '[\1](https://github.com/aimlapi/aimlapi-python/tree/main/\g<2>)'
142142

143143
[tool.pytest.ini_options]
144144
testpaths = ["tests"]

release-please-config.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
{
2-
"packages": {
3-
".": {}
4-
},
52
"$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json",
63
"include-v-in-tag": true,
74
"include-component-in-tag": false,
8-
"versioning": "prerelease",
9-
"prerelease": true,
105
"bump-minor-pre-major": true,
116
"bump-patch-for-minor-pre-major": false,
127
"pull-request-header": "Automated Release PR",
138
"pull-request-title-pattern": "release: ${version}",
9+
"packages": {
10+
".": {
11+
"release-type": "python",
12+
"package-name": "aimlapi",
13+
"extra-files": [
14+
"pyproject.toml",
15+
"src/aimlapi/_version.py",
16+
"src/openai/_version.py"
17+
]
18+
}
19+
},
1420
"changelog-sections": [
1521
{
1622
"type": "feat",
@@ -58,9 +64,5 @@
5864
"section": "Continuous Integration",
5965
"hidden": true
6066
}
61-
],
62-
"release-type": "python",
63-
"extra-files": [
64-
"src/openai/_version.py"
6567
]
66-
}
68+
}

src/aimlapi/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
AzureAIMLAPIWithStreamedResponse,
3434
Client,
3535
)
36+
from ._client import DEFAULT_BASE_URL
37+
from ._version import __title__, __version__
3638

3739
AzureOpenAI = AzureAIMLAPI
3840
AsyncAzureOpenAI = AsyncAzureAIMLAPI
@@ -55,7 +57,7 @@ def _first_env(*names: str) -> str | None:
5557
organization: str | None = None
5658
project: str | None = None
5759
webhook_secret: str | None = None
58-
base_url: str | httpx.URL | None = _first_env(*_BASE_URL_ENV_VARS)
60+
base_url: str | httpx.URL | None = _first_env(*_BASE_URL_ENV_VARS) or DEFAULT_BASE_URL
5961
websocket_base_url: str | httpx.URL | None = None
6062
timeout: float | Timeout | None = DEFAULT_TIMEOUT
6163
max_retries: int = DEFAULT_MAX_RETRIES
@@ -117,6 +119,8 @@ def _get_default_client() -> AIMLAPI:
117119
dict.fromkeys(
118120
[
119121
*_openai_all,
122+
"__title__",
123+
"__version__",
120124
"AIMLAPI",
121125
"AsyncAIMLAPI",
122126
"AIMLAPIWithRawResponse",

src/aimlapi/_version.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""
2+
Version information for the AI/ML API package.
3+
4+
This project is a fork of the OpenAI Python SDK, and the __version__
5+
value follows the same versioning scheme for compatibility.
6+
"""
7+
8+
__title__ = "aimlapi"
9+
__version__ = "2.8.1" # x-release-please-version

src/aimlapi/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from __future__ import annotations
22

3-
from openai.version import * # noqa: F401, F403
3+
from ._version import * # noqa: F401, F403

0 commit comments

Comments
 (0)