mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-14 04:42:41 +00:00
updated tests to verify usage of previous_response_id and conversation
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
parent
1e59793288
commit
9d039e884d
4 changed files with 30 additions and 0 deletions
|
|
@ -30,6 +30,7 @@ CATEGORIES = [
|
|||
"tools",
|
||||
"client",
|
||||
"telemetry",
|
||||
"openai",
|
||||
"openai_responses",
|
||||
"openai_conversations",
|
||||
"testing",
|
||||
|
|
|
|||
|
|
@ -230,6 +230,11 @@ class OpenAIResponsesImpl:
|
|||
if shields is not None:
|
||||
raise NotImplementedError("Shields parameter is not yet implemented in the meta-reference provider")
|
||||
|
||||
if conversation is not None and previous_response_id is not None:
|
||||
raise ValueError(
|
||||
"Mutually exclusive parameters: 'previous_response_id' and 'conversation'. Ensure you are only providing one of these parameters."
|
||||
)
|
||||
|
||||
if conversation is not None:
|
||||
if not conversation.startswith("conv_"):
|
||||
raise InvalidConversationIdError(conversation)
|
||||
|
|
|
|||
|
|
@ -102,6 +102,18 @@ class TestConversationResponses:
|
|||
)
|
||||
assert any(word in str(exc_info.value).lower() for word in ["not found", "404"])
|
||||
|
||||
response = openai_client.responses.create(
|
||||
model=text_model_id, input=[{"role": "user", "content": "First response"}]
|
||||
)
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
openai_client.responses.create(
|
||||
model=text_model_id,
|
||||
input=[{"role": "user", "content": "Hello"}],
|
||||
conversation="conv_test123",
|
||||
previous_response_id=response.id,
|
||||
)
|
||||
assert "mutually exclusive" in str(exc_info.value).lower()
|
||||
|
||||
def test_conversation_backward_compatibility(self, openai_client, text_model_id):
|
||||
"""Test that responses work without conversation parameter (backward compatibility)."""
|
||||
response = openai_client.responses.create(
|
||||
|
|
|
|||
|
|
@ -330,3 +330,15 @@ class TestIntegrationWorkflow:
|
|||
)
|
||||
|
||||
assert "not found" in str(exc_info.value)
|
||||
|
||||
async def test_conversation_and_previous_response_id(
|
||||
self, responses_impl_with_conversations, mock_conversations_api, mock_responses_store
|
||||
):
|
||||
with pytest.raises(ValueError) as exc_info:
|
||||
await responses_impl_with_conversations.create_openai_response(
|
||||
input="test", model="test", conversation="conv_123", previous_response_id="resp_123"
|
||||
)
|
||||
|
||||
assert "Mutually exclusive parameters" in str(exc_info.value)
|
||||
assert "previous_response_id" in str(exc_info.value)
|
||||
assert "conversation" in str(exc_info.value)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue