‹ Reports
The Dispatch

OSS Watchlist: langchain-ai/langchain


LangChain Project Faces Critical Asynchronous Streaming Bug

The LangChain project has encountered a significant issue affecting asynchronous streaming capabilities, which is critical for real-time applications.

Key Points:

Recent Activity

Development Team and Recent Activity

Eugene Yurtsev (eyurtsev)

Oleg Kulyk (kami4ka)

Jacob Lee (jacoblee93)

Erick Friis (efriis)

John (Coniferish)

Joel Akeret (jakeret)

Patterns, Themes, and Conclusions

  1. The development team continues to be highly collaborative with frequent interactions among members to address issues and implement new features.
  2. Documentation remains a significant focus area with regular updates to ensure clarity and user-friendliness.
  3. There is a strong emphasis on maintaining compatibility with various dependencies and platforms through continuous infrastructure improvements.
  4. New integrations and functionalities are being added regularly, demonstrating the team's commitment to expanding the project's capabilities.
  5. Bug fixes and minor enhancements are consistently addressed to ensure the stability and performance of the project.

Overall, the LangChain project demonstrates a well-coordinated effort towards building a robust framework for context-aware reasoning applications. The team's commitment to continuous improvement and collaboration is evident from the recent activities.

Risks

Issue #24737: [langchain-ollama] .astream does not extract model response content

Severity: Medium (2/3)

This issue affects asynchronous streaming, which is critical for real-time applications. The bug impacts multiple models (qwen2:0.5b, qwen2:1.5b, llama3.1:8b) using Ollama 0.3.0.

Issue #24720: Chathuggingface 422 error

Severity: Medium (2/3)

This issue affects integration with HuggingFace, a widely used platform for machine learning models. The error prevents users from utilizing ChatHuggingFace with HuggingFaceEndpoint, which could disrupt workflows dependent on this integration.

Issue #24718: Get AttributeError: 'Llama' object has no attribute '_lora_adapter' with llama cpp

Severity: Medium (2/3)

This issue affects users leveraging Llama models with specific configurations, impacting their ability to use these models effectively.

PR #24656: [FIX BUG] text_splitter.py

Severity: Low (1/3)

The pull request addresses a bug in text_splitter.py related to handling the buffer_size parameter. While important, this bug fix does not pose an immediate or significant risk but should be addressed to ensure correct functionality.

Issue #24699: agent_executor.astream_events does not work with ChatGroq

Severity: Medium (2/3)

This issue affects asynchronous event streaming, crucial for interactive applications. Users relying on this functionality will face disruptions if it does not work as expected.

