Skip to content

Dev madina#169

Merged
lfnothias merged 5 commits into
devfrom
dev_madina
Apr 24, 2026
Merged

Dev madina#169
lfnothias merged 5 commits into
devfrom
dev_madina

Conversation

@madina1203

@madina1203 madina1203 commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

User description

Migrated deprecated langchain.pydantic_v1 imports to pydantic directly.


PR Type

enhancement, bug_fix, dependencies


Description

  • Migrate deprecated langchain.pydantic_v1 imports to pydantic

  • Update args_schema type annotations for tools

  • Add big_benchmark.csv for automated evaluation

  • Update dependencies in environment.yml


Diagram Walkthrough

flowchart LR
  A["langchain.pydantic_v1"] -- "migrate to" --> B["pydantic"]
  C["args_schema"] -- "update type" --> D["type[BaseModel]"]
  E["big_benchmark.csv"] -- "add for" --> F["automated evaluation"]
  G["environment.yml"] -- "update" --> H["dependencies"]
Loading

File Walkthrough

Relevant files
Enhancement
14 files
tool_chemicals.py
Migrate to Pydantic and update args_schema                             
+2/-2     
tool_smiles.py
Migrate to Pydantic and update args_schema                             
+2/-2     
tool_target.py
Migrate to Pydantic and update args_schema                             
+2/-2     
tool_taxon.py
Migrate to Pydantic and update args_schema                             
+5/-5     
tool_filesparser.py
Migrate to Pydantic and update args_schema                             
+6/-2     
tool_interpreter.py
Migrate to Pydantic and update args_schema                             
+2/-2     
tool_spectrum.py
Migrate to Pydantic and update args_schema                             
+2/-2     
tool_merge_result.py
Migrate to Pydantic and update args_schema                             
+2/-2     
tool_sparql.py
Migrate to Pydantic and update args_schema                             
+5/-5     
tool_wikidata_query.py
Migrate to Pydantic and update args_schema                             
+5/-5     
tool_validator.py
Migrate to Pydantic and update args_schema                             
+2/-2     
custom_sqlite_file.py
Add ClassVar typing for database path                                       
+3/-3     
database_manager.py
Update memory database manager to use MemorySaver               
+40/-39 
langraph_workflow.py
Improve error logging in process_workflow                               
+1/-1     
Tests
1 files
evaluation.py
Add big_benchmark.csv and improve evaluation script           
+74/-59 
Dependencies
1 files
environment.yml
Update dependencies to newer versions                                       
+13/-13 


Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 23, 2026
    @coderabbitai

    coderabbitai Bot commented Apr 23, 2026

    Copy link
    Copy Markdown

    Important

    Review skipped

    Auto reviews are disabled on base/target branches other than the default branch.

    Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

    ⚙️ Run configuration

    Configuration used: Repository UI

    Review profile: CHILL

    Plan: Pro

    Run ID: 8f6c2540-dc1d-4d49-bce3-9a84b3b4b32f

    You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

    Use the checkbox below for a quick retry:

    • 🔍 Trigger review
    ✨ Finishing Touches
    🧪 Generate unit tests (beta)
    • Create PR with unit tests
    • Commit unit tests in branch dev_madina

    Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

    ❤️ Share

    Comment @coderabbitai help to get the list of available commands and usage tips.

    @qodo-code-review

    Copy link
    Copy Markdown

    Review Summary by Qodo

    Migrate to native Pydantic and update LangChain dependencies

    ✨ Enhancement 🐞 Bug fix

    Grey Divider

    Walkthroughs

    Description
    • Migrated deprecated langchain.pydantic_v1 imports to native pydantic across all agent tools
    • Added explicit type annotations for args_schema and class variables using ClassVar
    • Updated dependencies to latest versions (langchain 0.3.27, pydantic 2.13.3, langgraph 0.3.34)
    • Refactored evaluation script with dataset management and improved error handling
    • Replaced custom SqliteCheckpointerSaver with langgraph's built-in MemorySaver
    
    Diagram
    flowchart LR
      A["Deprecated langchain.pydantic_v1"] -->|"Replace with"| B["Native pydantic imports"]
      C["Old type annotations"] -->|"Add explicit types"| D["ClassVar and type[BaseModel]"]
      E["Old dependencies"] -->|"Update to latest"| F["LangChain 0.3.27, Pydantic 2.13.3"]
      G["Custom SqliteCheckpointerSaver"] -->|"Replace with"| H["langgraph MemorySaver"]
      I["Basic evaluation script"] -->|"Enhance with"| J["Dataset management and error handling"]
    
    Loading

    Grey Divider

    File Changes

    1. app/core/agents/enpkg/tool_chemicals.py ✨ Enhancement +2/-2

    Replace pydantic_v1 import and add type annotation

    app/core/agents/enpkg/tool_chemicals.py


    2. app/core/agents/enpkg/tool_smiles.py ✨ Enhancement +2/-2

    Replace pydantic_v1 import and add type annotation

    app/core/agents/enpkg/tool_smiles.py


    3. app/core/agents/enpkg/tool_target.py ✨ Enhancement +2/-2

    Replace pydantic_v1 import and add type annotation

    app/core/agents/enpkg/tool_target.py


    View more (13)
    4. app/core/agents/enpkg/tool_taxon.py ✨ Enhancement +5/-5

    Replace pydantic_v1 and add ClassVar annotations

    app/core/agents/enpkg/tool_taxon.py


    5. app/core/agents/entry/tool_filesparser.py ✨ Enhancement +6/-2

    Replace pydantic_v1 and create FileAnalyzerInput schema

    app/core/agents/entry/tool_filesparser.py


    6. app/core/agents/interpreter/tool_interpreter.py ✨ Enhancement +2/-2

    Replace pydantic_v1 import and add type annotation

    app/core/agents/interpreter/tool_interpreter.py


    7. app/core/agents/interpreter/tool_spectrum.py ✨ Enhancement +2/-2

    Replace pydantic_v1 import and add type annotation

    app/core/agents/interpreter/tool_spectrum.py


    8. app/core/agents/sparql/tool_merge_result.py ✨ Enhancement +2/-2

    Replace pydantic_v1 import and add type annotation

    app/core/agents/sparql/tool_merge_result.py


    9. app/core/agents/sparql/tool_sparql.py ✨ Enhancement +5/-5

    Replace pydantic_v1 and add explicit type annotations

    app/core/agents/sparql/tool_sparql.py


    10. app/core/agents/sparql/tool_wikidata_query.py ✨ Enhancement +5/-5

    Replace pydantic_v1 and add ClassVar annotations

    app/core/agents/sparql/tool_wikidata_query.py


    11. app/core/agents/validator/tool_validator.py ✨ Enhancement +2/-2

    Replace pydantic_v1 import and add type annotation

    app/core/agents/validator/tool_validator.py


    12. app/core/memory/custom_sqlite_file.py ✨ Enhancement +3/-3

    Remove pydantic_v1 Field import and add ClassVar

    app/core/memory/custom_sqlite_file.py


    13. app/core/memory/database_manager.py 🐞 Bug fix +40/-39

    Replace custom SqliteCheckpointerSaver with MemorySaver

    app/core/memory/database_manager.py


    14. app/core/tests/evaluation.py ✨ Enhancement +74/-59

    Refactor evaluation script with dataset management

    app/core/tests/evaluation.py


    15. app/core/workflow/langraph_workflow.py ✨ Enhancement +1/-1

    Add exception info to error logging

    app/core/workflow/langraph_workflow.py


    16. environment.yml Dependencies +13/-13

    Update all LangChain and dependency versions

    environment.yml


    Grey Divider

    Qodo Logo


    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @qodo-code-review

    qodo-code-review Bot commented Apr 23, 2026

    Copy link
    Copy Markdown

    Code Review by Qodo

    🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (0)

    Grey Divider


    Remediation recommended

    1. Eval runs at import 🐞 Bug ☼ Reliability
    Description
    app/core/tests/evaluation.py still executes LangSmith evaluation (run_on_dataset) at module import
    time, so importing the module triggers network calls and long-running work. This can break
    tooling/CI that imports the package and makes the module unsafe as a library import.
    
    Code

    app/core/tests/evaluation.py[R133-136]

    +# Run evaluation
    chain_results = run_on_dataset(
        dataset_name=dataset_name,
        llm_or_chain_factory=evaluate_result,
    Evidence
    The evaluation script runs substantial logic at top level (not under a main guard), including strict
    env-var checks and an unconditional run_on_dataset() call.
    

    app/core/tests/evaluation.py[22-35]
    app/core/tests/evaluation.py[42-77]
    app/core/tests/evaluation.py[131-146]

    Agent prompt
    The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
    
    ### Issue description
    `app/core/tests/evaluation.py` executes evaluation work (including LangSmith calls and `run_on_dataset`) at import time. This makes imports trigger network calls / long-running work and can fail in environments without required env vars.
    
    ### Issue Context
    This file lives under `app/core/tests/`, which increases the chance it gets imported by IDE tooling, packaging checks, or test tooling.
    
    ### Fix Focus Areas
    - Wrap all executable logic in a `main()` function and call it only under `if __name__ == "__main__":`.
    - Keep only definitions (functions/classes/constants) at module scope.
    
    - app/core/tests/evaluation.py[18-146]
    

    ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



    Advisory comments

    2. Orphaned custom checkpointer 🐞 Bug ⚙ Maintainability
    Description
    SqliteCheckpointerSaver is no longer used after memory_database() switched to returning MemorySaver,
    leaving app/core/memory/custom_sqlite_file.py as dead code with now-misleading rationale comments.
    This increases maintenance burden and makes it unclear which checkpoint implementation is intended.
    
    Code

    app/core/memory/database_manager.py[R1-40]

    +import os
    +from app.core.memory.tools_database import SqliteToolsDatabaseManager
    +import importlib
    +
    +def tools_database():
    +    """
    +    Get the database manager based on the environment variables
    +
    +    :return: The database manager
    +    """
    +    if os.getenv('DATABASE_URL') and os.getenv("TOOLS_DATABASE_MANAGER_CLASS"):
    +        class_path = os.getenv('TOOLS_DATABASE_MANAGER_CLASS')
    +        if class_path:
    +            # Dynamically import the module and class based on the environment variable
    +            module_name, class_name = class_path.rsplit('.', 1)
    +            module = importlib.import_module(module_name)
    +            manager_class = getattr(module, class_name)
    +            return manager_class()
    +    else:
    +        return SqliteToolsDatabaseManager()
    +
    +def memory_database():
    +    """
    +    Get the database manager based on the environment variables
    +
    +    :return: The database manager
    +    """
    +
    +    if os.getenv('DATABASE_URL') and os.getenv("MEMORY_DATABASE_MANAGER_CLASS"):
    +        class_path = os.getenv('MEMORY_DATABASE_MANAGER_CLASS')
    +        if class_path:
    +            # Dynamically import the module and class based on the environment variable
    +            module_name, class_name = class_path.rsplit('.', 1)
    +            module = importlib.import_module(module_name)
    +            manager_class = getattr(module, class_name)
    +            return manager_class()
    +    else:
    +        # Use langgraph's built-in MemorySaver which implements the current checkpoint API
    +        from langgraph.checkpoint.memory import MemorySaver
    +        return MemorySaver()
    Evidence
    database_manager.memory_database() no longer imports/returns SqliteCheckpointerSaver, while the
    custom implementation remains in the repo and documents itself as necessary for Streamlit
    multithreading.
    

    app/core/memory/database_manager.py[1-40]
    app/core/memory/custom_sqlite_file.py[1-29]

    Agent prompt
    The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
    
    ### Issue description
    `SqliteCheckpointerSaver` remains in the repo but is no longer wired in as the default checkpointer. This leaves dead code and misleading comments.
    
    ### Issue Context
    The fallback in `memory_database()` now returns `MemorySaver()`, and the import of `SqliteCheckpointerSaver` was removed.
    
    ### Fix Focus Areas
    - Decide whether the custom sqlite saver is still needed:
     - If not needed: delete `custom_sqlite_file.py` (and any references), or clearly mark it deprecated.
     - If needed for some modes: reintroduce it behind a config/env toggle and document when it should be used.
    
    - app/core/memory/database_manager.py[1-40]
    - app/core/memory/custom_sqlite_file.py[1-29]
    

    ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


    3. Duplicate Optional import 🐞 Bug ⚙ Maintainability
    Description
    tool_taxon.py now imports Optional twice, which is redundant and adds avoidable noise. This makes
    the file harder to maintain and review.
    
    Code

    app/core/agents/enpkg/tool_taxon.py[R1-9]

    +from typing import ClassVar, Optional
    
    from SPARQLWrapper import JSON, SPARQLWrapper
    
    
    -from langchain.pydantic_v1 import BaseModel, Field
    +from pydantic import BaseModel, Field
    
    from typing import Optional
    
    Evidence
    The file imports Optional in the combined import and again later as a standalone import.
    

    app/core/agents/enpkg/tool_taxon.py[1-9]

    Agent prompt
    The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
    
    ### Issue description
    `Optional` is imported twice in `tool_taxon.py`.
    
    ### Issue Context
    The PR added `ClassVar` to the first typing import, but left the previous `from typing import Optional` line in place.
    
    ### Fix Focus Areas
    - Remove the second `from typing import Optional`.
    
    - app/core/agents/enpkg/tool_taxon.py[1-9]
    

    ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


    Grey Divider

    Qodo Logo

    @github-actions

    Copy link
    Copy Markdown
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Docstring Format

    The newly added FileAnalyzerInput class has a minimal docstring. To meet the requirement of using Google Docstring format for key classes, please update it with a short summary line followed by detailed sections (e.g. Args, Returns). This will improve consistency and clarity for users of the tool.

    class FileAnalyzerInput(BaseModel):
        """Input schema for FileAnalyzer - no input fields required."""
        pass

    @github-actions

    github-actions Bot commented Apr 23, 2026

    Copy link
    Copy Markdown
    Contributor

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @lfnothias
    lfnothias merged commit 085c973 into dev Apr 24, 2026
    1 check passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    Dependencies Review effort 3/5 size:L This PR changes 100-499 lines, ignoring generated files.

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants