mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-19 08:28:10 +02:00
fix timestamps in tuner accumelator (#335)
* fix timestamps in tuner accumelator * chore: refactor strip_thought_ids_from_messages --------- Co-authored-by: Abhishek Kumar <abhishek@a6k.me>
This commit is contained in:
parent
af66372b65
commit
67479e98fd
3 changed files with 54 additions and 3 deletions
42
api/tests/test_message_sanitization.py
Normal file
42
api/tests/test_message_sanitization.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from copy import deepcopy
|
||||
|
||||
from pipecat.utils.context.message_sanitization import (
|
||||
strip_thought_from_id,
|
||||
strip_thought_ids_from_messages,
|
||||
)
|
||||
|
||||
|
||||
def test_strip_thought_from_id():
|
||||
assert strip_thought_from_id("call_123__thought__abc") == "call_123"
|
||||
assert strip_thought_from_id("call_123") == "call_123"
|
||||
assert strip_thought_from_id(None) is None
|
||||
|
||||
|
||||
def test_strip_thought_ids_from_messages_does_not_mutate_input():
|
||||
messages = [
|
||||
{
|
||||
"role": "assistant",
|
||||
"tool_calls": [
|
||||
{
|
||||
"id": "call_1__thought__hidden",
|
||||
"type": "function",
|
||||
"function": {"name": "lookup", "arguments": "{}"},
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "call_1__thought__hidden",
|
||||
"content": '{"status":"ok"}',
|
||||
},
|
||||
]
|
||||
original = deepcopy(messages)
|
||||
|
||||
cleaned = strip_thought_ids_from_messages(messages)
|
||||
|
||||
assert messages == original
|
||||
assert cleaned is not messages
|
||||
assert cleaned[0]["tool_calls"][0]["id"] == "call_1"
|
||||
assert cleaned[1]["tool_call_id"] == "call_1"
|
||||
Loading…
Add table
Add a link
Reference in a new issue