Skip to content

Dev#153

Merged
lfnothias merged 87 commits intomainfrom
dev
Apr 17, 2025
Merged

Dev#153
lfnothias merged 87 commits intomainfrom
dev

Conversation

@madina1203
Copy link
Collaborator

@madina1203 madina1203 commented Apr 7, 2025

PR Type

enhancement, documentation, configuration changes, tests


Description

  • Implemented support for different LLMs per agent.

  • Added Docker and Streamlit support for deployment.

  • Enhanced documentation with setup and usage instructions.

  • Introduced automated cleanup for temporary files and database entries.


Changes walkthrough 📝

Relevant files
Enhancement
25 files
agents_factory.py
Add LLM instance support in agent creation                             
+25/-2   
agent.py
Support specific LLM instance in agent creation                   
+3/-2     
agent.py
Support specific LLM instance in entry agent                         
+4/-3     
prompt.py
Update entry agent prompt for file handling                           
+7/-5     
prompt.py
Update interpreter prompt for spectrum plotting                   
+18/-6   
tool_spectrum.py
Add new tool for spectrum plotting                                             
+121/-0 
agent.py
Support specific LLM instance in SPARQL agent                       
+6/-6     
prompt.py
Update SPARQL prompt for visualization handling                   
+1/-1     
tool_merge_result.py
Update tool merge result for optional parameters                 
+1/-1     
tool_sparql.py
Update SPARQL tool for optional entity parameter                 
+1/-1     
agent.py
Support specific LLM instance in supervisor agent               
+2/-2     
prompt.py
Update supervisor prompt for visualization tasks                 
+1/-1     
agent.py
Support specific LLM instance in validator agent                 
+4/-2     
prompt.py
Update validator prompt for question validity                       
+5/-3     
RdfGraphCustom.py
Add authentication support for SPARQL store                           
+3/-2     
llm_handler.py
Add LLM creation utility for multiple providers                   
+47/-0   
main.py
Refactor main for LLM and endpoint management                       
+186/-264
session.py
Update session management for MetaboT                                       
+13/-13 
langraph_workflow.py
Refactor workflow for agent and model integration               
+151/-107
cleanup_database.py
Add script for database cleanup                                                   
+18/-0   
cleanup_files.py
Add script for file cleanup                                                           
+44/-0   
postgres_database.py
Add PostgreSQL database management                                             
+95/-0   
postgres_tool_database.py
Add tool-specific database operations                                       
+79/-0   
streamlit_app.py
Add main Streamlit application                                                     
+496/-0 
streamlit_utils.py
Add utility functions for Streamlit app                                   
+337/-0 
Miscellaneous
1 files
tool_interpreter.py
Remove unused code and clean up                                                   
+0/-5     
Formatting
2 files
test_db_connection.py
Format code for database connection test                                 
+7/-7     
tools_database.py
Add newline for code clarity                                                         
+2/-0     
Tests
3 files
questions.py
Add standard questions for testing                                             
+73/-0   
evaluation.py
Update evaluation script for LangSmith                                     
+54/-43 
installation_test.py
Add installation test script                                                         
+12/-0   
Configuration changes
8 files
.python-version
Specify Python version for the project                                     
+1/-0     
Dockerfile
Add Dockerfile for containerization                                           
+10/-0   
Procfile
Add Procfile for Heroku deployment                                             
+1/-0     
params.ini
Update configuration for LLM models                                           
+18/-9   
params_alternative.ini
Add alternative configuration file                                             
+55/-0   
docker-compose.yml
Add Docker Compose configuration                                                 
+8/-0     
environment.yml
Update environment dependencies                                                   
+3/-1     
setup.sh
Add setup script for Streamlit                                                     
+12/-0   
Documentation
3 files
README.md
Update README with setup and usage instructions                   
+72/-17 
mkdocs.yml
Update documentation configuration                                             
+1/-1     
README.md
Add README for Streamlit web app                                                 
+114/-0 
Additional files
1 files
__init__.py [link]   

Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • lfnothias and others added 30 commits February 13, 2025 12:25
    Managing environment variable for langchain project and endpoint
    Add information regarding different llm models in README
    @qodo-code-review
    Copy link

    Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

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

    Duplicate Imports

    The diff shows duplicate import and environment loading calls (e.g. multiple calls to load_dotenv and duplicate imports of create_workflow). Consider consolidating these statements to improve clarity and maintainability.

    import os
    import argparse
    from typing import Any, Dict, Optional
    from dotenv import load_dotenv
    from langsmith import Client
    from pathlib import Path
    from app.core.workflow.langraph_workflow import create_workflow, process_workflow
    from app.core.utils import setup_logger
    import pickle
    import configparser
    
    # Load environment variables
    load_dotenv()
    
    from typing import Any, Optional, Tuple
    import functools
    import argparse
    
    from langchain_community.chat_models import ChatOpenAI, ChatLiteLLM
    from dotenv import load_dotenv
    load_dotenv()
    
    
    import os
    
    from langsmith import Client
    from app.core.graph_management.RdfGraphCustom import RdfGraph
    from app.core.agents.agents_factory import create_all_agents
    from app.core.workflow.langraph_workflow import create_workflow, process_workflow
    from app.core.utils import setup_logger, load_config
    Docstring Consistency

    Some newly added key functions (e.g. get_api_key, create_litellm_model, llm_creation, langsmith_setup) include docstrings. Ensure they strictly follow the Google DocString format for arguments, returns, and usage details for documentation tools.

    def get_api_key(provider: str) -> Optional[str]:
        """
        Get API key for specified provider from environment variables.
    
        Args:
            provider: Provider name matching a key in API_KEY_MAPPING
    
        Returns:
            API key if found, None otherwise
        """
        env_var = API_KEY_MAPPING.get(provider)
        return os.getenv(env_var) if env_var else None
    
    def create_litellm_model(config: configparser.SectionProxy) -> ChatLiteLLM:
        """
        Create a ChatLiteLLM instance based on the model id and configuration.
        Only uses parameters that are explicitly specified in the configuration.
    
        Args:
            config (configparser.SectionProxy): The configuration section
    
        Returns:
            ChatLiteLLM: Configured ChatLiteLLM instance
        """
        if "id" not in config:

    @github-actions
    Copy link
    Contributor

    github-actions bot commented Apr 7, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 5 🔵🔵🔵🔵🔵
    🔒 Security concerns

    No critical security vulnerabilities were identified. However, be cautious to avoid accidental exposure of API keys and other sensitive credentials in logs or client-side messages.

    ⚡ Recommended focus areas for review

    Docstring Format

    Consider ensuring that all key functions and classes (e.g., create_all_agents) include Google-style docstrings. Consistent and clear documentation for parameters, return values, and exceptions will improve code maintainability.

    def create_all_agents(llms, graph, openai_key=None, session_id=None):
        """
        Dynamically create and initialize all agent modules as specified in the configuration.
    
        Parameters:
            llms (dict): A dictionary mapping LLM keys to their instances.
            graph: The graph instance used by the agents.
            openai_key (str, optional): The OpenAI API key to be used by agents. If not provided, it will be read from the environment.
            session_id (str, optional): A unique session identifier. If not provided, a new user session will be created.
    
        Returns:
            dict: A dictionary mapping agent names to their created executor instances.
        """
    Security Logging

    Verify that sensitive details such as API keys and credentials are not logged or exposed in error messages. Ensure that logging statements properly mask or exclude confidential information.

    def llm_creation(api_key: Optional[str] = None) -> Dict[str, ChatOpenAI]:
        """
        Create language models based on configuration parameters.
    
        Args:
            api_key (Optional[str]): The API key for OpenAI. If None, uses environment variable.
    
        Returns:
            Dict[str, ChatOpenAI]: A dictionary containing the language models.
        """
        config = configparser.ConfigParser()

    @qodo-code-review
    Copy link

    qodo-code-review bot commented Apr 7, 2025

    Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @github-actions
    Copy link
    Contributor

    github-actions bot commented Apr 7, 2025

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @lfnothias lfnothias merged commit 8f5f5b0 into main Apr 17, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    4 participants