LangAgent


NameLangAgent JSON
Version 0.3.1 PyPI version JSON
download
home_pagehttps://github.com/knowusuboaky/LangAgent
SummaryLangAgent is a versatile multi-agent system designed to streamline complex tasks such as research, automated code generation, logical reasoning, data analysis, and dynamic reporting. Powered by advanced language models, it integrates seamlessly with external APIs, databases, and a variety of data formats, enabling developers and professionals to automate workflows, extract insights, and generate professional-grade reports effortlessly.
upload_time2024-10-04 18:32:40
maintainerNone
docs_urlNone
authorKwadwo Daddy Nyame Owusu - Boakye
requires_python>=3.8
licenseNone
keywords ai machine learning language models multi-agent systems research automation code generation data analysis reasoning reporting langchain python sql data visualization automation openai data science natural language processing deep learning document summarization web scraping apis business intelligence langchain langsmith
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LangAgent 0.3.1

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python Versions](https://img.shields.io/pypi/pyversions/langagent.svg)](https://pypi.org/project/langagent/)
[![LangAgent Version](https://img.shields.io/pypi/v/langagent.svg)](https://pypi.org/project/langagent/)
[![Build Status](https://img.shields.io/github/actions/workflow/status/knowusuboaky/LangAgent/main.yml)](https://github.com/knowusuboaky/LangAgent/actions)
[![Issues](https://img.shields.io/github/issues/knowusuboaky/LangAgent)](https://github.com/knowusuboaky/LangAgent/issues)
[![Contact](https://img.shields.io/badge/Email-Contact-blue.svg)](mailto:kwadwo.owusuboakye@outlook.com)

**LangAgent** is a versatile multi-agent system designed to automate and streamline a wide range of complex tasks, including research, code generation, logical reasoning, data analysis, and dynamic reporting. Powered by advanced language models, **LangAgent** integrates seamlessly with APIs, databases, and various data formats, making it an essential tool for developers, data analysts, and business professionals to optimize workflows and extract valuable insights.

## Key Features

- **Research Automation**: Automatically gather, analyze, and summarize information from multiple sources such as web content, databases, and documents.
- **Code Generation & Debugging**: Generate, debug, and optimize code for various programming languages, supporting complex multi-step tasks.
- **Mathematical Reasoning**: Solve logical and mathematical queries with clear step-by-step breakdowns.
- **Data Analysis & Topic Generation**: Perform data clustering, trend analysis, and generate actionable insights from structured and unstructured data.
- **Professional Reporting**: Create detailed, high-quality reports with dynamic data visualizations and clear summaries.
- **Supervisor Chain**: Manage and coordinate workflows between multiple agents for complex tasks.

## Installation

You can install the `LangAgent` package via `pip`:

```bash
pip install LangAgent==0.3.1
```

## Getting Started

To start using the **LangAgent** library, you need to import the agents from their respective teams. Below is a detailed guide explaining each agent, its arguments, and how to effectively use them in your projects.

### Research Team Agents

The **Research Team** consists of three agents: **Researcher**, **Coder**, and **Weather**. Each agent is designed to assist with gathering research, generating code, or fetching weather data.

1. **Researcher Agent**
    - The researcher agent gathers and synthesizes information based on user queries. It automates the research process by providing structured and concise insights.
    
    **Arguments**:
    - `llm`: The language model to be used (e.g., `ChatOpenAI`).
    - `messages`: A list of `HumanMessage` objects representing the research query.

    **Example**:
    ```python
    from LangAgent.research_team.agents import researcher
    from langchain_openai import ChatOpenAI
    from langchain_core.messages import HumanMessage
    import yaml

    llm = ChatOpenAI()
    
    os.environ['TAVILY_API_KEY'] = yaml.safe_load(open('credentials.yml'))['online']

    search = {
        'api_key': os.environ.get("TAVILY_API_KEY"),
        'max_results': 5,
        'search_depth': "advanced"
    }

    researcher_agent = researcher.researcher(llm=llm, tavily_search=search)

    # Invoke the agent with a query
    result = researcher_agent.invoke({"messages": [HumanMessage(content="Who is Messi?")]})
    print(result['output'])
    ```

#### `Example of Resarcher Workflow`

<img src="https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-earch.png?raw=true" width="778" height="789" alt="Optional Alt Text"> 

2. **Coder Agent**
    - The coder agent generates, debugs, and optimizes code based on user input. It handles various programming challenges, from basic functions to advanced tasks.
    
    **Arguments**:
    - `llm`: The language model you want to use.
    - `messages`: A list of `HumanMessage` objects representing the code generation task.

    **Example**:
    ```python
    from LangAgent.research_team.agents import coder
    from langchain_openai import ChatOpenAI
    from langchain_core.messages import HumanMessage

    llm = ChatOpenAI()
    coder_agent = coder(llm)

    # Ask the agent to generate code
    result = coder_agent.invoke({"messages": [HumanMessage(content="Write a Python function to calculate the factorial of a number.")]} )
    print(result['output'])
    ```

#### `Example of Coder Workflow`

<img src="https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-cod.png?raw=true" width="447" height="544" alt="Optional Alt Text"> 

3. **Weather Agent**
    - The weather agent fetches and interprets weather data for a specified location using API integrations.
    
    **Arguments**:
    - `llm`: The language model to be used.
    - `OPENWEATHERMAP_API_KEY`: Your OpenWeatherMap API key.
    - `messages`: A list of `HumanMessage` objects representing the weather query.

    **Example**:
    ```python
    from LangAgent.research_team.agents import weather
    from langchain_openai import ChatOpenAI
    from langchain_core.messages import HumanMessage

    llm = ChatOpenAI()
    weather_agent = weather(llm, OPENWEATHERMAP_API_KEY="your-api-key-here")

    # Ask for weather details
    result = weather_agent.invoke({"messages": [HumanMessage(content="What is the weather today in New York?")]})
    print(result['output'])
    ```

#### `Example of Weather Workflow`

<img src="https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-openwea.png?raw=true" width="757" height="792" alt="Optional Alt Text"> 

### Logic Team Agents

The **Logic Team** consists of two agents: **Reasoner** and **Calculator**, both designed to solve logical and mathematical problems efficiently.

1. **Reasoner Agent**
    - The reasoner agent handles logical reasoning tasks and provides clear, step-by-step explanations for complex problems.
    
    **Arguments**:
    - `llm`: The language model to be used.
    - `messages`: A list of `HumanMessage` objects describing the logic problem.

    **Example**:
    ```python
    from LangAgent.logic_team.agents import reasoner
    from langchain_openai import ChatOpenAI
    from langchain_core.messages import HumanMessage

    llm = ChatOpenAI()
    reasoner_agent = reasoner(llm)

    # Solve a logic problem
    result = reasoner_agent.invoke({"messages": [HumanMessage(content="I have a 7 in the tens place. I have an even number in the ones place. I am lower than 74. What number am I?")]})
    print(result['output'])
    ```

#### `Example of Reasoner Workflow`

<img src="https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-rea.png?raw=true" width="408" height="548" alt="Optional Alt Text"> 

2. **Calculator Agent**
    - The calculator agent solves mathematical queries and calculations based on natural language inputs.
    
    **Arguments**:
    - `llm`: The language model to be used.
    - `messages`: A list of `HumanMessage` objects containing the mathematical query.

    **Example**:
    ```python
    from LangAgent.logic_team.agents import calculator
    from langchain_openai import ChatOpenAI
    from langchain_core.messages import HumanMessage

    llm = ChatOpenAI()
    calculator_agent = calculator(llm)

    # Solve a mathematical problem
    result = calculator_agent.invoke({"messages": [HumanMessage(content="Calculate the square root of 16")]})
    print(result['output'])
    ```

#### `Example of Calculator Workflow`

<img src="https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-cal.png?raw=true" width="410" height="549" alt="Optional Alt Text"> 

### Analysis Team Agents

The **Analysis Team** consists of two agents: **Topic Generator** and **SQL Databaser**, both designed to provide insights from data, either through text clustering or SQL-based analysis.


1. **Topic Generator Agent**
    - The topic generator agent clusters and analyzes text data, producing topics and visualizations based on user data.
    
    **Arguments**:
    - `llm`: The language model to be used.
    - `path`: The path to the CSV file containing text data.
    - `text_column`: The column in the CSV that contains the text data.
    - `user_topics`: Optional, user-provided topics for clustering.

    **Example**:
    ```python
    from LangAgent.analysis_team.agents import topic_generator
    from sentence_transformers import SentenceTransformer
    from langchain_openai import ChatOpenAI

    llm = ChatOpenAI()
    topic_generator_agent = topic_generator(llm)

    inputs = {
        'path': '../Comments.csv',
        'text_column': 'Comments',
        'user_topics': None
    }

    result = topic_generator_agent.invoke(inputs)
    result['summary_df']  # View the summarized data
    result['fig'].show()  # Show the visualization
    ```

#### `Example of Topic Generator Workflow`

<img src="https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-topic.png?raw=true" width="335" height="730" alt="Optional Alt Text"> 

2. **SQL Databaser Agent**
    - The SQL databaser agent executes SQL queries and provides insights from the results, including generating charts.
    
    **Arguments**:
    - `db_path`: The path to your SQLite or SQL database.
    - `llm`: The language model.
    - `user_question`: The question that drives the SQL query and chart generation.

    **Example**:
    ```python
    from LangAgent.analysis_team.agents import sql_databaser
    from langchain_openai import ChatOpenAI
    from langchain_experimental.utilities import PythonREPL

    llm = ChatOpenAI()
    PATH_DB = "sqlite:///database/leads_scored.db"
    sql_databaser_agent = sql_databaser(db_path=PATH_DB, llm=llm)

    question = """
    What are the total sales by month-year? 
    Use suggested price as a proxy for revenue for each transaction and a quantity of 1. 
    Make a line chart of sales over time.
    """

    initial_input = {
        "user_question": question
    }

    # Invoke the agent with the input
    result = sql_databaser_agent.invoke(initial_input)
    print(result['sql_query'])  # SQL Query
    print(result['summary'])  # Summary of results

    # Execute the Python code for chart generation
    repl = PythonREPL()
    repl.run(result['chart_plotly_code'])
    ```

#### `Example of SQL Databaser Workflow`

<img src="https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-sql.png?raw=true" width="502" height="870" alt="Optional Alt Text"> 

### Reporting Team Agents

The **Reporting Team** consists of two agents: **Interpreter** and **Summarizer**, both designed to provide insights and summaries of outputs from various sources such as data, charts, or documents.

1. **Interpreter Agent**
    - The interpreter agent provides clear, insightful interpretations of various types of outputs, including visual plots, tables, and data.
    
    **Arguments**:
    - `llm`: The language model.
    - `code_output`: The result or output that needs to be interpreted.

    **Example**:
    ```python
    from LangAgent.reporting_team.agents import interpreter
    from langchain_openai import ChatOpenAI

    llm = ChatOpenAI()
    interpreter_agent = interpreter(llm)

    result = interpreter_agent.invoke({"code_output": "Bar chart showing sales data."})
    print(result['output'])
    ```

#### `Example of Interpreter Workflow`

<img src="https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-inte.png?raw=true" width="403" height="546" alt="Optional Alt Text"> 

2. **Summarizer Agent**
    - The summarizer agent summarizes documents like PDFs, PPT, DOCX, TXT files or Plain Text into concise, actionable insights.
    
    **Arguments**:
    - `llm`: The language model.
    - `input_data`: The path to the document or text file that needs to be summarized.

    **Example**:
    ```python
    from LangAgent.reporting_team.agents import summarizer
    from langchain_openai import ChatOpenAI

    llm = ChatOpenAI()
    summarizer_agent = summarizer(llm)

    inputs = {
        'input_data': '../Comments.csv'
    }

    result = summarizer_agent.invoke(inputs)
    print(result['summary'])
    ```

#### `Example of Summarizer Workflow`

<img src="https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-sum.png?raw=true" width="358" height="535" alt="Optional Alt Text"> 

### Supervisor Chain

The **Supervisor Chain** manages the workflow between multiple agents. It selects the next agent based on predefined criteria or completion conditions. This is useful when you want to automate multi-step tasks and route tasks to different agents based on the flow of the conversation or task requirements.

- The **Supervisor Chain** allows you to manage complex workflows by selecting different agents based on their capabilities or status.

**Arguments**:
- `subagent_names`: A list of subagents (workers) that will perform tasks.
- `llm`: The language model that powers decision-making.
- `subagent_descriptions`: A dictionary of subagent names with descriptions of their roles (optional).
- `completion_criteria`: A string representing the criteria that signals completion of the workflow.
- `history_depth`: The number of previous messages to consider when making routing decisions (optional).

**Example**:
```python
from LangAgent.supervisor import supervisor_chain
from langchain_openai import ChatOpenAI

llm = ChatOpenAI()

# Define the subagents and their descriptions
subagent_names = ["researcher", "coder", "calculator"]
subagent_descriptions = {
    "researcher": "Finds relevant research and gathers data.",
    "coder": "Generates, debugs, and optimizes code.",
    "calculator": "Solves mathematical problems and queries."
}

# Create a supervisor chain to manage the workflow
supervisor = supervisor_chain(
    subagent_names=subagent_names, 
    llm=llm, 
    subagent_descriptions=subagent_descriptions, 
    completion_criteria="FINISH"
)
```

#### `Example of Supervision Workflow`

<img src="https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-4.png?raw=true" width="802" height="481" alt="Optional Alt Text">

## Dependencies

LangAgent relies on several core libraries, including:
- **LangChain** for agent creation and task management.
- **Sentence Transformers** for text embedding.
- **SQLAlchemy** for database interactions.
- **Pandas** for data manipulation.
- **Plotly** and **Matplotlib** for data visualization.

Install the required dependencies using:

```bash
pip install -r requirements.txt
```

## Contributing

We welcome contributions to LangAgent! If you'd like to contribute:
1. Fork the repository.
2. Create a branch for your feature (`git checkout -b feature/new-feature`).
3. Commit your changes (`git commit -m "Add new feature"`).
4. Push your branch (`git push origin feature/new-feature`).
5. Create a Pull Request.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Contact

For any inquiries or issues, please contact:

- **Author**: Kwadwo Daddy Nyame Owusu - Boakye
- **Email**: [kwadwo.owusuboakye@outlook.com](mailto:kwadwo.owusuboakye@outlook.com)
- **GitHub**: [https://github.com/knowusuboaky/LangAgent](https://github.com/knowusuboaky/LangAgent)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/knowusuboaky/LangAgent",
    "name": "LangAgent",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "AI, machine learning, language models, multi-agent systems, research automation, code generation, data analysis, reasoning, reporting, LangChain, Python, SQL, data visualization, automation, OpenAI, data science, natural language processing, deep learning, document summarization, web scraping, APIs, business intelligence, LangChain, LangSmith",
    "author": "Kwadwo Daddy Nyame Owusu - Boakye",
    "author_email": "kwadwo.owusuboakye@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/b7/00/0d69710d2580f3d9d0c44e175110755f1dee54dfcce19f84d1907c22b3b9/LangAgent-0.3.1.tar.gz",
    "platform": null,
    "description": "# LangAgent 0.3.1\r\n\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n[![Python Versions](https://img.shields.io/pypi/pyversions/langagent.svg)](https://pypi.org/project/langagent/)\r\n[![LangAgent Version](https://img.shields.io/pypi/v/langagent.svg)](https://pypi.org/project/langagent/)\r\n[![Build Status](https://img.shields.io/github/actions/workflow/status/knowusuboaky/LangAgent/main.yml)](https://github.com/knowusuboaky/LangAgent/actions)\r\n[![Issues](https://img.shields.io/github/issues/knowusuboaky/LangAgent)](https://github.com/knowusuboaky/LangAgent/issues)\r\n[![Contact](https://img.shields.io/badge/Email-Contact-blue.svg)](mailto:kwadwo.owusuboakye@outlook.com)\r\n\r\n**LangAgent** is a versatile multi-agent system designed to automate and streamline a wide range of complex tasks, including research, code generation, logical reasoning, data analysis, and dynamic reporting. Powered by advanced language models, **LangAgent** integrates seamlessly with APIs, databases, and various data formats, making it an essential tool for developers, data analysts, and business professionals to optimize workflows and extract valuable insights.\r\n\r\n## Key Features\r\n\r\n- **Research Automation**: Automatically gather, analyze, and summarize information from multiple sources such as web content, databases, and documents.\r\n- **Code Generation & Debugging**: Generate, debug, and optimize code for various programming languages, supporting complex multi-step tasks.\r\n- **Mathematical Reasoning**: Solve logical and mathematical queries with clear step-by-step breakdowns.\r\n- **Data Analysis & Topic Generation**: Perform data clustering, trend analysis, and generate actionable insights from structured and unstructured data.\r\n- **Professional Reporting**: Create detailed, high-quality reports with dynamic data visualizations and clear summaries.\r\n- **Supervisor Chain**: Manage and coordinate workflows between multiple agents for complex tasks.\r\n\r\n## Installation\r\n\r\nYou can install the `LangAgent` package via `pip`:\r\n\r\n```bash\r\npip install LangAgent==0.3.1\r\n```\r\n\r\n## Getting Started\r\n\r\nTo start using the **LangAgent** library, you need to import the agents from their respective teams. Below is a detailed guide explaining each agent, its arguments, and how to effectively use them in your projects.\r\n\r\n### Research Team Agents\r\n\r\nThe **Research Team** consists of three agents: **Researcher**, **Coder**, and **Weather**. Each agent is designed to assist with gathering research, generating code, or fetching weather data.\r\n\r\n1. **Researcher Agent**\r\n    - The researcher agent gathers and synthesizes information based on user queries. It automates the research process by providing structured and concise insights.\r\n    \r\n    **Arguments**:\r\n    - `llm`: The language model to be used (e.g., `ChatOpenAI`).\r\n    - `messages`: A list of `HumanMessage` objects representing the research query.\r\n\r\n    **Example**:\r\n    ```python\r\n    from LangAgent.research_team.agents import researcher\r\n    from langchain_openai import ChatOpenAI\r\n    from langchain_core.messages import HumanMessage\r\n    import yaml\r\n\r\n    llm = ChatOpenAI()\r\n    \r\n    os.environ['TAVILY_API_KEY'] = yaml.safe_load(open('credentials.yml'))['online']\r\n\r\n    search = {\r\n        'api_key': os.environ.get(\"TAVILY_API_KEY\"),\r\n        'max_results': 5,\r\n        'search_depth': \"advanced\"\r\n    }\r\n\r\n    researcher_agent = researcher.researcher(llm=llm, tavily_search=search)\r\n\r\n    # Invoke the agent with a query\r\n    result = researcher_agent.invoke({\"messages\": [HumanMessage(content=\"Who is Messi?\")]})\r\n    print(result['output'])\r\n    ```\r\n\r\n#### `Example of Resarcher Workflow`\r\n\r\n<img src=\"https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-earch.png?raw=true\" width=\"778\" height=\"789\" alt=\"Optional Alt Text\"> \r\n\r\n2. **Coder Agent**\r\n    - The coder agent generates, debugs, and optimizes code based on user input. It handles various programming challenges, from basic functions to advanced tasks.\r\n    \r\n    **Arguments**:\r\n    - `llm`: The language model you want to use.\r\n    - `messages`: A list of `HumanMessage` objects representing the code generation task.\r\n\r\n    **Example**:\r\n    ```python\r\n    from LangAgent.research_team.agents import coder\r\n    from langchain_openai import ChatOpenAI\r\n    from langchain_core.messages import HumanMessage\r\n\r\n    llm = ChatOpenAI()\r\n    coder_agent = coder(llm)\r\n\r\n    # Ask the agent to generate code\r\n    result = coder_agent.invoke({\"messages\": [HumanMessage(content=\"Write a Python function to calculate the factorial of a number.\")]} )\r\n    print(result['output'])\r\n    ```\r\n\r\n#### `Example of Coder Workflow`\r\n\r\n<img src=\"https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-cod.png?raw=true\" width=\"447\" height=\"544\" alt=\"Optional Alt Text\"> \r\n\r\n3. **Weather Agent**\r\n    - The weather agent fetches and interprets weather data for a specified location using API integrations.\r\n    \r\n    **Arguments**:\r\n    - `llm`: The language model to be used.\r\n    - `OPENWEATHERMAP_API_KEY`: Your OpenWeatherMap API key.\r\n    - `messages`: A list of `HumanMessage` objects representing the weather query.\r\n\r\n    **Example**:\r\n    ```python\r\n    from LangAgent.research_team.agents import weather\r\n    from langchain_openai import ChatOpenAI\r\n    from langchain_core.messages import HumanMessage\r\n\r\n    llm = ChatOpenAI()\r\n    weather_agent = weather(llm, OPENWEATHERMAP_API_KEY=\"your-api-key-here\")\r\n\r\n    # Ask for weather details\r\n    result = weather_agent.invoke({\"messages\": [HumanMessage(content=\"What is the weather today in New York?\")]})\r\n    print(result['output'])\r\n    ```\r\n\r\n#### `Example of Weather Workflow`\r\n\r\n<img src=\"https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-openwea.png?raw=true\" width=\"757\" height=\"792\" alt=\"Optional Alt Text\"> \r\n\r\n### Logic Team Agents\r\n\r\nThe **Logic Team** consists of two agents: **Reasoner** and **Calculator**, both designed to solve logical and mathematical problems efficiently.\r\n\r\n1. **Reasoner Agent**\r\n    - The reasoner agent handles logical reasoning tasks and provides clear, step-by-step explanations for complex problems.\r\n    \r\n    **Arguments**:\r\n    - `llm`: The language model to be used.\r\n    - `messages`: A list of `HumanMessage` objects describing the logic problem.\r\n\r\n    **Example**:\r\n    ```python\r\n    from LangAgent.logic_team.agents import reasoner\r\n    from langchain_openai import ChatOpenAI\r\n    from langchain_core.messages import HumanMessage\r\n\r\n    llm = ChatOpenAI()\r\n    reasoner_agent = reasoner(llm)\r\n\r\n    # Solve a logic problem\r\n    result = reasoner_agent.invoke({\"messages\": [HumanMessage(content=\"I have a 7 in the tens place. I have an even number in the ones place. I am lower than 74. What number am I?\")]})\r\n    print(result['output'])\r\n    ```\r\n\r\n#### `Example of Reasoner Workflow`\r\n\r\n<img src=\"https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-rea.png?raw=true\" width=\"408\" height=\"548\" alt=\"Optional Alt Text\"> \r\n\r\n2. **Calculator Agent**\r\n    - The calculator agent solves mathematical queries and calculations based on natural language inputs.\r\n    \r\n    **Arguments**:\r\n    - `llm`: The language model to be used.\r\n    - `messages`: A list of `HumanMessage` objects containing the mathematical query.\r\n\r\n    **Example**:\r\n    ```python\r\n    from LangAgent.logic_team.agents import calculator\r\n    from langchain_openai import ChatOpenAI\r\n    from langchain_core.messages import HumanMessage\r\n\r\n    llm = ChatOpenAI()\r\n    calculator_agent = calculator(llm)\r\n\r\n    # Solve a mathematical problem\r\n    result = calculator_agent.invoke({\"messages\": [HumanMessage(content=\"Calculate the square root of 16\")]})\r\n    print(result['output'])\r\n    ```\r\n\r\n#### `Example of Calculator Workflow`\r\n\r\n<img src=\"https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-cal.png?raw=true\" width=\"410\" height=\"549\" alt=\"Optional Alt Text\"> \r\n\r\n### Analysis Team Agents\r\n\r\nThe **Analysis Team** consists of two agents: **Topic Generator** and **SQL Databaser**, both designed to provide insights from data, either through text clustering or SQL-based analysis.\r\n\r\n\r\n1. **Topic Generator Agent**\r\n    - The topic generator agent clusters and analyzes text data, producing topics and visualizations based on user data.\r\n    \r\n    **Arguments**:\r\n    - `llm`: The language model to be used.\r\n    - `path`: The path to the CSV file containing text data.\r\n    - `text_column`: The column in the CSV that contains the text data.\r\n    - `user_topics`: Optional, user-provided topics for clustering.\r\n\r\n    **Example**:\r\n    ```python\r\n    from LangAgent.analysis_team.agents import topic_generator\r\n    from sentence_transformers import SentenceTransformer\r\n    from langchain_openai import ChatOpenAI\r\n\r\n    llm = ChatOpenAI()\r\n    topic_generator_agent = topic_generator(llm)\r\n\r\n    inputs = {\r\n        'path': '../Comments.csv',\r\n        'text_column': 'Comments',\r\n        'user_topics': None\r\n    }\r\n\r\n    result = topic_generator_agent.invoke(inputs)\r\n    result['summary_df']  # View the summarized data\r\n    result['fig'].show()  # Show the visualization\r\n    ```\r\n\r\n#### `Example of Topic Generator Workflow`\r\n\r\n<img src=\"https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-topic.png?raw=true\" width=\"335\" height=\"730\" alt=\"Optional Alt Text\"> \r\n\r\n2. **SQL Databaser Agent**\r\n    - The SQL databaser agent executes SQL queries and provides insights from the results, including generating charts.\r\n    \r\n    **Arguments**:\r\n    - `db_path`: The path to your SQLite or SQL database.\r\n    - `llm`: The language model.\r\n    - `user_question`: The question that drives the SQL query and chart generation.\r\n\r\n    **Example**:\r\n    ```python\r\n    from LangAgent.analysis_team.agents import sql_databaser\r\n    from langchain_openai import ChatOpenAI\r\n    from langchain_experimental.utilities import PythonREPL\r\n\r\n    llm = ChatOpenAI()\r\n    PATH_DB = \"sqlite:///database/leads_scored.db\"\r\n    sql_databaser_agent = sql_databaser(db_path=PATH_DB, llm=llm)\r\n\r\n    question = \"\"\"\r\n    What are the total sales by month-year? \r\n    Use suggested price as a proxy for revenue for each transaction and a quantity of 1. \r\n    Make a line chart of sales over time.\r\n    \"\"\"\r\n\r\n    initial_input = {\r\n        \"user_question\": question\r\n    }\r\n\r\n    # Invoke the agent with the input\r\n    result = sql_databaser_agent.invoke(initial_input)\r\n    print(result['sql_query'])  # SQL Query\r\n    print(result['summary'])  # Summary of results\r\n\r\n    # Execute the Python code for chart generation\r\n    repl = PythonREPL()\r\n    repl.run(result['chart_plotly_code'])\r\n    ```\r\n\r\n#### `Example of SQL Databaser Workflow`\r\n\r\n<img src=\"https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-sql.png?raw=true\" width=\"502\" height=\"870\" alt=\"Optional Alt Text\"> \r\n\r\n### Reporting Team Agents\r\n\r\nThe **Reporting Team** consists of two agents: **Interpreter** and **Summarizer**, both designed to provide insights and summaries of outputs from various sources such as data, charts, or documents.\r\n\r\n1. **Interpreter Agent**\r\n    - The interpreter agent provides clear, insightful interpretations of various types of outputs, including visual plots, tables, and data.\r\n    \r\n    **Arguments**:\r\n    - `llm`: The language model.\r\n    - `code_output`: The result or output that needs to be interpreted.\r\n\r\n    **Example**:\r\n    ```python\r\n    from LangAgent.reporting_team.agents import interpreter\r\n    from langchain_openai import ChatOpenAI\r\n\r\n    llm = ChatOpenAI()\r\n    interpreter_agent = interpreter(llm)\r\n\r\n    result = interpreter_agent.invoke({\"code_output\": \"Bar chart showing sales data.\"})\r\n    print(result['output'])\r\n    ```\r\n\r\n#### `Example of Interpreter Workflow`\r\n\r\n<img src=\"https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-inte.png?raw=true\" width=\"403\" height=\"546\" alt=\"Optional Alt Text\"> \r\n\r\n2. **Summarizer Agent**\r\n    - The summarizer agent summarizes documents like PDFs, PPT, DOCX, TXT files or Plain Text into concise, actionable insights.\r\n    \r\n    **Arguments**:\r\n    - `llm`: The language model.\r\n    - `input_data`: The path to the document or text file that needs to be summarized.\r\n\r\n    **Example**:\r\n    ```python\r\n    from LangAgent.reporting_team.agents import summarizer\r\n    from langchain_openai import ChatOpenAI\r\n\r\n    llm = ChatOpenAI()\r\n    summarizer_agent = summarizer(llm)\r\n\r\n    inputs = {\r\n        'input_data': '../Comments.csv'\r\n    }\r\n\r\n    result = summarizer_agent.invoke(inputs)\r\n    print(result['summary'])\r\n    ```\r\n\r\n#### `Example of Summarizer Workflow`\r\n\r\n<img src=\"https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-sum.png?raw=true\" width=\"358\" height=\"535\" alt=\"Optional Alt Text\"> \r\n\r\n### Supervisor Chain\r\n\r\nThe **Supervisor Chain** manages the workflow between multiple agents. It selects the next agent based on predefined criteria or completion conditions. This is useful when you want to automate multi-step tasks and route tasks to different agents based on the flow of the conversation or task requirements.\r\n\r\n- The **Supervisor Chain** allows you to manage complex workflows by selecting different agents based on their capabilities or status.\r\n\r\n**Arguments**:\r\n- `subagent_names`: A list of subagents (workers) that will perform tasks.\r\n- `llm`: The language model that powers decision-making.\r\n- `subagent_descriptions`: A dictionary of subagent names with descriptions of their roles (optional).\r\n- `completion_criteria`: A string representing the criteria that signals completion of the workflow.\r\n- `history_depth`: The number of previous messages to consider when making routing decisions (optional).\r\n\r\n**Example**:\r\n```python\r\nfrom LangAgent.supervisor import supervisor_chain\r\nfrom langchain_openai import ChatOpenAI\r\n\r\nllm = ChatOpenAI()\r\n\r\n# Define the subagents and their descriptions\r\nsubagent_names = [\"researcher\", \"coder\", \"calculator\"]\r\nsubagent_descriptions = {\r\n    \"researcher\": \"Finds relevant research and gathers data.\",\r\n    \"coder\": \"Generates, debugs, and optimizes code.\",\r\n    \"calculator\": \"Solves mathematical problems and queries.\"\r\n}\r\n\r\n# Create a supervisor chain to manage the workflow\r\nsupervisor = supervisor_chain(\r\n    subagent_names=subagent_names, \r\n    llm=llm, \r\n    subagent_descriptions=subagent_descriptions, \r\n    completion_criteria=\"FINISH\"\r\n)\r\n```\r\n\r\n#### `Example of Supervision Workflow`\r\n\r\n<img src=\"https://github.com/knowusuboaky/LangAgent/blob/main/README_files/figure-markdown/mermaid-figure-4.png?raw=true\" width=\"802\" height=\"481\" alt=\"Optional Alt Text\">\r\n\r\n## Dependencies\r\n\r\nLangAgent relies on several core libraries, including:\r\n- **LangChain** for agent creation and task management.\r\n- **Sentence Transformers** for text embedding.\r\n- **SQLAlchemy** for database interactions.\r\n- **Pandas** for data manipulation.\r\n- **Plotly** and **Matplotlib** for data visualization.\r\n\r\nInstall the required dependencies using:\r\n\r\n```bash\r\npip install -r requirements.txt\r\n```\r\n\r\n## Contributing\r\n\r\nWe welcome contributions to LangAgent! If you'd like to contribute:\r\n1. Fork the repository.\r\n2. Create a branch for your feature (`git checkout -b feature/new-feature`).\r\n3. Commit your changes (`git commit -m \"Add new feature\"`).\r\n4. Push your branch (`git push origin feature/new-feature`).\r\n5. Create a Pull Request.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\r\n\r\n## Contact\r\n\r\nFor any inquiries or issues, please contact:\r\n\r\n- **Author**: Kwadwo Daddy Nyame Owusu - Boakye\r\n- **Email**: [kwadwo.owusuboakye@outlook.com](mailto:kwadwo.owusuboakye@outlook.com)\r\n- **GitHub**: [https://github.com/knowusuboaky/LangAgent](https://github.com/knowusuboaky/LangAgent)\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "LangAgent is a versatile multi-agent system designed to streamline complex tasks such as research, automated code generation, logical reasoning, data analysis, and dynamic reporting. Powered by advanced language models, it integrates seamlessly with external APIs, databases, and a variety of data formats, enabling developers and professionals to automate workflows, extract insights, and generate professional-grade reports effortlessly.",
    "version": "0.3.1",
    "project_urls": {
        "Homepage": "https://github.com/knowusuboaky/LangAgent"
    },
    "split_keywords": [
        "ai",
        " machine learning",
        " language models",
        " multi-agent systems",
        " research automation",
        " code generation",
        " data analysis",
        " reasoning",
        " reporting",
        " langchain",
        " python",
        " sql",
        " data visualization",
        " automation",
        " openai",
        " data science",
        " natural language processing",
        " deep learning",
        " document summarization",
        " web scraping",
        " apis",
        " business intelligence",
        " langchain",
        " langsmith"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b7000d69710d2580f3d9d0c44e175110755f1dee54dfcce19f84d1907c22b3b9",
                "md5": "614b450937ce9ecb3e4cecd2dcc70434",
                "sha256": "957986fe740a39ac432cd176eade9e39f5246793ca37a86af64a9ef73bf4df00"
            },
            "downloads": -1,
            "filename": "LangAgent-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "614b450937ce9ecb3e4cecd2dcc70434",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8311,
            "upload_time": "2024-10-04T18:32:40",
            "upload_time_iso_8601": "2024-10-04T18:32:40.504043Z",
            "url": "https://files.pythonhosted.org/packages/b7/00/0d69710d2580f3d9d0c44e175110755f1dee54dfcce19f84d1907c22b3b9/LangAgent-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-04 18:32:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "knowusuboaky",
    "github_project": "LangAgent",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "langagent"
}
        
Elapsed time: 0.53251s