mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-03 09:53:45 +00:00
# What does this PR do? These were maybe be included in the webmethod? The unit test was pointless too since the request was never used anywhere? This shouldn't be in the API definition, if we never consume it. ## Test Plan CI with pre-commit on OpenAPI spec generation. Signed-off-by: Sébastien Han <seb@redhat.com>
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the terms described in the LICENSE file in
|
|
# the root directory of this source tree.
|
|
|
|
|
|
from llama_stack.apis.conversations.conversations import (
|
|
Conversation,
|
|
ConversationItem,
|
|
ConversationItemList,
|
|
)
|
|
|
|
|
|
def test_conversation_model_defaults():
|
|
conversation = Conversation(
|
|
id="conv_123456789",
|
|
created_at=1234567890,
|
|
metadata=None,
|
|
object="conversation",
|
|
)
|
|
assert conversation.id == "conv_123456789"
|
|
assert conversation.object == "conversation"
|
|
assert conversation.metadata is None
|
|
|
|
|
|
def test_openai_client_compatibility():
|
|
from openai.types.conversations.message import Message
|
|
from pydantic import TypeAdapter
|
|
|
|
openai_message = Message(
|
|
id="msg_123",
|
|
content=[{"type": "input_text", "text": "Hello"}],
|
|
role="user",
|
|
status="in_progress",
|
|
type="message",
|
|
object="message",
|
|
)
|
|
|
|
adapter = TypeAdapter(ConversationItem)
|
|
validated_item = adapter.validate_python(openai_message.model_dump())
|
|
|
|
assert validated_item.id == "msg_123"
|
|
assert validated_item.type == "message"
|
|
|
|
|
|
def test_conversation_item_list():
|
|
item_list = ConversationItemList(data=[])
|
|
assert item_list.object == "list"
|
|
assert item_list.data == []
|
|
assert item_list.first_id is None
|
|
assert item_list.last_id is None
|
|
assert item_list.has_more is False
|