mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-11 01:50:46 +08:00
feat(ops): enforce English-only replies and localize netx protocol labels
Append english_output_guard when lang=en, strengthen ops/generalist EN role prompts, pass NETX_TOOL_LANG into netx tools, and map Chinese protocol buckets to English. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
0de5f7bc98
commit
1366459ee0
10 changed files with 146 additions and 4 deletions
17
tests/test_english_output_guard.py
Normal file
17
tests/test_english_output_guard.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import unittest
|
||||
|
||||
from runtime.english_output_guard import english_output_guard_for_lang
|
||||
|
||||
|
||||
class EnglishOutputGuardTests(unittest.TestCase):
|
||||
def test_en_returns_guard(self) -> None:
|
||||
g = english_output_guard_for_lang("en")
|
||||
self.assertIn("English-only", g)
|
||||
self.assertIn("CJK", g)
|
||||
|
||||
def test_zh_empty(self) -> None:
|
||||
self.assertEqual(english_output_guard_for_lang("zh"), "")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
28
tests/test_netx_protocol_localize.py
Normal file
28
tests/test_netx_protocol_localize.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import unittest
|
||||
|
||||
from runtime.tools.experts.network_ops import netx_tools as nt
|
||||
|
||||
|
||||
class NetxProtocolLocalizeTests(unittest.TestCase):
|
||||
def test_localize_protocol_summary_to_en(self) -> None:
|
||||
data = {
|
||||
"protocol_summary": [
|
||||
{"key": "其他", "count": 1},
|
||||
{"key": "时钟", "count": 2},
|
||||
{"key": "OTN/光", "count": 3},
|
||||
{"key": "电源", "count": 4},
|
||||
{"key": "IP/MPLS", "count": 5},
|
||||
]
|
||||
}
|
||||
out = nt._localize_netx_payload(dict(data), lang="en")
|
||||
keys = [r["key"] for r in out["protocol_summary"]]
|
||||
self.assertEqual(keys, ["Other", "Clock", "OTN/Optical", "Power", "IP/MPLS"])
|
||||
|
||||
def test_zh_payload_unchanged(self) -> None:
|
||||
data = {"protocol_summary": [{"key": "其他", "count": 1}]}
|
||||
out = nt._localize_netx_payload(dict(data), lang="zh")
|
||||
self.assertEqual(out["protocol_summary"][0]["key"], "其他")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue