Metadata-Version: 2.4
Name: ErisPulse-OpenAI
Version: 2.1.0
Summary: ErisPulse OpenAI 通用接口封装模块
Author-email: wsu2059q <wsu2059@qq.com>
License: MIT License
        
        Copyright (c) 2025 wsu2059q
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: homepage, https://github.com/ErisPulse/ErisPulse-OpenAI
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: openai
Dynamic: license-file

# ErisPulse-OpenAI 模块文档

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

## 使用示例

### 基本使用
```python
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)
```

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

### 流式处理回调
```python
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相关参数

## 参考链接
- [ErisPulse 主库](https://github.com/ErisPulse/ErisPulse/)
