百度智能云千帆对接

public function getConversation(){新建会话$appidbb31179-7e38-4262-b3d9-b6d63111e32;$header[Content-Type:applicationjs

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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信