Add workflow support and enhance runtime configuration in models and services
- Introduce RuntimeModelResource and RuntimeKnowledgeBase classes to manage workflow resources. - Update AssistantConfig to include workflow_model_resources and workflow_knowledge_bases for better integration. - Refactor validation and processing logic in routes and services to accommodate workflow types. - Implement dynamic variable support for workflow assistants and enhance graph normalization. - Add ToolExecutor for reusable tool execution across different assistant types. - Update various services to ensure compatibility with new workflow features and improve error handling.
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import unittest
|
||||
|
||||
from models import AssistantConfig
|
||||
from services.pipecat.pipeline import _knowledge_tool_description
|
||||
from services.pipecat.pipeline import (
|
||||
KNOWLEDGE_CONTEXT_MARKER,
|
||||
KnowledgeRetrievalProcessor,
|
||||
_knowledge_tool_description,
|
||||
)
|
||||
|
||||
|
||||
class KnowledgeToolDescriptionTest(unittest.TestCase):
|
||||
@@ -33,6 +37,25 @@ class KnowledgeToolDescriptionTest(unittest.TestCase):
|
||||
self.assertNotIn("\n ", description)
|
||||
self.assertLess(len(description), 1000)
|
||||
|
||||
def test_workflow_knowledge_uses_system_role(self):
|
||||
processor = KnowledgeRetrievalProcessor(None)
|
||||
messages = [
|
||||
{"role": "assistant", "content": "你好"},
|
||||
{
|
||||
"role": "developer",
|
||||
"content": f"{KNOWLEDGE_CONTEXT_MARKER}\n旧检索结果",
|
||||
},
|
||||
]
|
||||
|
||||
processor._set_context(
|
||||
messages,
|
||||
f"{KNOWLEDGE_CONTEXT_MARKER}\n新检索结果",
|
||||
)
|
||||
|
||||
self.assertEqual(messages[0]["role"], "system")
|
||||
self.assertIn("新检索结果", messages[0]["content"])
|
||||
self.assertFalse(any(message["role"] == "developer" for message in messages))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user