feat: set store=False and add run_inference tests
Set store=False in Responses API calls since we send full conversation history as input items and don't use previous_response_id. Add 5 run_inference tests for OpenAIResponsesLLMService using real LLMContext and adapter (only HTTP client mocked).
This commit is contained in:
committed by
Mark Backman
parent
cd2886a4a8
commit
c66a5a8ede
@@ -79,9 +79,19 @@ class OpenAIResponsesLLMAdapter(BaseLLMAdapter[OpenAIResponsesLLMInvocationParam
|
|||||||
# message when instructions are provided. Contexts that worked with
|
# message when instructions are provided. Contexts that worked with
|
||||||
# OpenAILLMService (system_instruction + empty messages) need the
|
# OpenAILLMService (system_instruction + empty messages) need the
|
||||||
# instructions converted to an initial developer message.
|
# instructions converted to an initial developer message.
|
||||||
# NOTE: once we support `previous_response_id`, we need to revisit
|
#
|
||||||
|
# NOTE: if/when we support `previous_response_id`, we'll need to revisit
|
||||||
# this logic, as it'll be legit to provide instructions without input
|
# this logic, as it'll be legit to provide instructions without input
|
||||||
# items if `previous_response_id` is provided.
|
# items if `previous_response_id` is provided. Though...OpenAI's docs +
|
||||||
|
# ChatGPT suggests that `previous_response_id` is primarily for
|
||||||
|
# development convenience, not performance (other than minor bandwidth
|
||||||
|
# savings from not transferring the full context), as the model still
|
||||||
|
# processes the full context from the previous response. The tradeoff
|
||||||
|
# of using `previous_response_id` is that it requires enabling OpenAI-side
|
||||||
|
# 30-day conversation storage (meaning we couldn't do `store=False`
|
||||||
|
# in the API call), which may not be desirable for all users. So,
|
||||||
|
# my guess is we won't need to support `previous_response_id` in the
|
||||||
|
# immediate future.
|
||||||
if not input_items:
|
if not input_items:
|
||||||
params["input"] = [{"role": "developer", "content": system_instruction}]
|
params["input"] = [{"role": "developer", "content": system_instruction}]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -324,6 +324,7 @@ class OpenAIResponsesLLMService(LLMService):
|
|||||||
params: Dict[str, Any] = {
|
params: Dict[str, Any] = {
|
||||||
"model": self._settings.model,
|
"model": self._settings.model,
|
||||||
"stream": True,
|
"stream": True,
|
||||||
|
"store": False,
|
||||||
"input": invocation_params["input"],
|
"input": invocation_params["input"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -801,6 +801,7 @@ async def test_openai_responses_run_inference_with_llm_context():
|
|||||||
call_kwargs = service._client.responses.create.call_args.kwargs
|
call_kwargs = service._client.responses.create.call_args.kwargs
|
||||||
assert call_kwargs["model"] == "gpt-4.1"
|
assert call_kwargs["model"] == "gpt-4.1"
|
||||||
assert call_kwargs["stream"] is False
|
assert call_kwargs["stream"] is False
|
||||||
|
assert call_kwargs["store"] is False
|
||||||
assert call_kwargs["input"] == [{"role": "user", "content": "Hello, world!"}]
|
assert call_kwargs["input"] == [{"role": "user", "content": "Hello, world!"}]
|
||||||
assert call_kwargs["instructions"] == "You are a helpful assistant"
|
assert call_kwargs["instructions"] == "You are a helpful assistant"
|
||||||
assert call_kwargs["temperature"] == 0.7
|
assert call_kwargs["temperature"] == 0.7
|
||||||
|
|||||||
Reference in New Issue
Block a user