1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
# pylint: disable=too-many-lines,line-too-long,useless-suppression
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
# cSpell:disable
# import os
import pytest
from test_base import TestBase, servicePreparer, recorded_by_proxy_httpx
from devtools_testutils import is_live_and_not_recording
@pytest.mark.skipif(
condition=(not is_live_and_not_recording()),
reason="Skipped because we cannot record network calls with OpenAI client",
)
class TestResponses(TestBase):
# To run this test:
# pytest tests\responses\test_responses.py::TestResponses::test_responses -s
@servicePreparer()
@recorded_by_proxy_httpx
def test_responses(self, **kwargs):
"""
Test creating a responses call (no Agents, no Conversation).
Routes used in this test:
Action REST API Route OpenAI Client Method
------+---------------------------------------------+-----------------------------------
POST /openai/responses client.responses.create()
"""
model = self.test_agents_params["model_deployment_name"]
client = self.create_client(operation_group="agents", **kwargs).get_openai_client()
response1 = client.responses.create(
model=model,
input="How many feet in a mile?",
)
print(f"Response id: {response1.id}, output text: {response1.output_text}")
assert "5280" in response1.output_text or "5,280" in response1.output_text
response2 = client.responses.create(
model=model, input="And how many meters?", previous_response_id=response1.id
)
print(f"Response id: {response2.id}, output text: {response2.output_text}")
assert "1609" in response2.output_text or "1,609" in response2.output_text
|