瀏覽代碼

Merge remote-tracking branch 'origin/master'

2507040827 1 天之前
父節點
當前提交
5d83debb7c
共有 11 個文件被更改,包括 529 次插入108 次删除
  1. 18 0
      agent/build.sh
  2. 32 0
      agent/child.html
  3. 38 0
      agent/parent.html
  4. 407 77
      agent/pdm.lock
  5. 2 4
      agent/pyproject.toml
  6. 4 1
      agent/readme.md
  7. 二進制
      agent/release.tar.gz
  8. 0 1
      agent/src/agent/Untitled-1.json
  9. 3 3
      agent/src/agent/agent.py
  10. 18 21
      agent/src/agent/api_inner.py
  11. 7 1
      agent/tests/test_generate_reg.py

+ 18 - 0
agent/build.sh

@@ -0,0 +1,18 @@
+# 1. 锁定并安装(确保 pdm.lock 最新)
+pdm install --prod
+
+# 2. 导出 requirements.txt
+pdm export -o requirements.txt --prod
+
+# 3. 下载所有 wheel
+rm -rf release
+mkdir -p release
+pip download -r requirements.txt -d release/ --prefer-binary
+
+# 4. 构建并加入自己的项目
+# pdm build
+# cp dist/*.whl release/
+
+# 5. 打包
+rm release.tar.gz
+tar -czvf release.tar.gz release/

+ 32 - 0
agent/child.html

@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+  <meta charset="UTF-8" />
+  <title>子页面(iframe)</title>
+</head>
+<body>
+  <h2>子页面(iframe)</h2>
+  <div id="output">等待接收消息...</div>
+
+  <script>
+    // 监听来自父页面的消息
+    window.addEventListener('message', (event) => {
+      // 安全检查:验证来源是否可信
+      if (event.origin !== window.parent.location.origin) {
+        console.warn('收到未知来源的消息,已忽略:', event.origin);
+        return;
+      }
+
+      const data = event.data;
+      console.log('收到来自父页面的消息:', data);
+
+      // 显示消息内容
+      document.getElementById('output').innerHTML = `
+        <p>消息: ${data.message}</p>
+        <p>用户ID: ${data.userId}</p>
+        <p>时间: ${data.timestamp}</p>
+      `;
+    });
+  </script>
+</body>
+</html>

+ 38 - 0
agent/parent.html

@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+  <meta charset="UTF-8" />
+  <title>父页面</title>
+</head>
+<body>
+  <h2>父页面</h2>
+  <button id="sendBtn">向 iframe 发送消息</button>
+
+  <!-- 注意:src 必须是同源或你明确知道目标 origin -->
+  <iframe id="myIframe" src="child.html" width="600" height="300"></iframe>
+
+  <script>
+    const iframe = document.getElementById('myIframe');
+    const sendBtn = document.getElementById('sendBtn');
+
+    // 等待 iframe 加载完成再发送消息更安全
+    iframe.onload = () => {
+      console.log('iframe 已加载');
+    };
+
+    sendBtn.addEventListener('click', () => {
+      const data = {
+        message: '你好,子页面!',
+        userId: 12345,
+        timestamp: new Date().toISOString()
+      };
+
+      // 向 iframe 发送消息
+      // 第二个参数是目标 origin,出于安全考虑建议不要用 '*'
+      // 如果 child.html 在同一域名下,可以用 window.location.origin
+      console.log('向 iframe 发送消息:', data);
+      iframe.contentWindow.postMessage(data, window.location.origin);
+    });
+  </script>
+</body>
+</html>

+ 407 - 77
agent/pdm.lock

@@ -5,7 +5,7 @@
 groups = ["default"]
 strategy = ["inherit_metadata"]
 lock_version = "4.5.0"
-content_hash = "sha256:44f4afdfba6d7e4aa629c25c88506687ab6bdaf85333b4a5331cbb7dc551617e"
+content_hash = "sha256:b1461fe2ef5ca4d7887f30aedb0610d929a1b1f21128a9da6d005052a8ab9aa8"
 
 [[metadata.targets]]
 requires_python = "==3.10.*"
@@ -55,6 +55,21 @@ files = [
 ]
 
 [[package]]
+name = "anysqlite"
+version = "0.0.5"
+requires_python = ">=3.8"
+summary = ""
+groups = ["default"]
+marker = "python_version == \"3.10\""
+dependencies = [
+    "anyio>3.4.0",
+]
+files = [
+    {file = "anysqlite-0.0.5-py3-none-any.whl", hash = "sha256:cb345dc4f76f6b37f768d7a0b3e9cf5c700dfcb7a6356af8ab46a11f666edbe7"},
+    {file = "anysqlite-0.0.5.tar.gz", hash = "sha256:9dfcf87baf6b93426ad1d9118088c41dbf24ef01b445eea4a5d486bac2755cce"},
+]
+
+[[package]]
 name = "asyncer"
 version = "0.0.17"
 requires_python = ">=3.10"
