mirror of
https://github.com/primedigitaltech/market-assistant.git
synced 2026-07-21 23:41:39 +08:00
新增 providers 包:协议、Crawler 网关适配器、output 去围栏、token 启发式与工厂;llm_client 与 keyword_suggest 走统一入口。未改各 generate_* 提示词。补充 MA_LLM_TEXT_PROVIDER 说明至 .env.example。 Made-with: Cursor
16 lines
612 B
Python
16 lines
612 B
Python
"""对模型原始输出做与业务无关的轻量归一化(不修改提示词)。"""
|
|
from __future__ import annotations
|
|
|
|
|
|
def strip_outer_markdown_fence(text: str) -> str:
|
|
"""若模型用 ``` / ```markdown 包裹全文,去掉最外层围栏。与 `AI_crawler.strip_outer_markdown_fence` 行为一致。"""
|
|
t = (text or "").strip()
|
|
if not t.startswith("```"):
|
|
return t
|
|
lines = t.split("\n")
|
|
if lines and lines[0].strip().startswith("```"):
|
|
lines = lines[1:]
|
|
while lines and lines[-1].strip() == "```":
|
|
lines = lines[:-1]
|
|
return "\n".join(lines).strip()
|