Open
Conversation
This adds llm/responses.py with sync and async model classes that implement the OpenResponses API using httpx as the transport layer: - ResponsesModel (sync) and AsyncResponsesModel (async) extending KeyModel/AsyncKeyModel for integration with the llm framework - Pydantic models for ResponseResource and streaming events - SSE streaming parser for real-time text deltas - Custom error classes (ResponsesAPIError, ResponsesAuthenticationError, ResponsesRateLimitError, ResponsesInvalidRequestError) - Support for tool/function calls - Comprehensive test suite (35 tests) using TDD approach
- Add needs_key, key_env_var, Options to model classes to fix mypy attribute conflicts - Use ToolCall dataclass correctly for add_tool_call - Add key validation to raise error if no API key provided - Remove banner-style section headings - Clean up outdated TDD comments in tests
Owner
Author
|
I manually tested it with this: import llm
from llm.responses import ResponsesModel
from llm.default_plugins.openai_models import Chat
from llm.tools import llm_time
key = llm.get_key("openai")
chat_model = Chat(
"gpt-5-mini",
vision=True,
reasoning=True,
supports_schema=True,
supports_tools=True,
)
print("=== chat model ===")
print(chat_model.chain("what is the time?", key=key, tools=[llm_time]).text())
print("=== responses model ===")
responses_model = ResponsesModel(
"gpt-5-mini", "https://api.openai.com/v1", supports_schema=True, supports_tools=True
)
print(responses_model.chain("what is the time?", key=key, tools=[llm_time]).text())It didn't work at first because tool results were not passed correctly, but I fixed that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds llm/responses.py with sync and async model classes that
implement the OpenResponses API using httpx as the transport layer:
KeyModel/AsyncKeyModel for integration with the llm framework
ResponsesRateLimitError, ResponsesInvalidRequestError)