What Are People Building?
1. Customer Support Agent
python
# Handles customer questions automatically
tools = [
"check_order_status",
"process_refund",
"answer_faq",
"escalate_to_human"
]
# Handles 80% of questions without humans
2. Research Assistant
python
# Finds and summarizes information
tools = [
"web_search",
"read_papers",
"create_summary",
"generate_citations"
]
# Saves hours of research time
3. Content Creator
python
# Writes blog posts, social media, emails
tools = [
"research_topic",
"write_draft",
"generate_images",
"schedule_post"
]
# Creates content in minutes, not hours
4. Data Analyst
python
# Analyzes data and creates reports
tools = [
"query_database",
"run_python",
"create_charts",
"generate_report"
]
# Turns raw data into insights
Build a Customer Support Agent
python
from langchain_openai import ChatOpenAI
from langchain_core.tools import tool
from langgraph.prebuilt import create_react_agent
# --- Tools ---
@tool
def check_order(order_id: str) -> str:
"""Check the status of an order"""
orders = {
"ORD001": {"status": "shipped", "eta": "2 days"},
"ORD002": {"status": "processing", "eta": "5 days"},
"ORD003": {"status": "delivered", "eta": "delivered"},
}
order = orders.get(order_id)
if order:
return f"Order {order_id}: {order['status']}, ETA: {order['eta']}"
return f"Order {order_id} not found"
@tool
def process_refund(order_id: str, reason: str) -> str:
"""Process a refund for an order"""
return f"Refund of $49.99 processed for {order_id}. Reason: {reason}. Refund will appear in 3-5 business days."
@tool
def get_faq(question: str) -> str:
"""Get answer to frequently asked question"""
faqs = {
"shipping": "We offer free shipping on orders over $50. Standard shipping takes 3-5 days.",
"returns": "Returns accepted within 30 days. Items must be unused.",
"payment": "We accept all major credit cards, PayPal, and Apple Pay.",
}
for key, answer in faqs.items():
if key in question.lower():
return answer
return "Please contact [email protected] for more help."
# --- Agent ---
llm = ChatOpenAI(model="gpt-4o", temperature=0)
agent = create_react_agent(
model=llm,
tools=[check_order, process_refund, get_faq],
)
# --- Chat Loop ---
print("Customer Support Agent (type 'quit' to exit)")
print("-" * 50)
while True:
user_input = input("You: ")
if user_input.lower() == "quit":
break
result = agent.invoke({
"messages": [{"role": "user", "content": user_input}]
})
print(f"Agent: {result['messages'][-1].content}")
print()
Build a Research Assistant
python
from langchain_openai import ChatOpenAI
from langchain_core.tools import tool
from langgraph.prebuilt import create_react_agent
from duckduckgo_search import DDGS
@tool
def search_web(query: str) -> str:
"""Search the web for current information"""
with DDGS() as ddgs:
results = list(ddgs.text(query, max_results=5))
return "\n".join([f"- {r['title']}: {r['body'][:200]}" for r in results])
@tool
def summarize(text: str) -> str:
"""Create a summary of the given text"""
llm = ChatOpenAI(model="gpt-4o")
response = llm.invoke(f"Summarize this in 3 bullet points:\n{text}")
return response.content
@tool
def create_outline(topic: str) -> str:
"""Create an outline for a research topic"""
llm = ChatOpenAI(model="gpt-4o")
response = llm.invoke(f"Create a research outline for: {topic}")
return response.content
agent = create_react_agent(
model=ChatOpenAI(model="gpt-4o"),
tools=[search_web, summarize, create_outline],
)
# Research a topic
result = agent.invoke({
"messages": [{"role": "user", "content": "Research the latest trends in AI agents"}]
})
print(result["messages"][-1].content)
Related Topics
| Topic | Link |
|---|---|
| Production Apps | Building Apps |
| LLM Serving | Deployment |
| Monitoring | Observability |
| Cost Optimization | Save Money |