tune: enforce shorter and more colloquial outbound replies
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_en (ubuntu-latest, 3.10) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_zh (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.12) (push) Has been cancelled
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_en (ubuntu-latest, 3.10) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_zh (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.12) (push) Has been cancelled
This commit is contained in:
@@ -91,6 +91,7 @@ class QingjianClient:
|
||||
def _shorten_reply(self, text: str) -> str:
|
||||
max_len = max(8, int(SHORT_REPLY_MAX_CHARS))
|
||||
t = str(text or "").strip()
|
||||
t = self._humanize_reply(t)
|
||||
if len(t) <= max_len:
|
||||
return t
|
||||
parts = re.split(r"[。!?!?]", t)
|
||||
@@ -99,6 +100,27 @@ class QingjianClient:
|
||||
head = head[:max_len].rstrip(",,;;:: ")
|
||||
return head or t[:max_len]
|
||||
|
||||
@staticmethod
|
||||
def _humanize_reply(text: str) -> str:
|
||||
t = str(text or "").strip()
|
||||
replacements = {
|
||||
"您好呀": "在的",
|
||||
"您好,": "在的,",
|
||||
"您好": "在的",
|
||||
"很高兴为您服务": "我在呢",
|
||||
"请问您有什么需求": "你要做啥图",
|
||||
"请问有什么可以帮您": "你要做啥",
|
||||
"可以把要做的图发我": "图发我就行",
|
||||
"请您先完成订单付款": "先拍下付款哈",
|
||||
"麻烦您先完成付款": "先拍下付款哈",
|
||||
"我们马上为您处理": "我马上处理",
|
||||
"我这边": "我这",
|
||||
}
|
||||
for k, v in replacements.items():
|
||||
t = t.replace(k, v)
|
||||
t = t.replace("~~", "~")
|
||||
return t
|
||||
|
||||
@staticmethod
|
||||
def _is_invalid_ai_reply(text: str) -> bool:
|
||||
t = str(text or "").strip().lower()
|
||||
|
||||
Reference in New Issue
Block a user