generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 16
Add LangChain 1.x support #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
YouNeedCryDear
merged 27 commits into
oracle:main
from
fede-kamel:feature/langchain-1.x-support
Dec 11, 2025
+1,984
−520
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
13b3602
Add LangChain 1.x support and comprehensive integration tests
fede-kamel a0db8c5
Fix CI: Update poetry.lock and fix dependency conflicts
fede-kamel f515cd3
Fix linting issues in integration tests
fede-kamel 6674ef6
Require langchain-core>=1.1.0 for ModelProfileRegistry
fede-kamel 0864c9e
Fix mypy type errors for LangChain 1.x compatibility
fede-kamel defa0b7
Restore type: ignore for mock HTTPError responses
fede-kamel 42c2358
Add comprehensive integration tests for OpenAI models
fede-kamel 63c0426
Fix linting issues in test files
fede-kamel 68231af
Update CI matrix to test Python 3.9, 3.12, 3.13
fede-kamel 7a15cb2
Restore backward compatibility with LangChain 0.3.x
fede-kamel d74b49a
Fix test_message_text_property to work with both LangChain 0.3.x and 1.x
fede-kamel 20a1327
Skip JSON mode tests for OpenAI models due to 500 errors
fede-kamel 4185b91
Fix mypy type errors for bind() return type narrowing
fede-kamel eac4d00
Update poetry.lock for Python 3.9 support
fede-kamel 6f3e9b8
Fix Python 3.9 compatibility
fede-kamel c693948
Remove unused type ignore comments for mypy
fede-kamel 5bf6e8e
Support both LangChain 0.3.x and 1.x via Python version markers
fede-kamel 5eb591e
Fix Python 3.9 compatibility issues in tests
fede-kamel 3499780
Fix mypy unreachable error code in test
fede-kamel d7be806
Fix get_min_versions.py to respect Python version markers
fede-kamel 580750d
Add clarifying comment for type annotation in bind_tools
fede-kamel 304d33a
Move test_openai_model.py to integration tests directory
fede-kamel 915c40a
Convert test_openai_model.py to proper pytest format
fede-kamel 589614e
Address review feedback from @paxiaatucsdedu
fede-kamel 5244e47
Remove script-style test file - keep only proper pytest integration t…
fede-kamel c2be785
Remove unused type ignore comments in test_openai_models.py
fede-kamel d728f28
Add unused-ignore to type ignores for cross-version LangChain compati…
fede-kamel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1236,14 +1236,16 @@ def _prepare_request( | |
|
|
||
| def bind_tools( | ||
| self, | ||
| tools: Sequence[Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool]], | ||
| tools: Sequence[Union[Dict[str, Any], type, Callable, BaseTool]], | ||
| # Type annotation matches LangChain's BaseChatModel API. | ||
| # Runtime validation occurs in convert_to_openai_tool(). | ||
| *, | ||
| tool_choice: Optional[ | ||
| Union[dict, str, Literal["auto", "none", "required", "any"], bool] | ||
| ] = None, | ||
| parallel_tool_calls: Optional[bool] = None, | ||
| **kwargs: Any, | ||
| ) -> Runnable[LanguageModelInput, BaseMessage]: | ||
| ) -> Runnable[LanguageModelInput, AIMessage]: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May I ask why use AIMessage instead of BaseMessage? It seems to introduce many type errors? Is it possible to resolve these type errors instead of ignore them? @fede-kamel |
||
| """Bind tool-like objects to this chat model. | ||
|
|
||
| Assumes model is compatible with Meta's tool-calling API. | ||
|
|
@@ -1285,7 +1287,7 @@ def bind_tools( | |
| ) | ||
| kwargs["is_parallel_tool_calls"] = True | ||
|
|
||
| return super().bind(tools=formatted_tools, **kwargs) | ||
| return super().bind(tools=formatted_tools, **kwargs) # type: ignore[return-value, unused-ignore] | ||
|
|
||
| def with_structured_output( | ||
| self, | ||
|
|
@@ -1358,7 +1360,7 @@ def with_structured_output( | |
| key_name=tool_name, first_tool_only=True | ||
| ) | ||
| elif method == "json_mode": | ||
| llm = self.bind(response_format={"type": "JSON_OBJECT"}) | ||
| llm = self.bind(response_format={"type": "JSON_OBJECT"}) # type: ignore[assignment, unused-ignore] | ||
| output_parser = ( | ||
| PydanticOutputParser(pydantic_object=schema) | ||
| if is_pydantic_schema | ||
|
|
@@ -1382,7 +1384,7 @@ def with_structured_output( | |
| json_schema=response_json_schema | ||
| ) | ||
|
|
||
| llm = self.bind(response_format=response_format_obj) | ||
| llm = self.bind(response_format=response_format_obj) # type: ignore[assignment, unused-ignore] | ||
| if is_pydantic_schema: | ||
| output_parser = PydanticOutputParser(pydantic_object=schema) | ||
| else: | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description indicates that Python 3.10+ required. Why keep this python-version: - "3.9"? @fede-kamel