This commit is contained in:
2024-07-12 11:54:07 +08:00
parent 523350fde4
commit 3e2531f4e9
3 changed files with 90 additions and 1 deletions

View File

@@ -0,0 +1,85 @@
<?php
/*
* description
* authorwh
* 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"
}
]
}'
*
* authorwh
* @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);
}
}

View File

@@ -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');

View File

@@ -192,6 +192,10 @@ return [
],
],
'ai_report_config'=>[
'base_url'=>'https://serverfastgpt.excn.top/api/v1/chat/completions',
'APIKey'=>'fastgpt-e5wq9u6phvyfq4znrXfOuTHKHQHGjpcVBYay602ai5zv4HeOJRMDwT3ptm6',
],
//业务基础架构配置
'service_framework_config'=>[
//内网访问架构中放行的端口