feat: add configurable client tools and photo input
This commit is contained in:
57
backend/tests/test_user_input.py
Normal file
57
backend/tests/test_user_input.py
Normal file
@@ -0,0 +1,57 @@
|
||||
import unittest
|
||||
|
||||
from services.pipecat.processors import UserInputError, parse_user_input
|
||||
|
||||
|
||||
class UserInputParserTests(unittest.TestCase):
|
||||
def test_parses_text_and_current_camera_frame(self):
|
||||
value = parse_user_input(
|
||||
{
|
||||
"type": "user-input",
|
||||
"schema_version": 1,
|
||||
"input_id": "input_1",
|
||||
"parts": [
|
||||
{"type": "input_text", "text": "帮我看看"},
|
||||
{
|
||||
"type": "input_image",
|
||||
"source": {
|
||||
"type": "camera_frame",
|
||||
"frame": "current",
|
||||
},
|
||||
},
|
||||
],
|
||||
"options": {
|
||||
"run_immediately": True,
|
||||
"interrupt": True,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
self.assertIsNotNone(value)
|
||||
self.assertEqual(value.text, "帮我看看")
|
||||
self.assertTrue(value.has_camera_frame)
|
||||
self.assertEqual(value.transcript_text, "帮我看看\n已发送一张图片")
|
||||
|
||||
def test_rejects_legacy_and_unsupported_image_sources(self):
|
||||
self.assertIsNone(parse_user_input({"type": "user-text", "text": "旧协议"}))
|
||||
with self.assertRaisesRegex(UserInputError, "当前摄像头"):
|
||||
parse_user_input(
|
||||
{
|
||||
"type": "user-input",
|
||||
"schema_version": 1,
|
||||
"input_id": "input_2",
|
||||
"parts": [
|
||||
{
|
||||
"type": "input_image",
|
||||
"source": {
|
||||
"type": "uploaded_asset",
|
||||
"asset_id": "asset_1",
|
||||
},
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user