key ); $this->SetHeader($header); } public function generate( $promt, $context = '', $tokens = 0 ){ $url = $this->host.self::$urlgen; $tokens = ( $tokens == 0 )?1024:$tokens; $cmd = array( "model" => $this->model, "messages" =>array(array("role"=>"user", "content"=>$promt)), "stream" => false, "temperature" => 0.2, "top_p" => 0.7, "max_tokens" => $tokens, ); if( $context ){ // $cmd['context'] = $context; } // echo json_encode($cmd); exit; $r = $this->Send( $url, $cmd ); $this->res = $r; return $r; } public function Getres(){ $r = $this->res; $robj = json_decode($r); if( isset($robj->choices[0]) ) return nl2br($robj->choices[0]->message->content); return $r; } }