Skip to main content

ErisPulse-OpenAI 模块文档

简介

ErisPulse-OpenAI 是一个 OpenAI 通用接口的封装模块,提供了便捷的异步接口来与 OpenAI API 交互。

使用示例

基本使用

from ErisPulse import sdk

# 初始化模块
openai = sdk.OpenAI

# 同步聊天
messages = [{"role": "user", "content": "你好"}]
response = await openai.chat(messages)
print(response)

# 流式聊天
async for chunk in openai.chat_stream(messages):
    print(chunk, end="", flush=True)

自定义配置

# 自定义模型和参数
response = await openai.chat(
    messages,
    model="gpt-4",
    temperature=0.5,
    max_tokens=500
)

流式处理回调

async def handle_stream(content):
    print(content, end="", flush=True)

response = await openai.chat(
    messages,
    stream=True,
    stream_handler=handle_stream
)

API 参考

chat(messages, model=None, stream=False, stream_handler=None, **kwargs)

  • messages: List[Dict[str, str]] - 对话消息列表
  • model: Optional[str] - 指定模型,默认为配置中的模型
  • stream: bool - 是否使用流式响应
  • stream_handler: Optional[Callable] - 流式响应的回调函数
  • **kwargs: 其他 OpenAI API 参数
  • 返回: str - AI 响应内容

chat_stream(messages, model=None, **kwargs)

  • messages: List[Dict[str, str]] - 对话消息列表
  • model: Optional[str] - 指定模型,默认为配置中的模型
  • **kwargs: 其他 OpenAI API 参数
  • 返回: AsyncGenerator[str, None] - 流式响应生成器

配置说明

需要在项目的 config.toml 中配置OpenAI相关参数

参考链接

Metadata

Release files for ErisPulse-OpenAI 2.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ErisPulse-OpenAI 2.1.3
File Size Uploaded
erispulse_openai-2.1.3.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ErisPulse-OpenAI 2.1.3
File Interpreter ABI Platform
erispulse_openai-2.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 8.9 kB

Release files / erispulse_openai-2.1.3.tar.gz

Download URL erispulse_openai-2.1.3.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ecbefe0caba80b661770523a237beac21815a0cd6b3ffc62030ef882d56274ca
BLAKE2b-256 checksum
How to use checksums
242a88e2c6719a7e4a9c4e571aa693aa74c3ea32d0f697011ea4fccb78969b11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 17, 2025.

Transparency log

Release files / erispulse_openai-2.1.3-py3-none-any.whl

Download URL erispulse_openai-2.1.3-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
86254edf876cbdf2061bd477a3b5270f271dee17d6be1872621225accc5e9a0d
BLAKE2b-256 checksum
How to use checksums
dc957ee72f629065cd99c687d3465db6c9e65d57c0fa6de33772664d19634a9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 17, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

2.1.3 This release

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page