fixed
This commit is contained in:
85
digital_doctor/application/api/controller/Reportty.php
Normal file
85
digital_doctor/application/api/controller/Reportty.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/*
|
||||
* description:
|
||||
* author:wh
|
||||
* email:
|
||||
* createTime:{2024/7/12} {11:29}
|
||||
*/
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use think\Db;
|
||||
use wanghua\general_utility_tools_php\gpt\chat\ChatGPT;
|
||||
use wanghua\general_utility_tools_php\Mmodel;
|
||||
use wanghua\general_utility_tools_php\tool\Tools;
|
||||
|
||||
/**
|
||||
* 听译-报告
|
||||
* Class Reportty
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class Reportty
|
||||
{
|
||||
|
||||
/**
|
||||
* desc:获取报告
|
||||
*
|
||||
* curl --location --request POST 'https://serverfastgpt.excn.top/api/v1/chat/completions' \
|
||||
--header 'Authorization: Bearer fastgpt-e5wq9u6phvyfq4znrXfOuTHKHQHGjpcVBYay602ai5zv4HeOJRMDwT3ptm6' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"stream": false,
|
||||
"detail": false,
|
||||
"messages": [
|
||||
{
|
||||
"content": "医患对话内容",
|
||||
"role": "user"
|
||||
}
|
||||
]
|
||||
}'
|
||||
*
|
||||
* author:wh
|
||||
* @return mixed
|
||||
*/
|
||||
function getReport(){
|
||||
header('Content-Type: text/event-stream');
|
||||
header('Cache-Control: no-cache');
|
||||
header('Connection: keep-alive');
|
||||
header('X-Accel-Buffering: no');
|
||||
$config = config('ai_report_config');
|
||||
|
||||
$question = '';//input('question','');
|
||||
|
||||
$chatobj = new ChatGPT();
|
||||
$chatobj->url = $config['base_url'];
|
||||
$chatobj->model = '';
|
||||
$chatobj->apiKey = $config['APIKey'].':'.$config['APISecret'];
|
||||
|
||||
$answer_json_arr = [];
|
||||
|
||||
$ticket = input('ticket');
|
||||
if(empty($ticket)){
|
||||
|
||||
return json(Tools::set_fail('ticket必须'));
|
||||
}
|
||||
$user = Db::table('fa_users')->where('ticket',$ticket)->find();
|
||||
if(empty($user)){
|
||||
return json(Tools::set_fail('用户不存在'));
|
||||
}
|
||||
$his_record = Db::table('fa_ty_chathistory')->where('username',$user['username'])->select();
|
||||
|
||||
$config = [
|
||||
'stream'=>true,
|
||||
];
|
||||
$content = [
|
||||
//["role" => "user", "content" => '']
|
||||
];
|
||||
foreach ($his_record as $item){
|
||||
$content[] = ["role" => "user", "content" => $item['chat_msg']];
|
||||
}
|
||||
$chatobj->setBefore($content);
|
||||
|
||||
$chatobj->chat($question,$config,$answer_json_arr);
|
||||
}
|
||||
}
|
||||
@@ -158,7 +158,7 @@ class Events extends \think\worker\Events
|
||||
//解析action
|
||||
|
||||
//调用业务逻辑&响应处理结果
|
||||
(new WssMessageLogic())->domsg($client_id,$data);
|
||||
//(new WssMessageLogic())->domsg($client_id,$data);
|
||||
|
||||
//$client = new VmsClient('YOUR_APPID', 'YOUR_SECRET_KEY');
|
||||
|
||||
|
||||
@@ -192,6 +192,10 @@ return [
|
||||
],
|
||||
|
||||
],
|
||||
'ai_report_config'=>[
|
||||
'base_url'=>'https://serverfastgpt.excn.top/api/v1/chat/completions',
|
||||
'APIKey'=>'fastgpt-e5wq9u6phvyfq4znrXfOuTHKHQHGjpcVBYay602ai5zv4HeOJRMDwT3ptm6',
|
||||
],
|
||||
//业务基础架构配置
|
||||
'service_framework_config'=>[
|
||||
//内网访问架构中放行的端口
|
||||
|
||||
Reference in New Issue
Block a user