更新记录
1.0(2025-03-15) 下载此版本
无
平台兼容性
uni-app
| Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
|---|---|---|---|---|---|---|---|---|
| √ | √ | √ | √ | √ | - | - | - | - |
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
|---|---|---|---|---|---|---|---|---|---|---|
| √ | - | - | - | - | - | - | - | - | - | - |
其他
| 多语言 | 暗黑模式 | 宽屏模式 |
|---|---|---|
| × | × | √ |
插件概述
支持接入多种主流的 AI 模型平台,支持上下文对话
SSE 流式响应,实现实时交互,快速实时响应
统一接口文件在每个.js文件更改自己接口
可以只保留chat.vue对话功能
使用说明
导入本包到HBuilder X内
修改chat.vue文件,接口地址改为自己的即可
// 启动SSE连接
this.$refs.chatSSEClientRef.startChat({
url: '接口地址',
headers: {
'content-type': 'application/json',
},
接口响应格式
火山方舟的DeepSeek接口API举例 reasoning_content深度思考
data: {"reasoning_content":"嗯"}
data: {"reasoning_content":"用"}
data: {"reasoning_content":"户问"}
data: {"content":"你"}
data: {"content":"好"}
data: {"content":"我是"}
data: {"content":"智能"}
PHPSSE流式输出示例
//服务端提供调用百炼应用模型流式API转发至客户端 案例
public function getBailianStream(){
$bailian_appid = '123123';
$bailian_apikey = '123123';
$prompt = '你是谁';
// 设置响应头
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
header('Connection: keep-alive');
header('X-Accel-Buffering: no');
while (ob_get_level() > 0) {
ob_end_flush();
}
set_time_limit(0);
ob_implicit_flush(true);
$url = "https://dashscope.aliyuncs.com/api/v1/apps/{$bailian_appid}/completion";
$data = [
"input" => ['prompt' => $prompt],
"parameters" => [
'has_thoughts'=>true,
'incremental_output' => true
],
'debug'=>[]
];
$dataString = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_WRITEFUNCTION, function ($ch, $string) {
$lines = explode("\n", $string);
foreach ($lines as $line) {
if (str_starts_with($line, 'data: ')) {
$jsonData = substr($line, 6);
$decoded = json_decode($jsonData, true);
if ($decoded && isset($decoded['choices'][0]['delta']['content'])) {
$content = $decoded['choices'][0]['delta']['content'];
$newData = ['content' => $content];
echo 'data: '. json_encode($newData). "\n";
}
}
}
flush();
return strlen($string);
});
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: Bearer '.$bailian_apikey,
'X-DashScope-SSE: enable'
]);
$response = curl_exec($ch);
if ($response === false) {
$this->error('连接异常,请查看百炼应用相关设置!');
}
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status_code != 200) {
$this->error('连接异常,请查看百炼应用相关设置!');
}
flush();
}

收藏人数:
下载插件并导入HBuilderX
下载插件ZIP
下载 383
赞赏 0
下载 10799834
赞赏 1798
赞赏
京公网安备:11010802035340号