Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/app/endpoints/conversations_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ def transform_chat_message(entry: CacheEntry) -> dict[str, Any]:
return {
"provider": entry.provider,
"model": entry.model,
"query": entry.query,
"response": entry.response,
"messages": [
{"content": entry.query, "type": "user"},
{"content": entry.response, "type": "assistant"},
Expand Down
33 changes: 33 additions & 0 deletions tests/unit/app/endpoints/test_conversations_v2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# pylint: disable=redefined-outer-name

"""Unit tests for the /conversations REST API endpoints."""

from app.endpoints.conversations_v2 import transform_chat_message

from models.cache_entry import CacheEntry


def test_transform_message() -> None:
"""Test the transform_chat_message transformation function."""
entry = CacheEntry(
query="query", response="response", provider="provider", model="model"
)
transformed = transform_chat_message(entry)
assert transformed is not None

assert "provider" in transformed
assert transformed["provider"] == "provider"

assert "model" in transformed
assert transformed["model"] == "model"

assert "messages" in transformed
assert len(transformed["messages"]) == 2

message1 = transformed["messages"][0]
assert message1["type"] == "user"
assert message1["content"] == "query"

message2 = transformed["messages"][1]
assert message2["type"] == "assistant"
assert message2["content"] == "response"
Loading