diff --git a/functions.php b/functions.php
index 910680a..30d030a 100644
--- a/functions.php
+++ b/functions.php
@@ -6702,6 +6702,185 @@ function argon_ajax_get_ai_query_stats() {
}
add_action('wp_ajax_argon_get_ai_query_stats', 'argon_ajax_get_ai_query_stats');
+/**
+ * 注册 AI 查询统计页面
+ */
+function argon_register_ai_query_stats_page() {
+ add_submenu_page(
+ null, // 不在菜单中显示,通过其他方式访问
+ __('AI 查询统计', 'argon'),
+ __('AI 查询统计', 'argon'),
+ 'manage_options',
+ 'argon-ai-query-stats',
+ 'argon_render_ai_query_stats_page'
+ );
+}
+add_action('admin_menu', 'argon_register_ai_query_stats_page');
+
+/**
+ * 渲染 AI 查询统计页面
+ */
+function argon_render_ai_query_stats_page() {
+ if (!current_user_can('manage_options')) {
+ wp_die(__('权限不足', 'argon'));
+ }
+
+ global $wpdb;
+ $table_name = $wpdb->prefix . 'argon_ai_query_log';
+
+ // 获取统计数据
+ $stats = argon_get_ai_query_stats();
+
+ // 获取最近30天的查询趋势
+ $trend_data = $wpdb->get_results("
+ SELECT
+ DATE(query_time) as date,
+ COUNT(*) as total,
+ SUM(CASE WHEN status = 'success' THEN 1 ELSE 0 END) as success,
+ AVG(response_time) as avg_time
+ FROM $table_name
+ WHERE query_time >= DATE_SUB(NOW(), INTERVAL 30 DAY)
+ GROUP BY DATE(query_time)
+ ORDER BY date DESC
+ LIMIT 30
+ ", ARRAY_A);
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+ |
+ |
+
+
+
+ __('文章摘要', 'argon'),
+ 'spam_detection' => __('垃圾评论检测', 'argon'),
+ 'spam_detection_batch' => __('批量垃圾评论检测', 'argon'),
+ 'keyword_extraction' => __('关键词提取', 'argon'),
+ 'test' => __('测试', 'argon')
+ ];
+
+ foreach ($stats['by_scenario'] as $row):
+ $scenario_name = isset($scenario_names[$row['scenario']]) ? $scenario_names[$row['scenario']] : $row['scenario'];
+ ?>
+
+ |
+ |
+ ms |
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+ |
+ |
+
+
+
+ 'OpenAI',
+ 'anthropic' => 'Anthropic Claude',
+ 'deepseek' => 'DeepSeek',
+ 'xiaomi' => __('小米 Mimo', 'argon'),
+ 'qianwen' => __('通义千问', 'argon'),
+ 'wenxin' => __('文心一言', 'argon'),
+ 'doubao' => __('豆包', 'argon'),
+ 'kimi' => 'Kimi',
+ 'zhipu' => __('智谱 AI', 'argon'),
+ 'siliconflow' => __('硅基流动', 'argon')
+ ];
+
+ foreach ($stats['by_provider'] as $row):
+ $provider_name = isset($provider_names[$row['provider']]) ? $provider_names[$row['provider']] : $row['provider'];
+ ?>
+
+ |
+ |
+ ms |
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+
+ |
+ |
+ |
+ ms |
+
+
+
+
+
+
+
+
+
+
+
+
+
+ get_current_user_id()
+ ]);
if (!$ai_response) {
return false;
@@ -9883,105 +10056,6 @@ function argon_batch_detect_spam_comments($comments_data) {
return $result;
}
-/**
- * 调用 AI API 进行批量垃圾评论检测
- */
-function argon_call_ai_api_for_batch_spam_detection($provider, $api_key, $model, $prompt, $content) {
- $endpoint = get_option('argon_ai_summary_api_endpoint', '');
-
- // 根据不同服务商设置默认端点和模型
- $default_models = [
- 'openai' => 'gpt-4o-mini',
- 'anthropic' => 'claude-3-5-haiku-20241022',
- 'deepseek' => 'deepseek-chat',
- 'xiaomi' => 'MiMo-V2-Flash',
- 'qianwen' => 'qwen-turbo',
- 'wenxin' => 'ernie-4.0-turbo-8k',
- 'doubao' => 'doubao-pro-32k',
- 'kimi' => 'moonshot-v1-8k',
- 'zhipu' => 'glm-4-flash',
- 'siliconflow' => 'Qwen/Qwen2.5-7B-Instruct'
- ];
-
- if (empty($model) && isset($default_models[$provider])) {
- $model = $default_models[$provider];
- }
-
- // 构建请求
- $messages = [
- ['role' => 'system', 'content' => $prompt],
- ['role' => 'user', 'content' => $content]
- ];
-
- $body = [
- 'model' => $model,
- 'messages' => $messages,
- 'temperature' => 0.3,
- 'max_tokens' => 4000 // 批量检测需要更多 token
- ];
-
- // 根据服务商设置端点
- if (empty($endpoint)) {
- $endpoints = [
- 'openai' => 'https://api.openai.com/v1/chat/completions',
- 'anthropic' => 'https://api.anthropic.com/v1/messages',
- 'deepseek' => 'https://api.deepseek.com/v1/chat/completions',
- 'xiaomi' => 'https://api.mimo.xiaomi.com/v1/chat/completions',
- 'qianwen' => 'https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions',
- 'wenxin' => 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions',
- 'doubao' => 'https://ark.cn-beijing.volces.com/api/v3/chat/completions',
- 'kimi' => 'https://api.moonshot.cn/v1/chat/completions',
- 'zhipu' => 'https://open.bigmodel.cn/api/paas/v4/chat/completions',
- 'siliconflow' => 'https://api.siliconflow.cn/v1/chat/completions'
- ];
- $endpoint = isset($endpoints[$provider]) ? $endpoints[$provider] : $endpoints['openai'];
- }
-
- // Anthropic 特殊处理
- if ($provider === 'anthropic') {
- $body = [
- 'model' => $model,
- 'messages' => [['role' => 'user', 'content' => $prompt . "\n\n" . $content]],
- 'max_tokens' => 4000
- ];
- $headers = [
- 'x-api-key' => $api_key,
- 'anthropic-version' => '2023-06-01',
- 'Content-Type' => 'application/json'
- ];
- } else {
- $headers = [
- 'Authorization' => 'Bearer ' . $api_key,
- 'Content-Type' => 'application/json'
- ];
- }
-
- $response = wp_remote_post($endpoint, [
- 'headers' => $headers,
- 'body' => json_encode($body),
- 'timeout' => 60 // 批量检测需要更长超时时间
- ]);
-
- if (is_wp_error($response)) {
- return false;
- }
-
- $response_body = json_decode(wp_remote_retrieve_body($response), true);
-
- // 解析响应
- $ai_response = '';
- if ($provider === 'anthropic') {
- if (isset($response_body['content'][0]['text'])) {
- $ai_response = $response_body['content'][0]['text'];
- }
- } else {
- if (isset($response_body['choices'][0]['message']['content'])) {
- $ai_response = $response_body['choices'][0]['message']['content'];
- }
- }
-
- return $ai_response;
-}
/**
* 后台处理扫描任务(已废弃,保留以兼容旧代码)
diff --git a/settings.php b/settings.php
index fa45cc0..bbd613b 100644
--- a/settings.php
+++ b/settings.php
@@ -2587,6 +2587,16 @@ function themeoptions_page(){
+
+ |
+
+
+
+
+
+ |
+
+
|