admin 管理员组

文章数量: 1184232

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;

    }

本文标签: 智能 云千帆