A collection of universal tools based on LangChain for various tasks.
- Send emails with various formats (plain text, HTML)
- Support attachments
- Read and summarize emails
- Multiple email service providers support (QQ, 163, Aliyun)
- Generate mind maps from any topic automatically
- Support multiple mind map formats (FreeMind, OPML, XMind, MindManager)
- Intelligent content analysis and organization
- Easy to use with simple API
- Generate professional presentations automatically
- High-quality images generated by DALL-E 3
- Real-time market data integration
- Professional content organization
- Support custom pages and themes
git clone https://github.com/HansonJames/langchain_universal_tools.git
cd langchain_universal_tools
pip install -r requirements.txt
Create a .env
file with the following content:
# OpenAI and SerpAPI settings
OPENAI_API_KEY=your_openai_api_key
SERPAPI_API_KEY=your_serpapi_api_key
# Email service settings
EMAIL_USE=QQ # QQ, 163, or ALIYUN
EMAIL_CONFIGS={
"QQ": {
"smtp_host": "smtp.qq.com",
"smtp_port": 465,
"imap_host": "imap.qq.com",
"username": "your_qq_email",
"password": "your_email_password"
}
}
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_openai_functions_agent
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
from universal_email_tool import UniversalEmailTool, UniversalEmailToolReading
# Initialize tools
tools = [UniversalEmailTool(), UniversalEmailToolReading()]
# Initialize the language model
llm = ChatOpenAI(
temperature=0,
model_name="gpt-4o"
)
# Create the agent
agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# Send email
result = agent_executor.invoke({
"input": "Send an email to example@qq.com with subject 'Test' and content 'Hello'"
})
# Read emails
result = agent_executor.invoke({
"input": "Read and summarize my recent 3 emails"
})
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_openai_functions_agent
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
from xmind_tool import UniversalMindMapTool, UniversalMindMapToolReading
# Initialize tools
tools = [UniversalMindMapTool(), UniversalMindMapToolReading()]
# Initialize the language model
llm = ChatOpenAI(
temperature=0,
model_name="gpt-4o"
)
# Create the agent
agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# Generate mind map
topic = "Programming Languages Comparison"
result = agent_executor.invoke({
"input": f"Please generate a mind map about '{topic}'."
})
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_openai_functions_agent
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain.tools import StructuredTool
from universal_ppt_tool import PPTGenerator
# Initialize tools
ppt_generator = PPTGenerator()
tools = [
StructuredTool.from_function(
func=ppt_generator.generate_with_logging,
name="generate_ppt",
description="Generate PPT tool",
)
]
# Initialize the language model
llm = ChatOpenAI(
model_name="gpt-4o",
temperature=0
)
# Create the agent
agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# Generate PPT
topic = "2025 Business Opportunities"
result = agent_executor.invoke({
"input": f"""Please generate a {topic} PPT with 3 pages. Requirements:
1. Comprehensive and forward-looking content
2. Include latest market data and trends
3. Focus on future business directions
4. Professional and beautiful images
"""
})
- Plain text emails
- HTML formatted emails
- Support for attachments
- Email reading and summarization
- FreeMind (.mm)
- OPML (.opml)
- XMind (.xmind)
All mind map files are saved in the output/mindmap
directory.
- PowerPoint (.pptx)
- Professional layouts
- DALL-E generated images
- Data-driven content
All PPT files are saved in the output/ppt
directory.
- Python 3.8+
- OpenAI API key
- SerpAPI key (for mind map generation)
- Email service account
- Required Python packages (see requirements.txt)
Apache License
Contributions are welcome! Please feel free to submit a Pull Request.