@@ -72,6 +87,18 @@ files = [
 ]
 
 [[package]]
+name = "blinker"
+version = "1.9.0"
+requires_python = ">=3.9"
+summary = "Fast, simple object-to-object and broadcast signaling"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "blinker-1.9.0-py3-none-any.whl", hash = "sha256:ba0efaa9080b619ff2f3459d1d500c57bddea4a6b424b60a91141db6fd2f08bc"},
+    {file = "blinker-1.9.0.tar.gz", hash = "sha256:b4ce2265a7abece45e7cc896e98dbebe6cead56bcf805a3d23136d145f5445bf"},
+]
+
+[[package]]
 name = "certifi"
 version = "2026.1.4"
 requires_python = ">=3.7"
@@ -151,6 +178,32 @@ files = [
 ]
 
 [[package]]
+name = "dep-logic"
+version = "0.5.2"
+requires_python = ">=3.8"
+summary = "Python dependency specifications supporting logical operations"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+dependencies = [
+    "packaging>=22",
+]
+files = [
+    {file = "dep_logic-0.5.2-py3-none-any.whl", hash = "sha256:0e72ab6676afd32fe8702896a8b9886bddd6ccd457b77ba360e7b6c4c95ce4c0"},
+    {file = "dep_logic-0.5.2.tar.gz", hash = "sha256:f8dc4a74d1bad0d35a45c236572cf5d6534b5c2e84de87f2a354c849eec7e562"},
+]
+
+[[package]]
+name = "distlib"
+version = "0.4.0"
+summary = "Distribution utilities"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "distlib-0.4.0-py2.py3-none-any.whl", hash = "sha256:9659f7d87e46584a30b5780e43ac7a2143098441670ff0a49d5f9034c54a6c16"},
+    {file = "distlib-0.4.0.tar.gz", hash = "sha256:feec40075be03a04501a973d81f633735b4b69f98b05450592310c0f401a4e0d"},
+]
+
+[[package]]
 name = "distro"
 version = "1.9.0"
 requires_python = ">=3.6"
@@ -194,18 +247,6 @@ files = [
 ]
 
 [[package]]
-name = "et-xmlfile"
-version = "2.0.0"
-requires_python = ">=3.8"
-summary = "An implementation of lxml.xmlfile for the standard library"
-groups = ["default"]
-marker = "python_version == \"3.10\""
-files = [
-    {file = "et_xmlfile-2.0.0-py3-none-any.whl", hash = "sha256:7a91720bc756843502c3b7504c77b8fe44217c85c537d85037f0f536151b2caa"},
-    {file = "et_xmlfile-2.0.0.tar.gz", hash = "sha256:dab3f4764309081ce75662649be815c4c9081e88f0837825f90fd28317d4da54"},
-]
-
-[[package]]
 name = "exceptiongroup"
 version = "1.3.1"
 requires_python = ">=3.7"
@@ -239,6 +280,34 @@ files = [
 ]
 
 [[package]]
+name = "filelock"
+version = "3.24.3"
+requires_python = ">=3.10"
+summary = "A platform independent file lock."
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "filelock-3.24.3-py3-none-any.whl", hash = "sha256:426e9a4660391f7f8a810d71b0555bce9008b0a1cc342ab1f6947d37639e002d"},
+    {file = "filelock-3.24.3.tar.gz", hash = "sha256:011a5644dc937c22699943ebbfc46e969cdde3e171470a6e40b9533e5a72affa"},
+]
+
+[[package]]
+name = "findpython"
+version = "0.7.1"
+requires_python = ">=3.8"
+summary = "A utility to find python versions on your system"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+dependencies = [
+    "packaging>=20",
+    "platformdirs>=4.3.6",
+]
+files = [
+    {file = "findpython-0.7.1-py3-none-any.whl", hash = "sha256:1b78b1ff6e886cbddeffe80f8ecdbf2b8b061169bbd18b673070e26b644c51ac"},
+    {file = "findpython-0.7.1.tar.gz", hash = "sha256:9f29e6a3dabdb75f2b39c949772c0ed26eab15308006669f3478cdab0d867c78"},
+]
+
+[[package]]
 name = "h11"
 version = "0.16.0"
 requires_python = ">=3.8"
@@ -251,6 +320,41 @@ files = [
 ]
 
 [[package]]