Of Note

  1. Documentation Updates: Continuous updates in documentation by Jacob Lee indicate an ongoing effort to improve user experience by ensuring clarity in usage instructions and correcting errors promptly (#24635).
  2. New Integrations: The addition of new integrations like ScrapingAnt Loader by Oleg Kulyk shows the project's expansion towards supporting more diverse data sources (#24655).
  3. Infrastructure Improvements: Erick Friis's commits focusing on release management and infrastructure improvements demonstrate a commitment to maintaining a robust development pipeline (#24638).

Detailed Reports

Report On: Fetch commits



Repo Commits Analysis

Development Team and Recent Activity

Eugene Yurtsev (eyurtsev)

  • Recent Activity:
    • Commits:
    • Added InMemoryRateLimiter and BaseRateLimiter.
    • Added linter to prevent further usage of root_validator and validator.
    • Temporarily disabled min version checking on pull request.
    • Fixed typo in skipif for chat model integration tests.
    • Collaborations: Erick Friis, Chester Curme.
    • Patterns: Focused on core enhancements, infrastructure improvements, and code quality.

Oleg Kulyk (kami4ka)

  • Recent Activity:
    • Commits:
    • Added ScrapingAnt Loader Community Integration.
    • Collaborations: None noted.
    • Patterns: Focused on adding new integrations.

Jacob Lee (jacoblee93)

  • Recent Activity:
    • Commits:
    • Fixed image caption document loader page and typo on custom tools page.
    • Updated LLM caching, HF sentence transformers, and DDG pages.
    • Removed very old document comparison notebook.
    • Collaborations: None noted.
    • Patterns: Focused on documentation updates and fixes.

Erick Friis (efriis)

  • Recent Activity:
    • Commits:
    • Added unstructured API key to release.
    • Released multiple versions for CLI, Milvus, and other packages.
    • Removed snapshot flag from pytest defaults.
    • Added retry wait on test PyPI.
    • Collaborations: ChengZi, Isaac Francisco, Eugene Yurtsev.
    • Patterns: Focused on infrastructure improvements and release management.

John (Coniferish)

  • Recent Activity:
    • Commits:
    • Initialized langchain-unstructured package with multiple loaders and tests.
    • Collaborations: ChengZi, Isaac Francisco, Erick Friis.
    • Patterns: Focused on adding new functionalities and integrations.

Joel Akeret (jakeret)

  • Recent Activity:
    • Commits:
    • Added compatibility for OllamaFunctions with ImagePromptTemplate.
    • Collaborations: Isaac Francisco, Joel Akeret.
    • Patterns: Focused on enhancing existing features.

Isaac Francisco (isahers1)

  • Recent Activity: ...

Patterns, Themes, and Conclusions

  1. The development team continues to be highly collaborative with frequent interactions among members to address issues and implement new features.
  2. Documentation remains a significant focus area with regular updates to ensure clarity and user-friendliness.
  3. There is a strong emphasis on maintaining compatibility with various dependencies and platforms through continuous infrastructure improvements.
  4. New integrations and functionalities are being added regularly, demonstrating the team's commitment to expanding the project's capabilities.
  5. Bug fixes and minor enhancements are consistently addressed to ensure the stability and performance of the project.

Overall, the LangChain project demonstrates a well-coordinated effort towards building a robust framework for context-aware reasoning applications. The team's commitment to continuous improvement and collaboration is evident from the recent activities.

Report On: Fetch issues



Analysis of Open Issues in LangChain Project

Overview

The LangChain project currently has 673 open issues, with a variety of problems, uncertainties, disputes, TODOs, and anomalies. This analysis will highlight notable issues and trends that are particularly significant for the project's current state.

Notable Open Issues

  1. Issue #24737: [langchain-ollama] .astream does not extract model response content

    • Created by: PaweÅ‚ Kopaniecki
    • Description: The .astream(...) method always returns an empty string for each chunk of the model response. This is due to the response content being contained within an unexpected key.
    • Significance: This issue affects asynchronous streaming, which is critical for real-time applications. The bug impacts multiple models (qwen2:0.5b, qwen2:1.5b, llama3.1:8b) using Ollama 0.3.0.
    • Status: Needs a fix in the .astream source code to correctly extract the response content.
  2. Issue #24720: Chathuggingface 422 error

    • Created by: minmin-intel
    • Description: Using ChatHuggingFace with HuggingFaceEndpoint results in a 422 "Unprocessable entity" error from the huggingface-hub Inference client post function.
    • Significance: This issue affects integration with HuggingFace, a widely used platform for machine learning models.
    • Status: Downgrading to older versions of huggingface_hub and langchain resolves the issue temporarily.
  3. Issue #24718: Get AttributeError: 'Llama' object has no attribute '_lora_adapter' with llama cpp

    • Created by: DdavidC
    • Description: An AttributeError occurs when initializing LlamaCpp with certain parameters.
    • Significance: This issue affects users leveraging Llama models with specific configurations, impacting their ability to use these models effectively.
    • Status: Requires investigation and potential fix in the initialization code for LlamaCpp.
  4. Issue #24713: Error in RootListenersTracer.on_chain_end callback: KeyError('answer') while streaming a RAG Chain Output

    • Created by: Abhishek Acharya
    • Description: A KeyError occurs during the on_chain_end callback when streaming a Retrieval-Augmented Generation (RAG) Chain output.
    • Significance: This impacts the reliability of RAG chains, which are essential for many advanced NLP applications.
    • Status: Needs debugging and resolution to handle missing keys gracefully.
  5. Issue #24703: ChatOllama is missing the parameters seed and base_url

    • Created by: Christoper Manzano
    • Description: The ChatOllama class lacks support for seed and base_url parameters, which are necessary for reproducibility and server hosting configurations.
    • Significance: This limits the flexibility and usability of ChatOllama in different deployment scenarios.
    • Comments: Lennart J. Kurzweg is looking into it and plans to PR a solution focusing on base_url and seed.
  6. Issue #24699: agent_executor.astream_events does not work with ChatGroq

    • Created by: PruthvirajChavan98
    • Description: The agent_executor.astream_events method fails when used with ChatGroq if streaming=True.
    • Significance: This issue affects asynchronous event streaming, crucial for interactive applications.
    • Comments: A workaround involves omitting streaming=True, but this remains a bug needing a proper fix.
  7. Issue #24696: AttributeError: 'Collection' object has no attribute 'model_fields'

    • Created by: WuYanZhao107
    • Description: An AttributeError occurs when using Chroma vector stores due to missing attributes.
    • Significance: This impacts users relying on Chroma for vector storage and retrieval operations.
    • Comments: Harrison Chase suggested checking the chromadb version and upgrading if necessary.
  8. Issue #24675 & Issue #24673 (Documentation Issues)

    • These issues highlight missing or unclear documentation regarding SQL Server permissions and assumptions about optional fields in OpenAIAssistantRunnable.
    • Significance: Proper documentation is crucial for user adoption and effective use of the library.

Recently Closed Issues

  1. Issue #24658 & Issue #24558 (Technical Bugs)

    • These issues were related to sparse vectors in Qdrant and relevance scores in Chroma, respectively.
    • Both were resolved through updates or fixes in the respective modules.
  2. Issue #24473 & Issue #24461 (Model Usage Issues)

    • These issues involved incorrect model usage or unexpected behavior with specific models like gpt-4o-mini.
    • Resolved through user clarification or code corrections.
  3. Issue #24396 (Tool Calling Issue)

    • An issue with passing tool output back to the model using OllamaFunctions was resolved by updating the Ollama server.

Conclusion

The LangChain project has several critical open issues affecting various functionalities such as asynchronous streaming, model initialization, tool integration, and documentation clarity. Addressing these issues promptly will enhance the robustness and usability of the library. Recent closures indicate active maintenance and responsiveness to user-reported problems, which is a positive sign for ongoing development efforts.

Report On: Fetch PR 24656 For Assessment



PR #24656

Summary

This pull request addresses a bug in the text_splitter.py file, which is a critical component for text processing within the langchain repository. The specific issue fixed involves the handling of the buffer_size parameter when it is greater than 1.

Changes

The changes made in this PR are as follows:

diff --git a/libs/experimental/langchain_experimental/text_splitter.py b/libs/experimental/langchain_experimental/text_splitter.py
index 02e7d80916ef7c..5170c8c0c2deb8 100644
--- a/libs/experimental/langchain_experimental/text_splitter.py
+++ b/libs/experimental/langchain_experimental/text_splitter.py
@@ -238,12 +238,12 @@ def split_text(
             end_index = index

             # Slice the sentence_dicts from the current start index to the end index
-            group = sentences[start_index : end_index + 1]
+            group = sentences[start_index : end_index + self.buffer_size]
             combined_text = " ".join([d["sentence"] for d in group])
             chunks.append(combined_text)

             # Update the start index for the next group
-            start_index = index + 1
+            start_index = index + self.buffer_size

         # The last group, if any sentences remain
         if start_index < len(sentences):

Code Quality Assessment

Correctness

  • Bug Fix: The bug fix correctly addresses the issue where buffer_size was not being properly utilized. By changing end_index + 1 to end_index + self.buffer_size, and start_index = index + 1 to start_index = index + self.buffer_size, the code now correctly handles cases where buffer_size is greater than 1.

Readability

  • Clarity: The changes are clear and concise. The variable names and logic are straightforward, making it easy to understand what the code is doing.
  • Comments: The existing comments are sufficient to explain the logic of slicing and updating indices.

Maintainability

  • Modularity: The function remains modular and focused on its task of splitting text. The changes do not introduce any new dependencies or complexity.
  • Testing: While the diff does not show any changes to tests, it would be prudent to ensure that there are tests covering cases with different buffer_size values to validate this fix.

Performance

  • Efficiency: The change does not introduce any performance overhead. It simply corrects the logic for handling buffer sizes.

Recommendations

  1. Testing: Ensure that there are unit tests that cover scenarios with various buffer_size values, including edge cases.
  2. Documentation: If not already present, document the expected behavior of buffer_size in the function's docstring or relevant documentation sections.

Conclusion

The changes made in this pull request are appropriate and effectively fix the identified bug. The code quality is high, maintaining clarity, correctness, and maintainability. With adequate testing, this fix should improve the robustness of the text splitting functionality in LangChain.

Report On: Fetch pull requests



Analysis of Progress Since Last Report

Summary:

Since the last analysis 21 days ago, there has been significant activity in the langchain-ai/langchain repository. Here's a detailed breakdown of the changes:

Open Pull Requests Analysis:

  1. PR #24656: [FIX BUG] text_splitter.py

    • State: Open
    • Created: 0 days ago
    • Significance: Fixes a bug in text_splitter.py when buffer_size is greater than 1.
    • Comments: Includes a comment from vercel[bot] about deployment status.
  2. PR #24655: community: Fix invalid iohttp verify parameter

    • State: Open
    • Created: 0 days ago
    • Significance: Fixes an invalid parameter issue in iohttp.
    • Comments: Includes a comment from vercel[bot] about deployment status.
  3. PR #24644: add rate limiter to integration tests

    • State: Open
    • Created: 0 days ago
    • Significance: Adds a rate limiter to integration tests to manage the load.
    • Comments: Includes multiple commits by Eugene Yurtsev.
  4. PR #24643: graph_transformers: bug fix for create_simple_model not passing in llm_type

    • State: Open
    • Created: 0 days ago
    • Significance: Fixes an issue where llm_type was not passed correctly in create_simple_model.
    • Comments: Includes a comment from vercel[bot] about deployment status.
  5. PR #24641: core[patch]: convert TypedDict to tool schema support

    • State: Open
    • Created: 0 days ago
    • Significance: Converts TypedDict to tool schema support.
    • Comments: Includes multiple commits by Bagatur (baskaryan).
  6. Several other PRs were opened focusing on minor updates, enhancements, and documentation improvements.

Closed Pull Requests Analysis:

  1. #24649: add MoonshotChatOpenAI

    • Closed without being merged.
    • Significance: Proposed support for OpenAI's new version and stream token usage but was not merged.
  2. #24638: infra: add unstructured api key to release

    • Closed and merged by Erick Friis (efriis).
    • Significance: Added an unstructured API key to the release process.
  3. #24635: docs[patch]: Fix image caption document loader page and typo on custom tools page

    • Closed and merged by Jacob Lee (jacoblee93).
    • Significance: Fixed issues in the documentation related to image captions and custom tools.
  4. #24633: docs[patch]: Updates LLM caching, HF sentence transformers, and DDG pages

    • Closed and merged by Jacob Lee (jacoblee93).
    • Significance: Updated various documentation pages for better clarity and accuracy.
  5. #24629: docs: fix ChatGooglePalm fix

    • Closed and merged by ccurme (ccurme).
    • Significance: Fixed an issue with the ChatGooglePalm class not being parsed correctly in the documentation.
  6. Several other PRs were closed focusing on bug fixes, enhancements, and documentation updates.

Conclusion:

The repository has seen substantial activity over the past three weeks with numerous pull requests being opened and closed. Notable changes include bug fixes, documentation improvements, new features like rate limiting for integration tests, and enhanced message handling capabilities. The activity indicates ongoing efforts to enhance functionality, improve user experience, and maintain code quality across the project.


If you have any further questions or need additional details on specific pull requests or changes, feel free to ask!

Report On: Fetch Files For Assessment



Source Code Assessment

File: libs/core/langchain_core/runnables/rate_limiter.py

Structure and Quality

  • Class Design: The file contains two classes, BaseRateLimiter and InMemoryRateLimiter. The BaseRateLimiter serves as an abstract base class, which is a good design choice for extensibility.
  • Methods: The acquire method in BaseRateLimiter is abstract, enforcing subclasses to implement it. The InMemoryRateLimiter implements this method and adds additional functionality.
  • Thread Safety: The use of threading locks in InMemoryRateLimiter ensures thread safety, which is critical for rate limiting.
  • Documentation: Docstrings are present but could be more detailed, especially for the parameters and return types.
  • Error Handling: Basic error handling is in place, but could be more robust (e.g., handling specific exceptions).

Concrete Evidence of Quality

  • Thread Safety: The use of threading locks (self._lock) ensures that the rate limiter is thread-safe.
  • Extensibility: The abstract base class (BaseRateLimiter) allows for future extensions without modifying existing code.

File: libs/community/langchain_community/document_loaders/scrapingant.py

Structure and Quality

  • Class Design: The file contains a single class, ScrapingAntLoader, which extends BaseLoader.
  • Initialization: The constructor initializes the ScrapingAnt client and validates input URLs.
  • Dependencies: Dependencies are imported within the function scope, which is a good practice to avoid unnecessary imports if the functionality is not used.
  • Error Handling: Error handling is present in the lazy_load method, allowing the process to continue on failure if specified.

Concrete Evidence of Quality

  • Dependency Management: The import of ScrapingAntClient within the constructor ensures that the dependency is only loaded if needed.
  • Error Logging: Errors are logged using Python's logging module, providing useful debug information without halting execution.

File: libs/community/langchain_community/document_loaders/unstructured.py

Structure and Quality

  • Class Design: Multiple classes (UnstructuredBaseLoader, UnstructuredFileLoader, UnstructuredAPIFileLoader, etc.) inherit from a common base class (UnstructuredBaseLoader), promoting code reuse and consistency.
  • Deprecation Warnings: Deprecated classes are marked with decorators, guiding users towards newer implementations.
  • Version Validation: Functions like validate_unstructured_version ensure that the required version of dependencies is met.
  • Post Processing: Methods for post-processing elements are provided, allowing for customization.

Concrete Evidence of Quality

  • Version Checks: The presence of version checks (validate_unstructured_version) ensures compatibility with required library versions.
  • Deprecation Handling: Deprecated classes are clearly marked, providing users with information on alternative imports.

File: libs/partners/milvus/langchain_milvus/vectorstores/milvus.py

Structure and Quality

  • Class Design: This file appears to be large (1282 lines), indicating it might contain multiple classes or extensive functionality. Without full context, it's challenging to assess specific details.
  • Dynamic Fields: The update mentions adding dynamic field features, which likely enhances flexibility in vector storage.

Concrete Evidence of Quality

  • Dynamic Field Features: The addition of dynamic fields suggests an improvement in how data can be stored and queried, enhancing the utility of the Milvus vector store.

File: libs/partners/pinecone/langchain_pinecone/embeddings.py

Structure and Quality

  • Class Design: Contains a single class, PineconeEmbeddings, extending from both BaseModel and Embeddings.
  • Configuration Management: Uses Pydantic's configuration management to set default values based on the model type.
  • Asynchronous Support: Provides both synchronous and asynchronous methods for embedding documents and queries.
  • Validation: Root validators ensure that necessary environment variables (like API keys) are set.

Concrete Evidence of Quality

  • Asynchronous Methods: The presence of async methods (aembed_documents, aembed_query) indicates support for non-blocking operations.
  • Environment Validation: Validators ensure that required configurations (like API keys) are present before proceeding.

File: libs/community/langchain_community/retrievers/nanopq.py

Structure and Quality

  • Class Design: Contains a single class, NanoPQRetriever, extending from BaseRetriever.
  • Index Creation: Uses concurrent futures for creating an index of embeddings, improving performance.
  • Error Handling: Basic error handling is present for importing dependencies and during index creation.

Concrete Evidence of Quality

  • Concurrent Index Creation: The use of concurrent futures for embedding creation suggests a focus on performance optimization.
  • Error Messaging: Detailed error messages guide users to resolve issues related to parameter combinations during index creation.

File: libs/community/tests/unit_tests/runnables/test_rate_limiter.py

Structure and Quality

  • Test Coverage: Tests cover both blocking and non-blocking behavior of the rate limiter.
  • Assertions: Uses assertions to validate expected behavior under different conditions (e.g., rate limits being respected).

Concrete Evidence of Quality

  • Comprehensive Testing: Tests cover various scenarios including edge cases like exceeding rate limits, ensuring robustness.

Overall, the code exhibits good practices such as dependency management, error handling, extensibility through abstract base classes, and comprehensive testing. Specific areas like documentation could be improved for better clarity.

Aggregate for risks



Notable Risks

Issue #24737: [langchain-ollama] .astream does not extract model response content

Severity: Medium (2/3)

Rationale

This issue affects asynchronous streaming, which is critical for real-time applications. The bug impacts multiple models, which could hinder the performance and reliability of applications relying on this functionality.

  • Evidence: The issue description highlights that the .astream(...) method always returns an empty string for each chunk of the model response due to the response content being contained within an unexpected key.
  • Reasoning: Asynchronous streaming is essential for real-time applications, and a bug in this functionality can significantly impact user experience and application performance.

Next Steps

  • Assign a developer to investigate and fix the issue in the .astream source code to correctly extract the response content.
  • Add unit tests to cover various scenarios for asynchronous streaming to prevent similar issues in the future.

Issue #24720: Chathuggingface 422 error

Severity: Medium (2/3)

Rationale

This issue affects integration with HuggingFace, a widely used platform for machine learning models. The error prevents users from utilizing ChatHuggingFace with HuggingFaceEndpoint, which could disrupt workflows dependent on this integration.

  • Evidence: The issue description states that using ChatHuggingFace with HuggingFaceEndpoint results in a 422 "Unprocessable entity" error from the huggingface-hub Inference client post function.
  • Reasoning: Integration with HuggingFace is crucial for many users, and an error preventing this integration can lead to significant disruptions in their workflows.

Next Steps

  • Investigate the root cause of the 422 error and implement a fix.
  • Ensure compatibility with the latest versions of huggingface_hub and langchain.
  • Add tests to verify the integration works as expected with different versions of dependencies.

Issue #24718: Get AttributeError: 'Llama' object has no attribute '_lora_adapter' with llama cpp

Severity: Medium (2/3)

Rationale

This issue affects users leveraging Llama models with specific configurations, impacting their ability to use these models effectively. It could lead to frustration and reduced productivity for users relying on these configurations.

  • Evidence: The issue description mentions an AttributeError occurring when initializing LlamaCpp with certain parameters.
  • Reasoning: Users unable to initialize Llama models due to this error will face significant disruptions in their work, especially if these models are critical to their applications.

Next Steps

  • Investigate and fix the initialization code for LlamaCpp to handle the _lora_adapter attribute correctly.
  • Add tests to cover various initialization scenarios for LlamaCpp to ensure robustness.

PR #24656: [FIX BUG] text_splitter.py

Severity: Low (1/3)

Rationale

The pull request addresses a bug in text_splitter.py related to handling the buffer_size parameter. While important, this bug fix does not pose an immediate or significant risk but should be addressed to ensure correct functionality.

  • Evidence: The PR changes correct the logic for handling buffer_size by adjusting index calculations.
  • Reasoning: Proper handling of buffer_size is essential for text processing tasks, but the impact is limited and not urgent.

Next Steps

  • Merge the PR after thorough review and testing.
  • Ensure unit tests cover various buffer_size values to validate the fix.

Issue #24699: agent_executor.astream_events does not work with ChatGroq

Severity: Medium (2/3)

Rationale

This issue affects asynchronous event streaming, crucial for interactive applications. Users relying on this functionality will face disruptions if it does not work as expected.

  • Evidence: The issue description states that agent_executor.astream_events fails when used with ChatGroq if streaming=True.
  • Reasoning: Asynchronous event streaming is vital for interactive applications, and any disruption can significantly impact user experience.

Next Steps

  • Investigate and fix the issue with agent_executor.astream_events when used with ChatGroq.
  • Add tests to ensure asynchronous event streaming works correctly under various conditions.