{"id":19756842,"url":"https://github.com/imiphp/imi-openai-chatgpt","last_synced_at":"2025-04-30T12:30:56.721Z","repository":{"id":131207645,"uuid":"611600229","full_name":"imiphp/imi-openai-chatgpt","owner":"imiphp","description":"这是一个在 imi 框架接入 OpenAI ChatGPT 的 Demo 项目。","archived":false,"fork":false,"pushed_at":"2023-03-11T01:05:09.000Z","size":16,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-01-31T02:31:30.208Z","etag":null,"topics":["chatgpt","openai","php","swoole"],"latest_commit_sha":null,"homepage":"https://www.imiphp.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imiphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-09T06:42:44.000Z","updated_at":"2023-06-02T10:34:17.000Z","dependencies_parsed_at":"2023-04-06T08:29:21.647Z","dependency_job_id":null,"html_url":"https://github.com/imiphp/imi-openai-chatgpt","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"8d699e37ed8f0d8181bf30556db2ffdd9ce32320"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-openai-chatgpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-openai-chatgpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-openai-chatgpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-openai-chatgpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imiphp","download_url":"https://codeload.github.com/imiphp/imi-openai-chatgpt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224207899,"owners_count":17273674,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt","openai","php","swoole"],"created_at":"2024-11-12T03:17:07.139Z","updated_at":"2024-11-12T03:17:09.338Z","avatar_url":"https://github.com/imiphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 说明\r\n\r\n这是一个在 imi 框架接入 OpenAI ChatGPT 的 Demo 项目。\r\n\r\nOpenAI 的接口使用了 html5 新加入的 `event-stream` 技术，imi 编写的接口同样采用了该技术，可以实现实时返回 AI 回复的内容。\r\n\r\n建议使用 Swoole 最新版本！\r\n\r\nimi 框架：\u003chttps://www.imiphp.com\u003e\r\n\r\nimi 文档：\u003chttps://doc.imiphp.com\u003e\r\n\r\nOpenAI：\u003chttps://platform.openai.com/\u003e\r\n\r\n\u003e 如何注册请自行搜索解决。\r\n\r\n## 安装\r\n\r\n创建项目：`composer create-project imiphp/openai-chatgpt`\r\n\r\n## 配置\r\n\r\n复制 `.env.tpl` 为 `.env`。\r\n\r\n修改 `.env` 配置即可。\r\n\r\n## 运行\r\n\r\n`vendor/bin/imi-swoole swoole/start`\r\n\r\n## 访问测试\r\n\r\n\u003chttp://127.0.0.1:8080/\u003e\r\n\r\n控制器：`Module/Test/ApiController/IndexController.php`\r\n\r\n页面模版：`Module/Test/template/index/index.html`\r\n\r\n## 生产环境\r\n\r\n**关闭热更新：**`config/beans.php` 中 `hotUpdate.status` 设为 `false`\r\n\r\n## 代码质量\r\n\r\n### 格式化代码\r\n\r\n内置 `php-cs-fixer`，统一代码风格。\r\n\r\n配置文件 `.php-cs-fixer.php`，可根据自己实际需要进行配置，文档：\u003chttps://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/config.rst\u003e\r\n\r\n**格式化项目：** `./vendor/bin/php-cs-fixer fix`\r\n\r\n**格式化指定文件：** `./vendor/bin/php-cs-fixer fix test.php`\r\n\r\n### 代码静态分析\r\n\r\n内置 `phpstan`，可规范代码，排查出一些隐藏问题。\r\n\r\n配置文件 `phpstan.neon`，可根据自己实际需要进行配置，文档：\u003chttps://phpstan.org/config-reference\u003e\r\n\r\n**分析项目：** `./vendor/bin/phpstan`\r\n\r\n**分析指定文件：** `./vendor/bin/phpstan test.php`\r\n\r\n### 测试用例\r\n\r\n内置 `phpunit`，可以实现自动化测试。\r\n\r\n**文档：**\u003chttps://phpunit.readthedocs.io/en/9.5/\u003e\r\n\r\n**测试用例 demo：**`tests/Module/Test/TestServiceTest.php`\r\n\r\n**运行测试用例：**`composer test`\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimiphp%2Fimi-openai-chatgpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimiphp%2Fimi-openai-chatgpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimiphp%2Fimi-openai-chatgpt/lists"}