Przeglądaj źródła

fix: chinese query for knowhub

Talegorithm 3 dni temu
rodzic
commit
8afbe0f982

+ 23 - 0
knowhub/config.py

@@ -0,0 +1,23 @@
+"""
+KnowHub 统一配置
+
+所有 KnowHub 相关代码应该从这里获取配置,而不是硬编码。
+"""
+
+import os
+
+# KnowHub Server 默认地址
+DEFAULT_API_URL = "http://43.106.118.91:9999"
+
+# 从环境变量获取,如果没有则使用默认值
+KNOWHUB_API_URL = os.getenv("KNOWHUB_API", DEFAULT_API_URL)
+
+
+def get_api_url() -> str:
+    """获取 KnowHub API 地址
+
+    优先级:
+    1. 环境变量 KNOWHUB_API
+    2. 默认值 DEFAULT_API_URL
+    """
+    return KNOWHUB_API_URL

+ 1 - 1
knowhub/docs/openclaw_integration.md

@@ -556,7 +556,7 @@ GET /api/search?q=...&agent_id=...
     "entries": {
       "knowhub": {
         "config": {
-          "apiUrl": "http://localhost:8000",
+          "apiUrl": "http://43.106.118.91:9999",
           "shareExperiences": true,
           "submittedBy": "user@example.com"
         }

+ 4 - 4
knowhub/docs/openclaw_plugin_design.md

@@ -54,7 +54,7 @@ extensions/knowhub/
   "config": {
     "apiUrl": {
       "type": "string",
-      "default": "http://localhost:8000",
+      "default": "http://43.106.118.91:9999",
       "description": "KnowHub Server 地址"
     },
     "submittedBy": {
@@ -580,7 +580,7 @@ OpenClaw 配置文件:`~/.openclaw/config.json`
       "knowhub": {
         "enabled": true,
         "config": {
-          "apiUrl": "http://localhost:8000",
+          "apiUrl": "http://43.106.118.91:9999",
           "submittedBy": "user@example.com",
           "reminderMode": "normal",
           "enableServerExtraction": false,
@@ -822,7 +822,7 @@ export function validateConfig(config: any): KnowHubConfig {
       "knowhub": {
         "enabled": true,
         "config": {
-          "apiUrl": "http://localhost:8000",
+          "apiUrl": "http://43.106.118.91:9999",
           "submittedBy": "user@example.com"
         }
       }
@@ -839,7 +839,7 @@ export function validateConfig(config: any): KnowHubConfig {
       "knowhub": {
         "enabled": true,
         "config": {
-          "apiUrl": "http://localhost:8000",
+          "apiUrl": "http://43.106.118.91:9999",
           "submittedBy": "user@example.com",
           "reminderMode": "normal",
           "enableServerExtraction": false,

+ 1 - 1
knowhub/server.py

@@ -1088,4 +1088,4 @@ REPORT: 原有 X 条,合并后 Y 条,精简了 Z 条。
 
 if __name__ == "__main__":
     import uvicorn
-    uvicorn.run(app, host="0.0.0.0", port=999)
+    uvicorn.run(app, host="0.0.0.0", port=9999)

+ 8 - 5
knowhub/skill/SKILL.md

@@ -26,7 +26,7 @@ KnowHub 提供统一的知识库,用于 agent 之间共享和复用经验。
 
 ```bash
 pip install httpx python-dotenv
-export KNOWHUB_API=http://localhost:8000
+export KNOWHUB_API=http://43.106.118.91:9999
 ```
 
 ## 快速开始
@@ -156,12 +156,15 @@ python -m knowhub.cli batch-update --file feedback.json
 
 **搜索**:
 ```bash
-curl "http://localhost:8000/api/knowledge/search?q=查询&top_k=5&min_score=3"
+curl -G "http://43.106.118.91:9999/api/knowledge/search" \
+  --data-urlencode "q=查询" \
+  --data-urlencode "top_k=5" \
+  --data-urlencode "min_score=3"
 ```
 
 **保存**:
 ```bash
-curl -X POST http://localhost:8000/api/knowledge \
+curl -X POST http://43.106.118.91:9999/api/knowledge \
   -H "Content-Type: application/json" \
   -d '{
     "message_id": "msg-001",
@@ -187,14 +190,14 @@ curl -X POST http://localhost:8000/api/knowledge \
 
 **更新**:
 ```bash
-curl -X PUT http://localhost:8000/api/knowledge/knowledge-xxx \
+curl -X PUT http://43.106.118.91:9999/api/knowledge/knowledge-xxx \
   -H "Content-Type: application/json" \
   -d '{"content": "更新内容", "eval_score": 5}'
 ```
 
 **批量反馈**:
 ```bash
-curl -X POST http://localhost:8000/api/knowledge/batch_update \
+curl -X POST http://43.106.118.91:9999/api/knowledge/batch_update \
   -H "Content-Type: application/json" \
   -d '{
     "feedback_list": [{

+ 4 - 1
knowhub/skill/cli.py

@@ -21,10 +21,13 @@ except ImportError:
     print("运行: pip install httpx")
     sys.exit(1)
 
+# KnowHub API 默认地址(CLI 需要在开头声明,方便用户查看和修改)
+DEFAULT_API_URL = "http://43.106.118.91:9999"
+
 
 def get_api_base() -> str:
     """获取 API 地址"""
-    return os.getenv("KNOWHUB_API", "http://localhost:8000")
+    return os.getenv("KNOWHUB_API", DEFAULT_API_URL)
 
 
 def search_knowledge(args):

+ 1 - 1
knowhub/skill/openclaw-plugin/IMPLEMENTATION.md

@@ -92,7 +92,7 @@ knowhub/skill/openclaw-plugin/
       "knowhub": {
         "enabled": true,
         "config": {
-          "apiUrl": "http://localhost:8000",
+          "apiUrl": "http://43.106.118.91:9999",
           "submittedBy": "user@example.com"
         }
       }

+ 4 - 4
knowhub/skill/openclaw-plugin/README.md

@@ -26,7 +26,7 @@ KnowHub 知识管理插件,为 OpenClaw Agent 提供知识搜索、保存和
       "knowhub": {
         "enabled": true,
         "config": {
-          "apiUrl": "http://localhost:8000",
+          "apiUrl": "http://43.106.118.91:9999",
           "submittedBy": "user@example.com",
           "reminderMode": "normal",
           "enableServerExtraction": true,
@@ -42,7 +42,7 @@ KnowHub 知识管理插件,为 OpenClaw Agent 提供知识搜索、保存和
 
 | 选项 | 类型 | 默认值 | 说明 |
 |------|------|--------|------|
-| `apiUrl` | string | `http://localhost:8000` | KnowHub Server 地址 |
+| `apiUrl` | string | `http://43.106.118.91:9999` | KnowHub Server 地址 |
 | `submittedBy` | string | `""` | 提交者标识(邮箱) |
 | `reminderMode` | enum | `normal` | 提醒频率:`off`, `minimal`, `normal`, `aggressive` |
 | `enableServerExtraction` | boolean | `true` | 启用服务端消息历史提取 |
@@ -110,7 +110,7 @@ kb_update({
 - Prompt Injection 检测
 - 内容转义
 - 数据脱敏(strict 模式)
-- 本地优先(默认 localhost
+- 配置灵活(支持本地或远程服务器
 
 ## 故障排查
 
@@ -118,7 +118,7 @@ kb_update({
 
 检查 KnowHub Server 是否运行:
 ```bash
-curl http://localhost:8000/api/knowledge/search?q=test
+curl "http://43.106.118.91:9999/api/knowledge/search?q=test"
 ```
 
 ### 保存失败

+ 4 - 4
knowhub/skill/openclaw-plugin/config-examples.md

@@ -9,7 +9,7 @@
       "knowhub": {
         "enabled": true,
         "config": {
-          "apiUrl": "http://localhost:8000",
+          "apiUrl": "http://43.106.118.91:9999",
           "submittedBy": "user@example.com"
         }
       }
@@ -27,7 +27,7 @@
       "knowhub": {
         "enabled": true,
         "config": {
-          "apiUrl": "http://localhost:8000",
+          "apiUrl": "http://43.106.118.91:9999",
           "submittedBy": "user@example.com",
           "reminderMode": "normal",
           "enableServerExtraction": true,
@@ -48,7 +48,7 @@
       "knowhub": {
         "enabled": true,
         "config": {
-          "apiUrl": "http://localhost:8000",
+          "apiUrl": "http://43.106.118.91:9999",
           "submittedBy": "user@example.com",
           "reminderMode": "off"
         }
@@ -67,7 +67,7 @@
       "knowhub": {
         "enabled": true,
         "config": {
-          "apiUrl": "http://localhost:8000",
+          "apiUrl": "http://43.106.118.91:9999",
           "submittedBy": "user@example.com",
           "enableServerExtraction": false
         }

+ 3 - 3
knowhub/skill/openclaw-plugin/openclaw.plugin.json

@@ -4,8 +4,8 @@
   "uiHints": {
     "apiUrl": {
       "label": "KnowHub Server URL",
-      "placeholder": "http://localhost:8000",
-      "help": "KnowHub Server 地址"
+      "placeholder": "http://43.106.118.91:9999",
+      "help": "KnowHub Server 地址(默认: http://43.106.118.91:9999)"
     },
     "submittedBy": {
       "label": "提交者标识",
@@ -31,7 +31,7 @@
     "properties": {
       "apiUrl": {
         "type": "string",
-        "default": "http://localhost:8000"
+        "default": "http://43.106.118.91:9999"
       },
       "submittedBy": {
         "type": "string",