Skip to content

Commit

Permalink
Resolved merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
kanesoban committed Dec 17, 2024
2 parents 07d440c + 8e81715 commit 3d2dcf8
Showing 1 changed file with 69 additions and 1 deletion.
70 changes: 69 additions & 1 deletion swarm_copy_tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,78 @@

from swarm_copy.utils import (
RegionMeta,
get_descendants_id
get_descendants_id,
merge_chunk,
merge_fields,
)


def test_merge_fields_str():
target = {"key_1": "abc", "key_2": ""}
source = {"key_1": "def"}
merge_fields(target, source)
assert target == {"key_1": "abcdef", "key_2": ""}

source = {"key_1": "", "key_2": ""}
target = {"key_1": "value_1"}
with pytest.raises(KeyError):
merge_fields(target, source)


def test_merge_fields_dict():
target = {"key_1": "abc", "key_2": {"sub_key_1": "", "sub_key_2": "abc"}}
source = {"key_1": "def", "key_2": {"sub_key_1": "hello", "sub_key_2": "cba"}}
merge_fields(target, source)
assert target == {
"key_1": "abcdef",
"key_2": {"sub_key_1": "hello", "sub_key_2": "abccba"},
}


def test_merge_chunk():
message = {
"content": "",
"sender": "test agent",
"role": "assistant",
"function_call": None,
"tool_calls": [
{
"function": {"arguments": "", "name": ""},
"id": "",
"type": "",
}
],
}
delta = {
"content": "Great content",
"function_call": None,
"refusal": None,
"role": "assistant",
"tool_calls": [
{
"index": 0,
"id": "call_NDiPAjDW4oLef44xIptVSAZC",
"function": {"arguments": "Thalamus", "name": "resolve-entities-tool"},
"type": "function",
}
],
}
merge_chunk(message, delta)
assert message == {
"content": "Great content",
"sender": "test agent",
"role": "assistant",
"function_call": None,
"tool_calls": [
{
"function": {"arguments": "Thalamus", "name": "resolve-entities-tool"},
"id": "call_NDiPAjDW4oLef44xIptVSAZC",
"type": "function",
}
],
}


@pytest.mark.parametrize(
"brain_region_id,expected_descendants",
[
Expand Down

0 comments on commit 3d2dcf8

Please sign in to comment.