
3 月 8 日妇女节,来一场职场姐妹茶话会!欢迎加入群聊

EasyAdmin8在EasyAdmin的基础上,使用ThinkPHP v8.1重构,并且开发了Laravel和webman等框架的版本,是市面上常用PHP框架的快速开发后台管理系统。
在最新版本中,项目已经接入AI功能,并且支持千问、豆包、DeepSeek等市场主流AI接口对接和自定义AI模型的接口对接
- 对应AI composer包介绍
php-ai
Require
- PHP 8.1+
- GuzzleHttp 7.9.0+
Installation
composer require wolfcode/php-ai
Demo
<?php namespace App\Demo; use Wolfcode\Ai\Enum\AiType; use Wolfcode\Ai\Service\AiChatService; class Demo{ public function test() { $single = AiChatService::instance(); $result = $single // 当使用推理模型时,可能存在超时的情况,所以需要设置超时时间为 0 // ->setTimeLimit(0) // 请替换为您需要的模型类型 ->setAiType(AiType::QWEN) // 如果需要指定模型的 API 地址,可自行设置 // ->setAiUrl('https://xxx.com') // 请替换为您的模型 ->setAiModel('qwen-plus') // 请替换为您的 API KEY ->setAiKey('sk-1234567890') // 此内容会作为系统提示,会影响到回答的内容 当前仅作为测试使用 ->setSystemContent('你现在是一位资深的海外电商产品经理') ->chat('who are you ?'); $result2 = $single // 当使用推理模型时,可能存在超时的情况,所以需要设置超时时间为 0 // ->setTimeLimit(0) // 请替换为您需要的模型类型 ->setAiType(AiType::DOUBAO) // 如果需要指定模型的 API 地址,可自行设置 // ->setAiUrl('https://xxx.com') // 请替换为您的模型 ->setAiModel('doubao-1-5-pro-32k-250115') // 请替换为您的 API KEY ->setAiKey('sk-1234567890') // 此内容会作为系统提示,会影响到回答的内容 当前仅作为测试使用 ->setSystemContent('你现在是一位资深的海外电商产品经理') ->chat('who are you ?'); $result3 = $single // 当使用推理模型时,可能存在超时的情况,所以需要设置超时时间为 0 ->setTimeLimit(0) // 请替换为您需要的模型类型 ->setAiType(AiType::DEEPSEEK) // 如果需要指定模型的 API 地址,可自行设置 // ->setAiUrl('https://xxx.com') // 请替换为您的模型 ->setAiModel('deepseek-reasoner') // 请替换为您的 API KEY ->setAiKey('sk-1234567890') // 此内容会作为系统提示,会影响到回答的内容 当前仅作为测试使用 ->setSystemContent('你现在是一位资深的海外电商产品经理') ->chat('who are you ?'); // 当 AiType 不在枚举范围内时,可自行设置 $resultCustom = $single->customChat([ 'url' => 'https://api.siliconflow.cn/v1/chat/completions', 'key' => 'sk-1234567890', 'model' => 'deepseek-ai/DeepSeek-R1', 'messages' => [ ['role' => 'system', 'content' => '你是一个AI助手'], ['role' => 'user', 'content' => '高斯的主要成就有哪些?'], ] ] ); } }
还没有评论,来说两句吧...