PHPackages                             tourze/open-ai-api-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tourze/open-ai-api-bundle

ActiveSymfony-bundle[API Development](/categories/api)

tourze/open-ai-api-bundle
=========================

1.0.1(5mo ago)00MITPHPCI passing

Since Nov 3Pushed 4mo agoCompare

[ Source](https://github.com/tourze/open-ai-api-bundle)[ Packagist](https://packagist.org/packages/tourze/open-ai-api-bundle)[ RSS](/packages/tourze-open-ai-api-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (33)Versions (3)Used By (0)

OpenAI API Bundle
=================

[](#openai-api-bundle)

[English](README.md) | [中文](README.zh-CN.md)

Introduction
------------

[](#introduction)

OpenAI API Bundle 是一个为 Symfony 应用程序提供 OpenAI API 数据管理功能的 Symfony Bundle。该 Bundle 提供了完整的实体模型、Repository 模式、管理后台集成和数据修复功能，帮助您在 Symfony 项目中高效管理 OpenAI 相关数据。

Installation
------------

[](#installation)

通过 Composer 安装：

```
composer require tourze/open-ai-api-bundle
```

Configuration
-------------

[](#configuration)

在您的 Symfony 应用程序中注册 Bundle：

```
// config/bundles.php
return [
    // ...
    Tourze\OpenAiApiBundle\OpenAiApiBundle::class => ['all' => true],
];
```

Features
--------

[](#features)

- ✅ 完整的 OpenAI 数据实体模型
- 🤖 集成 EasyAdmin 管理后台
- 🔧 依赖注入支持
- 📚 完整的 Repository 模式
- 🎯 状态枚举管理
- 🔍 数据修复工具
- 📊 聊天对话管理

Core Entities
-------------

[](#core-entities)

### 1. AI Model (AI模型)

[](#1-ai-model-ai模型)

- **路径**: `src/Entity/AIModel.php`
- **功能**: 管理 OpenAI 模型配置信息
- **主要字段**:
    - `modelId`: 模型唯一标识符
    - `name`: 模型显示名称
    - `owner`: 模型所有者
    - `status`: 模型状态（可用/不可用/测试中）
    - `contextWindow`: 上下文窗口大小
    - `inputPricePerToken` / `outputPricePerToken`: Token 价格
    - `capabilities`: 模型能力配置

### 2. Assistant (AI助手)

[](#2-assistant-ai助手)

- **路径**: `src/Entity/Assistant.php`
- **功能**: 管理 AI 助手配置
- **主要字段**:
    - `name`: 助手名称
    - `description`: 助手描述
    - `modelId`: 使用的模型
    - `instructions`: 指令集
    - `tools`: 工具配置
    - `status`: 助手状态

### 3. Thread (对话线程)

[](#3-thread-对话线程)

- **路径**: `src/Entity/Thread.php`
- **功能**: 管理对话线程
- **主要字段**:
    - `assistantId`: 关联的助手
    - `title`: 线程标题
    - `status`: 线程状态
    - `metadata`: 元数据

### 4. Chat Conversation (聊天对话)

[](#4-chat-conversation-聊天对话)

- **路径**: `src/Entity/ChatConversation.php`
- **功能**: 管理具体的聊天对话记录

### 5. Uploaded File (上传文件)

[](#5-uploaded-file-上传文件)

- **路径**: `src/Entity/UploadedFile.php`
- **功能**: 管理上传到 OpenAI 的文件

Enums
-----

[](#enums)

Bundle 提供了完整的状态枚举：

- **ModelStatus**: 模型状态管理 (`Available`, `Unavailable`, `Testing`)
- **AssistantStatus**: 助手状态管理
- **ThreadStatus**: 线程状态管理
- **ConversationStatus**: 对话状态管理
- **FileStatus**: 文件状态管理

Admin Controllers
-----------------

[](#admin-controllers)

集成 EasyAdmin Bundle 提供管理后台：

- `AIModelCrudController`: AI 模型管理
- `AssistantCrudController`: AI 助手管理
- `ThreadCrudController`: 对话线程管理
- `ChatConversationCrudController`: 聊天对话管理
- `UploadedFileCrudController`: 上传文件管理

Data Fixtures
-------------

[](#data-fixtures)

提供测试数据生成器：

- `AIModelFixtures`: 生成 AI 模型测试数据
- `AssistantFixtures`: 生成 AI 助手测试数据
- `ThreadFixtures`: 生成对话线程测试数据
- `ChatConversationFixtures`: 生成聊天对话测试数据
- `UploadedFileFixtures`: 生成上传文件测试数据

Requirements
------------

[](#requirements)

- PHP 8.1 或更高版本
- Symfony 7.3 或更高版本
- Doctrine ORM
- EasyAdmin Bundle
- 相关的 Tourze Bundle 依赖

Development
-----------

[](#development)

### Running Tests

[](#running-tests)

```
# 运行单元测试
./vendor/bin/phpunit packages/open-ai-api-bundle/tests

# 运行 PHPStan 静态分析
./vendor/bin/phpstan analyse packages/open-ai-api-bundle
```

### Database Schema

[](#database-schema)

Bundle 提供完整的数据库表结构：

- `openai_ai_models`: OpenAI 模型配置表
- `openai_assistants`: AI 助手表
- `openai_threads`: 对话线程表
- `openai_chat_conversations`: 聊天对话表
- `openai_uploaded_files`: 上传文件表

### Quality Standards

[](#quality-standards)

- PHPStan Level 8 静态分析
- PHPUnit 完整测试覆盖
- 严格的类型声明
- 完整的输入验证

License
-------

[](#license)

MIT License - 详见 [LICENSE](LICENSE) 文件

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance77

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Total

2

Last Release

175d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-open-ai-api-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-open-ai-api-bundle/health.svg)](https://phpackages.com/packages/tourze-open-ai-api-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M308](/packages/easycorp-easyadmin-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
