Enhance AIClient with skill document processing capabilities
Added a new method to run a skill document pipeline, allowing for enhanced processing of user messages based on specified skill documents. Implemented logic to extract relevant text from user messages and improved error handling during processing. Updated message handling to strip URLs from responses to prevent issues with message delivery. Added tests to validate the new processing functionality and ensure robustness.
This commit is contained in:
@@ -55,3 +55,19 @@ def test_extract_prefix_limit_from_user_message():
|
||||
assert AIClient._extract_prefix_limit("直接返回前100字") == 100
|
||||
assert AIClient._extract_prefix_limit("前 256 字") == 256
|
||||
assert AIClient._extract_prefix_limit("返回全文") is None
|
||||
|
||||
|
||||
def test_extract_processing_payload_with_marker():
|
||||
message = "调用humanizer_zh.read_skill_doc人性化处理以下文本:\n第一段。\n第二段。"
|
||||
payload = AIClient._extract_processing_payload(message)
|
||||
assert payload == "第一段。\n第二段。"
|
||||
|
||||
|
||||
def test_extract_processing_payload_with_generic_pattern():
|
||||
message = "请按技能规则优化如下:\n这是待处理文本。"
|
||||
payload = AIClient._extract_processing_payload(message)
|
||||
assert payload == "这是待处理文本。"
|
||||
|
||||
|
||||
def test_extract_processing_payload_returns_none_when_absent():
|
||||
assert AIClient._extract_processing_payload("请调用工具 humanizer_zh.read_skill_doc") is None
|
||||
|
||||
Reference in New Issue
Block a user