|
@@ -730,7 +730,6 @@ function themeConfig($form)
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
function getPost($postId){
|
|
|
$db = Typecho_Db::get();
|
|
|
$post = $db->fetchRow($db->select()->from('table.contents')->where('cid = ?', $postId));
|
|
@@ -741,11 +740,92 @@ function getPost($postId){
|
|
|
else
|
|
|
{
|
|
|
return Typecho_Widget::widget('Widget_Abstract_Contents')->push($post);
|
|
|
-
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function logSearch($keyword, $category_id, $dataset_id) {
|
|
|
+ $db = Typecho_Db::get();
|
|
|
+ $request = Typecho_Request::getInstance();
|
|
|
|
|
|
+ $data = array(
|
|
|
+ 'keyword' => $keyword,
|
|
|
+ 'category_id' => $category_id ?: null,
|
|
|
+ 'dataset_id' => $dataset_id,
|
|
|
+ 'ip_address' => $request->getIp(),
|
|
|
+ 'user_agent' => $request->getServer('HTTP_USER_AGENT'),
|
|
|
+ 'referer' => $request->getServer('HTTP_REFERER')
|
|
|
+ );
|
|
|
+
|
|
|
+ try {
|
|
|
+ $db->query($db->insert('table.search_logs')->rows($data));
|
|
|
+ } catch (Exception $e) {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+function retrieveDatasetData($token, $datasets, $keyword)
|
|
|
+{
|
|
|
+
|
|
|
+ $url = "http://8.217.82.148/v1/datasets/{$datasets}/retrieve";
|
|
|
+
|
|
|
+
|
|
|
+ $requestBody = [
|
|
|
+ 'query' => $keyword,
|
|
|
+ 'retrieval_model' => [
|
|
|
+ 'reranking_enable' => false,
|
|
|
+ 'reranking_mode' => null,
|
|
|
+ 'reranking_model' => [
|
|
|
+ 'reranking_provider_name' => '',
|
|
|
+ 'reranking_model_name' => ''
|
|
|
+ ],
|
|
|
+ 'weights' => null,
|
|
|
+ 'top_k' => 3,
|
|
|
+ 'score_threshold_enabled' => false,
|
|
|
+ 'score_threshold' => null
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ $ch = curl_init();
|
|
|
+
|
|
|
+
|
|
|
+ curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
|
|
+
|
|
|
+
|
|
|
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
|
+ 'Authorization: Bearer ' . $token,
|
|
|
+ 'Content-Type: application/json',
|
|
|
+ ]);
|
|
|
+
|
|
|
+
|
|
|
+ curl_setopt($ch, CURLOPT_POST, true);
|
|
|
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestBody));
|
|
|
+
|
|
|
+
|
|
|
+ $response = curl_exec($ch);
|
|
|
+
|
|
|
+
|
|
|
+ if (curl_errno($ch)) {
|
|
|
+ echo 'cURL Error: ' . curl_error($ch);
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+
|
|
|
+ $data = json_decode($response, true);
|
|
|
+
|
|
|
+
|
|
|
+ curl_close($ch);
|
|
|
+
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
?>
|