+name = "hishel"
+version = "1.1.9"
+requires_python = ">=3.10"
+summary = "Elegant HTTP Caching for Python"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+dependencies = [
+    "msgpack>=1.1.2",
+    "typing-extensions>=4.14.1",
+]
+files = [
+    {file = "hishel-1.1.9-py3-none-any.whl", hash = "sha256:6b6f294cb7593f170a9bf874849cc85330ff81f5e35d2ca189548498fed10806"},
+    {file = "hishel-1.1.9.tar.gz", hash = "sha256:47248a50e4cff4fbaa141832782d8c07b2169914916f4bd792f37449176dfa23"},
+]
+
+[[package]]
+name = "hishel"
+version = "1.1.9"
+extras = ["httpx"]
+requires_python = ">=3.10"
+summary = "Elegant HTTP Caching for Python"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+dependencies = [
+    "anyio>=4.9.0",
+    "anysqlite>=0.0.5",
+    "hishel==1.1.9",
+    "httpx>=0.28.1",
+]
+files = [
+    {file = "hishel-1.1.9-py3-none-any.whl", hash = "sha256:6b6f294cb7593f170a9bf874849cc85330ff81f5e35d2ca189548498fed10806"},
+    {file = "hishel-1.1.9.tar.gz", hash = "sha256:47248a50e4cff4fbaa141832782d8c07b2169914916f4bd792f37449176dfa23"},
+]
+
+[[package]]
 name = "httpcore"
 version = "1.0.9"
 requires_python = ">=3.8"
@@ -285,6 +389,38 @@ files = [
 ]
 
 [[package]]
+name = "httpx"
+version = "0.28.1"
+extras = ["socks"]
+requires_python = ">=3.8"
+summary = "The next generation HTTP client."
+groups = ["default"]
+marker = "python_version == \"3.10\""
+dependencies = [
+    "httpx==0.28.1",
+    "socksio==1.*",
+]
+files = [
+    {file = "httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad"},
+    {file = "httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc"},
+]
+
+[[package]]
+name = "id"
+version = "1.6.1"
+requires_python = ">=3.9"
+summary = "A tool for generating OIDC identities"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+dependencies = [
+    "urllib3<3,>=2",
+]
+files = [
+    {file = "id-1.6.1-py3-none-any.whl", hash = "sha256:f5ec41ed2629a508f5d0988eda142e190c9c6da971100612c4de9ad9f9b237ca"},
+    {file = "id-1.6.1.tar.gz", hash = "sha256:d0732d624fb46fd4e7bc4e5152f00214450953b9e772c182c1c22964def1a069"},
+]
+
+[[package]]
 name = "idna"
 version = "3.11"
 requires_python = ">=3.8"
@@ -297,6 +433,18 @@ files = [
 ]
 
 [[package]]
+name = "installer"
+version = "0.7.0"
+requires_python = ">=3.7"
+summary = "A library for installing Python wheels."
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "installer-0.7.0-py3-none-any.whl", hash = "sha256:05d1933f0a5ba7d8d6296bb6d5018e7c94fa473ceb10cf198a92ccea19c27b53"},
+    {file = "installer-0.7.0.tar.gz", hash = "sha256:a26d3e3116289bb08216e0d0f7d925fcef0b0194eedfa0c944bcaaa106c4b631"},
+]
+
+[[package]]
 name = "jiter"
 version = "0.13.0"
 requires_python = ">=3.9"
@@ -494,6 +642,52 @@ files = [
 ]
 
 [[package]]
+name = "markdown-it-py"
+version = "4.0.0"
+requires_python = ">=3.10"
+summary = "Python port of markdown-it. Markdown parsing, done right!"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+dependencies = [
+    "mdurl~=0.1",
+]
+files = [
+    {file = "markdown_it_py-4.0.0-py3-none-any.whl", hash = "sha256:87327c59b172c5011896038353a81343b6754500a08cd7a4973bb48c6d578147"},
+    {file = "markdown_it_py-4.0.0.tar.gz", hash = "sha256:cb0a2b4aa34f932c007117b194e945bd74e0ec24133ceb5bac59009cda1cb9f3"},
+]
+
+[[package]]
+name = "mdurl"
+version = "0.1.2"
+requires_python = ">=3.7"
+summary = "Markdown URL utilities"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"},
+    {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"},
+]
+
+[[package]]
+name = "msgpack"
+version = "1.1.2"
+requires_python = ">=3.9"
+summary = "MessagePack serializer"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "msgpack-1.1.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0051fffef5a37ca2cd16978ae4f0aef92f164df86823871b5162812bebecd8e2"},
+    {file = "msgpack-1.1.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a605409040f2da88676e9c9e5853b3449ba8011973616189ea5ee55ddbc5bc87"},
+    {file = "msgpack-1.1.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8b696e83c9f1532b4af884045ba7f3aa741a63b2bc22617293a2c6a7c645f251"},
+    {file = "msgpack-1.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:365c0bbe981a27d8932da71af63ef86acc59ed5c01ad929e09a0b88c6294e28a"},
+    {file = "msgpack-1.1.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:41d1a5d875680166d3ac5c38573896453bbbea7092936d2e107214daf43b1d4f"},
+    {file = "msgpack-1.1.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:354e81bcdebaab427c3df4281187edc765d5d76bfb3a7c125af9da7a27e8458f"},
+    {file = "msgpack-1.1.2-cp310-cp310-win32.whl", hash = "sha256:e64c8d2f5e5d5fda7b842f55dec6133260ea8f53c4257d64494c534f306bf7a9"},
+    {file = "msgpack-1.1.2-cp310-cp310-win_amd64.whl", hash = "sha256:db6192777d943bdaaafb6ba66d44bf65aa0e9c5616fa1d2da9bb08828c6b39aa"},
+    {file = "msgpack-1.1.2.tar.gz", hash = "sha256:3b60763c1373dd60f398488069bcdc703cd08a711477b5d480eecc9f9626f47e"},
+]
+
+[[package]]
 name = "numpy"
 version = "2.2.6"
 requires_python = ">=3.10"
