落地报价模板 AI 解析与对象存储,并增加回复超时系统设置页。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""本地冒烟:sheet_map 解析 + 桌面 8 张样表可读。不打千问。"""
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import sys
|
||||
import types
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
DESK = Path(r"C:/Users/Administrator/Desktop/海陆空报价单模板最新-0917/海陆空报价单模板最新-0917")
|
||||
|
||||
|
||||
def load_sheet_map():
|
||||
llm_mode = types.ModuleType("agent.llm.modes")
|
||||
|
||||
class LlmMode:
|
||||
class SHEET_MAP:
|
||||
value = "sheet_map"
|
||||
|
||||
llm_mode.LlmMode = LlmMode
|
||||
sys.modules.setdefault("agent", types.ModuleType("agent"))
|
||||
sys.modules.setdefault("agent.llm", types.ModuleType("agent.llm"))
|
||||
sys.modules["agent.llm.modes"] = llm_mode
|
||||
path = ROOT / "agent" / "llm" / "mode_sheet_map.py"
|
||||
spec = importlib.util.spec_from_file_location("mode_sheet_map", path)
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
assert spec.loader is not None
|
||||
spec.loader.exec_module(mod)
|
||||
return mod
|
||||
|
||||
|
||||
def main() -> None:
|
||||
mod = load_sheet_map()
|
||||
out = mod.parse_mapping_json('{"fields":{"quote_no":"S!A1"},"feeRegions":[]}')
|
||||
assert out["ok"], out
|
||||
fenced = mod.strip_json_fence('```json\n{"a":1}\n```')
|
||||
assert '"a"' in fenced or "a" in fenced
|
||||
msg = mod.build_user_message(
|
||||
{
|
||||
"transportMode": "land",
|
||||
"fileName": "陆运.xlsx",
|
||||
"sheet": "Sheet1",
|
||||
"cellInventory": ["Sheet1!A1 | 客户 | - | FFFF00"],
|
||||
}
|
||||
)
|
||||
assert "陆运" in msg
|
||||
prompt = ROOT / "agent" / "quote_templates" / "prompts" / "mapping_analyzer.txt"
|
||||
assert prompt.is_file() and prompt.stat().st_size > 1000, prompt
|
||||
print("sheet_map helpers OK")
|
||||
|
||||
assert DESK.is_dir(), f"missing desktop dir: {DESK}"
|
||||
files = sorted(list(DESK.glob("*.xlsx")) + list(DESK.glob("*.xlsx.xlsx")))
|
||||
assert len(files) >= 8, f"expected >=8 templates, got {len(files)}"
|
||||
try:
|
||||
import openpyxl
|
||||
except ImportError:
|
||||
print(f"desktop files present: {len(files)} (openpyxl not installed, skip cell count)")
|
||||
for f in files:
|
||||
print(" -", f.name)
|
||||
return
|
||||
for f in files:
|
||||
wb = openpyxl.load_workbook(f, data_only=False)
|
||||
ws = wb.active
|
||||
n = sum(1 for row in ws.iter_rows(max_row=100, max_col=24) for c in row if c.value is not None)
|
||||
print(f"{f.name}: sheet={ws.title} nonempty≈{n}")
|
||||
print("desktop 8 templates readable OK")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user