mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-18 07:18:53 +00:00
fix(responses): use conversation items when no stored messages exist (#3819)
Handle a base case when no stored messages exist because no Response call has been made. ## Test Plan ``` ./scripts/integration-tests.sh --stack-config server:ci-tests \ --suite responses --inference-mode record-if-missing --pattern test_conversation_responses ```
This commit is contained in:
parent
6ba9db3929
commit
8e7e0ddfec
4 changed files with 1894 additions and 10 deletions
|
@ -63,29 +63,24 @@ class TestConversationResponses:
|
|||
|
||||
# Verify all turns are in conversation
|
||||
conversation_items = openai_client.conversations.items.list(conversation.id)
|
||||
print(f"DEBUG: Found {len(conversation_items.data)} messages in conversation:")
|
||||
for i, item in enumerate(conversation_items.data):
|
||||
if hasattr(item, "role") and hasattr(item, "content"):
|
||||
content = item.content[0].text if item.content else "No content"
|
||||
print(f" {i}: {item.role} - {content}")
|
||||
assert len(conversation_items.data) >= 4 # 2 user + 2 assistant messages
|
||||
|
||||
def test_conversation_context_loading(self, openai_client, text_model_id):
|
||||
"""Test that conversation context is properly loaded for responses."""
|
||||
conversation = openai_client.conversations.create(
|
||||
items=[
|
||||
{"type": "message", "role": "user", "content": "My name is Alice"},
|
||||
{"type": "message", "role": "user", "content": "My name is Alice. I like to eat apples."},
|
||||
{"type": "message", "role": "assistant", "content": "Hello Alice!"},
|
||||
]
|
||||
)
|
||||
|
||||
response = openai_client.responses.create(
|
||||
model=text_model_id,
|
||||
input=[{"role": "user", "content": "What's my name?"}],
|
||||
input=[{"role": "user", "content": "What do I like to eat?"}],
|
||||
conversation=conversation.id,
|
||||
)
|
||||
|
||||
assert "alice" in response.output_text.lower()
|
||||
assert "apple" in response.output_text.lower()
|
||||
|
||||
def test_conversation_error_handling(self, openai_client, text_model_id):
|
||||
"""Test error handling for invalid and nonexistent conversations."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue