Merged
Conversation
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.
Description
This PR add streaming support, resolves OpenAI provider bugs, adds a real OpenAI graph agent example, and fixes all mypy type errors.
Type of Change
Related Issues
Fixes OpenAI provider type errors and runtime issues
Changes Made
1. Added Streaming support
2. Fixed OpenAI Provider Bugs (
src/routekit/providers/openai.py)httpximport: Now importshttpxat runtime (not just inTYPE_CHECKING) so it's available in exception handlerscontent=Nonehandling: Changedmessage.get("content", "")tomessage.get("content") or ""to properly handle cases where OpenAI returnsNonefor content (common when tool calls are present)3. Added Real OpenAI Example (
examples/graph_agent_real.py)gpt-4o-minifor cost efficiency (can be changed to other models)4. Fixed Type Errors
src/routekit/core/runtime.py: Added type assertions forModelResponsewhenstream=FalseandAsyncIteratorwhenstream=Truesrc/routekit/core/agent.py: Added type assertion forRunResultin streaming method5. Code Formatting
ruff formatto all modified filesTesting
test_streaming_serve.py- all tests pass without hanginggraph_agent_real.py- successfully executes with real OpenAI APImypy src/ruff check src/Checklist
mypy src/)ruff check src/)Additional Notes
graph_agent_real.pyexample requiresOPENAI_API_KEYenvironment variable to be setgpt-4o-minifor cost efficiency, but can be changed to other models likegpt-4orgpt-3.5-turbo