@@ -541,21 +735,6 @@ files = [
 ]
 
 [[package]]
-name = "openpyxl"
-version = "3.1.5"
-requires_python = ">=3.8"
-summary = "A Python library to read/write Excel 2010 xlsx/xlsm files"
-groups = ["default"]
-marker = "python_version == \"3.10\""
-dependencies = [
-    "et-xmlfile",
-]
-files = [
-    {file = "openpyxl-3.1.5-py2.py3-none-any.whl", hash = "sha256:5282c12b107bffeef825f4617dc029afaf41d0ea60823bbb665ef3079dc79de2"},
-    {file = "openpyxl-3.1.5.tar.gz", hash = "sha256:cf0e3cf56142039133628b5acffe8ef0c12bc902d2aadd3e0fe5878dc08d1050"},
-]
-
-[[package]]
 name = "orjson"
 version = "3.11.7"
 requires_python = ">=3.10"
@@ -611,29 +790,65 @@ files = [
 ]
 
 [[package]]
-name = "pandas"
-version = "2.3.3"
+name = "pbs-installer"
+version = "2026.2.11"
+requires_python = ">=3.8"
+summary = "Installer for Python Build Standalone"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "pbs_installer-2026.2.11-py3-none-any.whl", hash = "sha256:0a1eb8bc6c0a53f381b8dc09c18c0d7aa9e6a2495b0bf02b27d48af6b6b4d01f"},
+    {file = "pbs_installer-2026.2.11.tar.gz", hash = "sha256:7eb2730aaa8e2a9aa51db3871e494d058dbab64328deec1fc7bdbbc68578167f"},
+]
+
+[[package]]
+name = "pdm"
+version = "2.26.6"
 requires_python = ">=3.9"
-summary = "Powerful data structures for data analysis, time series, and statistics"
+summary = "A modern Python package and dependency manager supporting the latest PEP standards"
 groups = ["default"]
 marker = "python_version == \"3.10\""
 dependencies = [
-    "numpy>=1.22.4; python_version < \"3.11\"",
-    "numpy>=1.23.2; python_version == \"3.11\"",
-    "numpy>=1.26.0; python_version >= \"3.12\"",
-    "python-dateutil>=2.8.2",
-    "pytz>=2020.1",
-    "tzdata>=2022.7",
+    "blinker",
+    "certifi>=2024.8.30",
+    "dep-logic>=0.5",
+    "filelock>=3.13",
+    "findpython<1.0.0a0,>=0.7.0",
+    "hishel[httpx]>=1.0.0",
+    "httpcore>=1.0.6",
+    "httpx[socks]<1,>0.20",
+    "id>=1.5.0",
+    "importlib-metadata>=3.6; python_version < \"3.10\"",
+    "installer<0.8,>=0.7",
+    "packaging>22.0",
+    "pbs-installer>=2025.10.7",
+    "platformdirs",
+    "pyproject-hooks",
+    "python-dotenv>=0.15",
+    "resolvelib>=1.1",
+    "rich>=12.3.0",
+    "shellingham>=1.3.2",
+    "tomli>=1.1.0; python_version < \"3.11\"",
+    "tomlkit<1,>=0.11.1",
+    "truststore>=0.10.4; python_version >= \"3.10\"",
+    "unearth>=0.17.5",
+    "virtualenv>=20",
 ]
 files = [
-    {file = "pandas-2.3.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:376c6446ae31770764215a6c937f72d917f214b43560603cd60da6408f183b6c"},
-    {file = "pandas-2.3.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e19d192383eab2f4ceb30b412b22ea30690c9e618f78870357ae1d682912015a"},
-    {file = "pandas-2.3.3-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5caf26f64126b6c7aec964f74266f435afef1c1b13da3b0636c7518a1fa3e2b1"},
-    {file = "pandas-2.3.3-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:dd7478f1463441ae4ca7308a70e90b33470fa593429f9d4c578dd00d1fa78838"},
-    {file = "pandas-2.3.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:4793891684806ae50d1288c9bae9330293ab4e083ccd1c5e383c34549c6e4250"},
-    {file = "pandas-2.3.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:28083c648d9a99a5dd035ec125d42439c6c1c525098c58af0fc38dd1a7a1b3d4"},
-    {file = "pandas-2.3.3-cp310-cp310-win_amd64.whl", hash = "sha256:503cf027cf9940d2ceaa1a93cfb5f8c8c7e6e90720a2850378f0b3f3b1e06826"},
-    {file = "pandas-2.3.3.tar.gz", hash = "sha256:e05e1af93b977f7eafa636d043f9f94c7ee3ac81af99c13508215942e64c993b"},
+    {file = "pdm-2.26.6-py3-none-any.whl", hash = "sha256:39583edee738cc62b9ec2d5b4e434f44e501b55f609401a89732b5e8a451944f"},
+    {file = "pdm-2.26.6.tar.gz", hash = "sha256:771f95b9a484f9eb34dcf8d851be6ff95333e4f3c46189f9004cfd5cc2e925f9"},
+]
+
+[[package]]
+name = "platformdirs"
+version = "4.9.2"
+requires_python = ">=3.10"
+summary = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`."
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "platformdirs-4.9.2-py3-none-any.whl", hash = "sha256:9170634f126f8efdae22fb58ae8a0eaa86f38365bc57897a6c4f781d1f5875bd"},
+    {file = "platformdirs-4.9.2.tar.gz", hash = "sha256:9a33809944b9db043ad67ca0db94b14bf452cc6aeaac46a88ea55b26e2e9d291"},
 ]
 
 [[package]]
@@ -690,6 +905,18 @@ files = [
 ]
 
 [[package]]
+name = "pygments"
+version = "2.19.2"
+requires_python = ">=3.8"
+summary = "Pygments is a syntax highlighting package written in Python."
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b"},
+    {file = "pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887"},
+]
+
+[[package]]
 name = "pymysql"
 version = "1.1.2"
 requires_python = ">=3.8"
@@ -702,41 +929,43 @@ files = [
 ]
 
 [[package]]
-name = "python-dateutil"
-version = "2.9.0.post0"
-requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7"
-summary = "Extensions to the standard Python datetime module"
+name = "pyproject-hooks"
+version = "1.2.0"
+requires_python = ">=3.7"
+summary = "Wrappers to call pyproject.toml-based build backend hooks."
 groups = ["default"]
 marker = "python_version == \"3.10\""
-dependencies = [
-    "six>=1.5",
-]
 files = [
-    {file = "python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3"},
-    {file = "python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"},
+    {file = "pyproject_hooks-1.2.0-py3-none-any.whl", hash = "sha256:9e5c6bfa8dcc30091c74b0cf803c81fdd29d94f01992a7707bc97babb1141913"},
+    {file = "pyproject_hooks-1.2.0.tar.gz", hash = "sha256:1e859bd5c40fae9448642dd871adf459e5e2084186e8d2c2a79a824c970da1f8"},
 ]
 
 [[package]]
-name = "python-multipart"
-version = "0.0.22"
-requires_python = ">=3.10"
-summary = "A streaming multipart parser for Python"
+name = "python-discovery"
+version = "1.1.0"
+requires_python = ">=3.8"
+summary = "Python interpreter discovery"
 groups = ["default"]
 marker = "python_version == \"3.10\""
+dependencies = [
+    "filelock>=3.15.4",
+    "platformdirs<5,>=4.3.6",
+]
 files = [
-    {file = "python_multipart-0.0.22-py3-none-any.whl", hash = "sha256:2b2cd894c83d21bf49d702499531c7bafd057d730c201782048f7945d82de155"},
-    {file = "python_multipart-0.0.22.tar.gz", hash = "sha256:7340bef99a7e0032613f56dc36027b959fd3b30a787ed62d310e951f7c3a3a58"},
+    {file = "python_discovery-1.1.0-py3-none-any.whl", hash = "sha256:a162893b8809727f54594a99ad2179d2ede4bf953e12d4c7abc3cc9cdbd1437b"},
+    {file = "python_discovery-1.1.0.tar.gz", hash = "sha256:447941ba1aed8cc2ab7ee3cb91be5fc137c5bdbb05b7e6ea62fbdcb66e50b268"},
 ]
 
 [[package]]
-name = "pytz"
-version = "2025.2"
-summary = "World timezone definitions, modern and historical"
+name = "python-dotenv"
+version = "1.2.1"
+requires_python = ">=3.9"
+summary = "Read key-value pairs from a .env file and set them as environment variables"
 groups = ["default"]
 marker = "python_version == \"3.10\""
 files = [
-    {file = "pytz-2025.2-py2.py3-none-any.whl", hash = "sha256:5ddf76296dd8c44c26eb8f4b6f35488f3ccbf6fbbd7adee0b7262d43f0ec2f00"},
-    {file = "pytz-2025.2.tar.gz", hash = "sha256:360b9e3dbb49a209c21ad61809c7fb453643e048b38924c765813546746e81c3"},
+    {file = "python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61"},
+    {file = "python_dotenv-1.2.1.tar.gz", hash = "sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6"},
 ]
 
 [[package]]
@@ -821,15 +1050,43 @@ files = [
 ]
 
 [[package]]
-name = "six"
-version = "1.17.0"
-requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7"
-summary = "Python 2 and 3 compatibility utilities"
+name = "resolvelib"
+version = "1.2.1"
+requires_python = ">=3.9"
+summary = "Resolve abstract dependencies into concrete ones"
 groups = ["default"]
 marker = "python_version == \"3.10\""
 files = [
-    {file = "six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274"},
-    {file = "six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"},
+    {file = "resolvelib-1.2.1-py3-none-any.whl", hash = "sha256:fb06b66c8da04172d9e72a21d7d06186d8919e32ae5ab5cdf5b9d920be805ac2"},
+    {file = "resolvelib-1.2.1.tar.gz", hash = "sha256:7d08a2022f6e16ce405d60b68c390f054efcfd0477d4b9bd019cc941c28fad1c"},
+]
+
+[[package]]
+name = "rich"
+version = "14.3.3"
+requires_python = ">=3.8.0"
+summary = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+dependencies = [
+    "markdown-it-py>=2.2.0",
+    "pygments<3.0.0,>=2.13.0",
+]
+files = [
+    {file = "rich-14.3.3-py3-none-any.whl", hash = "sha256:793431c1f8619afa7d3b52b2cdec859562b950ea0d4b6b505397612db8d5362d"},
+    {file = "rich-14.3.3.tar.gz", hash = "sha256:b8daa0b9e4eef54dd8cf7c86c03713f53241884e814f4e2f5fb342fe520f639b"},
+]
+
+[[package]]
+name = "shellingham"
+version = "1.5.4"
+requires_python = ">=3.7"
+summary = "Tool to Detect Surrounding Shell"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "shellingham-1.5.4-py2.py3-none-any.whl", hash = "sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686"},
+    {file = "shellingham-1.5.4.tar.gz", hash = "sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de"},
 ]
 
 [[package]]
@@ -845,6 +1102,18 @@ files = [
 ]
 
 [[package]]
+name = "socksio"
+version = "1.0.0"
+requires_python = ">=3.6"
+summary = "Sans-I/O implementation of SOCKS4, SOCKS4A, and SOCKS5."
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "socksio-1.0.0-py3-none-any.whl", hash = "sha256:95dc1f15f9b34e8d7b16f06d74b8ccf48f609af32ab33c608d08761c5dcbb1f3"},
+    {file = "socksio-1.0.0.tar.gz", hash = "sha256:f88beb3da5b5c38b9890469de67d0cb0f9d494b78b106ca1845f96c10b91c4ac"},
+]
+
+[[package]]
 name = "starlette"
 version = "0.50.0"
 requires_python = ">=3.10"
@@ -895,6 +1164,30 @@ files = [
 ]
 
 [[package]]
+name = "tomli"
+version = "2.4.0"
+requires_python = ">=3.8"
+summary = "A lil' TOML parser"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "tomli-2.4.0-py3-none-any.whl", hash = "sha256:1f776e7d669ebceb01dee46484485f43a4048746235e683bcdffacdf1fb4785a"},
+    {file = "tomli-2.4.0.tar.gz", hash = "sha256:aa89c3f6c277dd275d8e243ad24f3b5e701491a860d5121f2cdd399fbb31fc9c"},
+]
+
+[[package]]
+name = "tomlkit"
+version = "0.14.0"
+requires_python = ">=3.9"
+summary = "Style preserving TOML library"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "tomlkit-0.14.0-py3-none-any.whl", hash = "sha256:592064ed85b40fa213469f81ac584f67a4f2992509a7c3ea2d632208623a3680"},
+    {file = "tomlkit-0.14.0.tar.gz", hash = "sha256:cf00efca415dbd57575befb1f6634c4f42d2d87dbba376128adb42c121b87064"},
+]
+
+[[package]]
 name = "tqdm"
 version = "4.67.2"
 requires_python = ">=3.7"
@@ -910,6 +1203,18 @@ files = [
 ]
 
 [[package]]
+name = "truststore"
+version = "0.10.4"
+requires_python = ">=3.10"
+summary = "Verify certificates using native system trust stores"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+files = [
+    {file = "truststore-0.10.4-py3-none-any.whl", hash = "sha256:adaeaecf1cbb5f4de3b1959b42d41f6fab57b2b1666adb59e89cb0b53361d981"},
+    {file = "truststore-0.10.4.tar.gz", hash = "sha256:9d91bd436463ad5e4ee4aba766628dd6cd7010cf3e2461756b3303710eebc301"},
+]
+
+[[package]]
 name = "typing-extensions"
 version = "4.15.0"
 requires_python = ">=3.9"
@@ -937,15 +1242,19 @@ files = [
 ]
 
 [[package]]
-name = "tzdata"
-version = "2025.3"
-requires_python = ">=2"
-summary = "Provider of IANA time zone data"
+name = "unearth"
+version = "0.18.2"
+requires_python = ">=3.9"
+summary = "A utility to fetch and download python packages"
 groups = ["default"]
 marker = "python_version == \"3.10\""
+dependencies = [
+    "httpx<1,>=0.27.0",
+    "packaging>=20",
+]
 files = [
-    {file = "tzdata-2025.3-py2.py3-none-any.whl", hash = "sha256:06a47e5700f3081aab02b2e513160914ff0694bce9947d6b76ebd6bf57cfc5d1"},
-    {file = "tzdata-2025.3.tar.gz", hash = "sha256:de39c2ca5dc7b0344f2eba86f49d614019d29f060fc4ebc8a417896a620b56a7"},
+    {file = "unearth-0.18.2-py3-none-any.whl", hash = "sha256:31fd55d67c0e46a1ebb78993a2010568e6c4231334a3207d18d5d4a549d8d692"},
+    {file = "unearth-0.18.2.tar.gz", hash = "sha256:1e53d7f52f46dd5f875e77ff1c55b12477e215a092e4b66c9764a77df4a9b520"},
 ]
 
 [[package]]
@@ -1003,6 +1312,27 @@ files = [
 ]
 
 [[package]]
+name = "virtualenv"
+version = "21.1.0"
+requires_python = ">=3.8"
+summary = "Virtual Python Environment builder"
+groups = ["default"]
+marker = "python_version == \"3.10\""
+dependencies = [
+    "distlib<1,>=0.3.7",
+    "filelock<4,>=3.24.2; python_version >= \"3.10\"",
+    "filelock<=3.19.1,>=3.16.1; python_version < \"3.10\"",
+    "importlib-metadata>=6.6; python_version < \"3.8\"",
+    "platformdirs<5,>=3.9.1",
+    "python-discovery>=1",
+    "typing-extensions>=4.13.2; python_version < \"3.11\"",
+]
+files = [
+    {file = "virtualenv-21.1.0-py3-none-any.whl", hash = "sha256:164f5e14c5587d170cf98e60378eb91ea35bf037be313811905d3a24ea33cc07"},
+    {file = "virtualenv-21.1.0.tar.gz", hash = "sha256:1990a0188c8f16b6b9cf65c9183049007375b26aad415514d377ccacf1e4fb44"},
+]
+
+[[package]]
 name = "xxhash"
 version = "3.6.0"
 requires_python = ">=3.7"

+ 2 - 4
agent/pyproject.toml

@@ -8,7 +8,6 @@ authors = [
 dependencies = [
     "fastapi>=0.128.0",
     "uvicorn>=0.40.0",
-    "python-multipart>=0.0.22",
     "requests>=2.32.5",
     "langchain>=1.2.9",
     "langchain-openai>=1.1.7",
@@ -17,8 +16,7 @@ dependencies = [
     "elasticsearch==8.9.0",
     "numpy>=2.2.6",
     "asyncer>=0.0.17",
-    "pandas>=2.3.3",
-    "openpyxl>=3.1.5",
+    "pdm>=2.26.6",
 ]
 requires-python = ">=3.10"
 readme = "README.md"
@@ -29,7 +27,7 @@ build.package-dir = "src"
 distribution = true
 
 [tool.pdm.scripts]
-start = "uvicorn agent.main:app --host 0.0.0.0 --port 8080"
+start = "uvicorn agent.main:app --host 0.0.0.0 --port 9876"
 start-bg = { shell = "nohup pdm run start > uvicorn.log 2>&1 & echo 'Started in background'; echo \"Logs in uvicorn.log\"" }
 
 [build-system]

+ 4 - 1
agent/readme.md

@@ -18,7 +18,10 @@
 - URL: /api/aitag/admin/v1/generate_reg
 - METHOD:POST
 - Context-Type:application/json
-- Body:{"id": "0196235AA24A459499057D0BA4AEC9BC"}
+- Body:{
+        "tag_name": "智能电网",
+        "tag_remark": "指以智能电网技术为核心,建设或改造电力系统,提升电力系统智能化水平和运行效率的项目。"
+    }
 
 ## 2. 对下游系统接口
 

二進制
agent/release.tar.gz


+ 0 - 1
agent/src/agent/Untitled-1.json

@@ -1 +0,0 @@
-[{"id": "20260200002", "tag_code": "012", "tag_name": "海洋捕捞", "desc": "贷款投向为‘海水捕捞’,用途为‘渔业’,明确指向在海洋自然水域中通过直接采捕方式获取天然海洋生物资源的生产性经济活动,符合标签定义中‘在海洋水域中直接捕获野生生物’的核心语义要素。尽管未出现‘捕捞’等动词,但‘海水捕捞’作为投向明确表达了以获取海产经济价值为目的的直接采捕行为,且‘渔业’作为用途进一步佐证了其生产性经济活动属性。结合‘海水’与‘捕捞’的语义组合,可合理推断其作业环境为海洋自然水域,行为本质为直接采获野生生物,符合标签判定要点。不存在人工培育、苗种投放、养殖管理等排除情形,因此支持命中。", "passr": true}]

+ 3 - 3
agent/src/agent/agent.py

@@ -91,14 +91,14 @@ class GenerateReg(BaseModel):
     """ 大模型生成的正则表达式 """
     reg: str = Field(description="大模型生成的正则表达式")
 
-async def generate_reg(tag_info):
+async def generate_reg(tag_name: str, tag_remark: str):
 
     prompt = f"""
         你是一名银行信贷业务产业标签打标平台的规则设计专家。你的任务是:仅根据我提供的【标签名称】与【语义定义】,生成一条中文关键词正则规则,用于极短文本字段(投向 / 贷款用途)的第一阶段初筛。
 ###
 【输入】
-标签名称:{tag_info[1] if tag_info else ''}
- 语义定义:{tag_info[2] if tag_info else ''}
+标签名称:{tag_name}
+ 语义定义:{tag_remark}
 ###
 【数据特征】
  ● 文本极短(通常 2~8 字)

+ 18 - 21
agent/src/agent/api_inner.py

@@ -87,31 +87,28 @@ def delete_tag(request: SynchronizeTagRequest):
 
 
 class GenerateRegRequest(BaseModel):
-    id: str = Field(..., description="标签编码")
+    tag_name: str = Field(..., description="标签名称")
+    tag_remark: str = Field(..., description="标签定义")
 
-async def generate_and_update_reg(tag_info):
-    reg = await agent.generate_reg(tag_info)
-    reg = reg.replace('))(', ')).*(')  
-    dao.execute(
-        """UPDATE aitag_tag_info SET reg = %s WHERE id = %s""",
-        (reg, tag_info[0])
-    )
-    logging.info(f"Updated reg in database for tag {tag_info[0]}: {reg}")
+async def generate_and_update_reg(tag_name: str, tag_remark: str):
+    reg = await agent.generate_reg(tag_name,tag_remark)
+    logging.info(f"Generated reg for tag {tag_name}: {reg}")
+    reg = reg.replace('))(', ')).*(')
+    logging.info(f"Generated reg for tag {tag_name}: {reg}")
+    logging.info(f"Updated reg in database for tag {tag_name}: {reg}")
+    return reg
 
 @router.post("/generate_reg")
-async def generate_reg(id: GenerateRegRequest, background_tasks: BackgroundTasks):
-    print(f"Received request to generate reg for tag id: {id.id}")
-    tag_info = dao.query(
-            """SELECT id,tag_nm, tag_remark FROM aitag_tag_info WHERE id = %s
-            """,
-            (id.id,)
-    )
-    background_tasks.add_task(
-        generate_and_update_reg,  # 后台任务函数
-        tag_info=tag_info[0] if tag_info else None,
-    )
+async def generate_reg(request: GenerateRegRequest, background_tasks: BackgroundTasks):
+    print(f"Received request to generate reg for tag remark: {request.tag_remark}")
+    # background_tasks.add_task(
+    #     generate_and_update_reg,  # 后台任务函数
+    #     tag_name=request.tag_name,
+    #     tag_remark=request.tag_remark
+    # )
+    reg = await generate_and_update_reg(request.tag_name, request.tag_remark)
     return {
         "code": 200,
-        "message": "generate_reg background task started"
+        "data": reg
     }
     

+ 7 - 1
agent/tests/test_generate_reg.py

@@ -1,6 +1,12 @@
 import requests
 res = requests.post("http://10.192.72.13:9876/api/aitag/admin/v1/generate_reg", json={
-    "id": "0196235AA24A459499057D0BA4AEC9BC"
+    "tag_name": "智能电网",
+    "tag_remark": "指以智能电网技术为核心,建设或改造电力系统,提升电力系统智能化水平和运行效率的项目。"
 })
+
+# res = requests.post("http://localhost:8080/api/aitag/admin/v1/generate_reg", json={
+#     "tag_name": "智能电网",
+#     "tag_remark": "指以智能电网技术为核心,建设或改造电力系统,提升电力系统智能化水平和运行效率的项目。"
+# })
 print(res.json())