public function getConversation(){//新建会话
$appid = 'bb31179-7e38-4262-b3d9-b6d63111e32';
$header = ['Content-Type:application/json','X-Appbuilder-Authorization:Bearer bce-v3/ALTAK-nOh1NmsuEFyP7oqUtMQeq/9d4f86057645bf57d73620416e5473759'];
$url = 'https://qianfan.baidubce/v2/app/conversation';
$msg =['app_id'=>$appid];
return $this->http_post($url,$msg,$header);
}
public function getRuns(){//大模型对话
$conversation_id=$_GET['conversation_id'];
$query=$_GET['query'];
$appid = 'bb31179-7e38-4262-b3d9-b6d63111e32';
$header = ['Content-Type:application/json','X-Appbuilder-Authorization:Bearer bce-v3/ALTAK-nOh1NmsuEFyP7oqUtMQeq/9d4f86057645bf57d73620416e5473759'];
$url = 'https://qianfan.baidubce/v2/app/conversation/runs';
$msg =['app_id'=>$appid,'query'=>$query,'stream'=>false,'conversation_id'=>$conversation_id];
return $this->http_post($url,$msg,$header);
}
function http_post($url,$param,$header){
$oCurl = curl_init();
if(stripos($url,"https://")!==FALSE){
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1
}
curl_setopt($oCurl, CURLOPT_URL, $url);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($oCurl, CURLOPT_POST,true);
curl_setopt($oCurl, CURLOPT_POSTFIELDS,json_encode($param));
curl_setopt($oCurl, CURLOPT_HTTPHEADER, $header);
$sContent = curl_exec($oCurl);
curl_close($oCurl);
return $sContent;
}
发布者:admin,转转请注明出处:http://www.yc00.com/web/1754605902a5181587.html
评论列表(0条)