mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-30 18:13:52 +00:00
OpenAI Responses - image support and multi-turn tool calling
Signed-off-by: Ben Browning <bbrownin@redhat.com>
This commit is contained in:
parent
35b2e2646f
commit
d523c8692a
13 changed files with 186 additions and 34 deletions
|
|
@ -36,3 +36,66 @@ def test_web_search_non_streaming(openai_client, client_with_models, text_model_
|
|||
assert response.output[1].role == "assistant"
|
||||
assert len(response.output[1].content) > 0
|
||||
assert expected.lower() in response.output_text.lower().strip()
|
||||
|
||||
|
||||
def test_input_image_non_streaming(openai_client, vision_model_id):
|
||||
supported_models = ["llama-4", "gpt-4o", "llama4"]
|
||||
if not any(model in vision_model_id.lower() for model in supported_models):
|
||||
pytest.skip(f"Skip for non-supported model: {vision_model_id}")
|
||||
|
||||
response = openai_client.with_options(max_retries=0).responses.create(
|
||||
model=vision_model_id,
|
||||
input=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{
|
||||
"type": "input_text",
|
||||
"text": "Identify the type of animal in this image.",
|
||||
},
|
||||
{
|
||||
"type": "input_image",
|
||||
"image_url": "https://upload.wikimedia.org/wikipedia/commons/f/f7/Llamas%2C_Vernagt-Stausee%2C_Italy.jpg",
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
)
|
||||
output_text = response.output_text.lower()
|
||||
assert "llama" in output_text
|
||||
|
||||
|
||||
def test_multi_turn_web_search_from_image_non_streaming(openai_client, vision_model_id):
|
||||
supported_models = ["llama-4", "gpt-4o", "llama4"]
|
||||
if not any(model in vision_model_id.lower() for model in supported_models):
|
||||
pytest.skip(f"Skip for non-supported model: {vision_model_id}")
|
||||
|
||||
response = openai_client.with_options(max_retries=0).responses.create(
|
||||
model=vision_model_id,
|
||||
input=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{
|
||||
"type": "input_text",
|
||||
"text": "Extract a single search keyword that represents the type of animal in this image.",
|
||||
},
|
||||
{
|
||||
"type": "input_image",
|
||||
"image_url": "https://upload.wikimedia.org/wikipedia/commons/f/f7/Llamas%2C_Vernagt-Stausee%2C_Italy.jpg",
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
)
|
||||
output_text = response.output_text.lower()
|
||||
assert "llama" in output_text
|
||||
|
||||
search_response = openai_client.with_options(max_retries=0).responses.create(
|
||||
model=vision_model_id,
|
||||
input="Search the web using the search tool for those keywords plus the words 'maverick' and 'scout' and summarize the results.",
|
||||
previous_response_id=response.id,
|
||||
tools=[{"type": "web_search"}],
|
||||
)
|
||||
output_text = search_response.output_text.lower()
|
||||
assert "model" in output_text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue