forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_models.py
More file actions
71 lines (58 loc) · 2.74 KB
/
Copy pathtest_models.py
File metadata and controls
71 lines (58 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from datetime import datetime, timezone
from omi_plugin_sdk.models import ActionItem, Conversation, Structured
def test_structured_parses_action_items_and_optional_lists():
structured = Structured.model_validate(
{
"title": "Planning",
"overview": "Discussed launch tasks",
"category": "not-a-real-category",
"action_items": [{"description": "Send recap", "completed": True}],
}
)
assert structured.category.value == "other"
assert structured.action_items == [ActionItem(description="Send recap", completed=True)]
assert structured.events == []
def test_conversation_parses_legacy_payload_without_optional_lists():
conversation = Conversation.model_validate(
{
"created_at": datetime.now(timezone.utc).isoformat(),
"transcript_segments": [{"text": "hello", "speaker": "SPEAKER_03", "is_user": False, "start": 0, "end": 1}],
"structured": {"title": "hello", "overview": "world"},
}
)
assert conversation.discarded is False
assert conversation.transcript_segments[0].speaker_id == 3
assert conversation.structured.action_items == []
def test_dropbox_compatible_conversation_helpers():
conversation = Conversation.model_validate(
{
"id": "conv-1",
"created_at": datetime.now(timezone.utc).isoformat(),
"transcript_segments": [
{"text": "hello", "speaker": "SPEAKER_01", "is_user": False, "start": 0, "end": 2},
{"text": "reply", "speaker": "SPEAKER_00", "is_user": True, "start": 3, "end": 5},
],
"structured": {
"title": "Dropbox",
"overview": "Summary",
"action_items": [{"description": "Share file"}],
},
}
)
assert conversation.id == "conv-1"
assert conversation.get_duration() == "0:00:05"
assert "[0:00:00 - 0:00:02] Speaker 1: hello" in conversation.get_transcript(include_timestamps=True)
assert "User: reply" in conversation.get_transcript(user_name="User")
def test_conversation_preserves_apps_results_and_syncs_legacy_plugins_results():
conversation = Conversation.model_validate(
{
"created_at": datetime.now(timezone.utc).isoformat(),
"transcript_segments": [],
"structured": {"title": "Apps", "overview": "Has app output"},
"apps_results": [{"app_id": "summarizer", "content": "App summary"}],
}
)
assert conversation.apps_results[0].app_id == "summarizer"
assert conversation.apps_results[0].content == "App summary"
assert conversation.plugins_results[0].plugin_id == "summarizer"
assert conversation.plugins_results[0].content == "App summary"