Skip to content

AI4LI-Language/write-sense-agent

Repository files navigation

WriteSense Agent

WriteSense Agent is an intelligent assistant designed to help people with disabilities create and work with documents. The agent coordinates multiple specialized sub-agents using a hierarchical architecture and responds in Vietnamese to provide accessible document creation support.

🎯 What This Does

  • Document Creation Support: Help users write reports, diaries, and various documents
  • Vietnamese Language: Always responds in Vietnamese for accessibility
  • Multi-Agent System: Orchestrator coordinates specialized agents for different tasks
  • Disability-Friendly: Simple, clear interactions with step-by-step guidance

πŸš€ Quick Start (5 Minutes)

Step 1: Clone the Project

git clone https://github.com/AI4LI-Language/write-sense-agent.git
cd write-sense-agent

Step 2: Set Up Python Environment

# Create virtual environment
python3 -m venv venv

# Activate it
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Install project in development mode
pip install -e .

Step 3: Configure API Keys

Copy the environment template and add your API keys:

cp env.template .env

Edit .env file and add your API keys:

# At minimum, you need one of these:
OPENAI_API_KEY=your_openai_api_key_here
# OR
ANTHROPIC_API_KEY=your_anthropic_api_key_here

Step 4: Test Basic Setup

python examples/basic_usage.py

You should see the agent respond in Vietnamese! πŸŽ‰


🐳 Run with Docker (Recommended)

Step 1: Start Services

docker-compose up --build -d

or

docker-compose up --build

This starts:

  • WriteSense Agent on http://localhost:8123
  • PostgreSQL database on port 5433
  • Redis cache on port 6379

Step 2: Test the API

# Check if service is running
curl http://localhost:8123/ok

# Chat with the agent
python chat_with_agent.py

Step 3: Use the API

# Create a thread
curl -X POST http://localhost:8123/threads -H "Content-Type: application/json" -d '{}'

# Send a message (replace THREAD_ID with actual ID)
curl -X POST http://localhost:8123/threads/THREAD_ID/runs \
  -H "Content-Type: application/json" \
  -d '{
    "assistant_id": "agent",
    "input": {"messages": [{"role": "user", "content": "BαΊ‘n cΓ³ thể giΓΊp gΓ¬ cho tΓ΄i?"}]}
  }'

API DOCS:

http://localhost:8123/docs

πŸ—οΈ Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Orchestrator Agent          β”‚  ← GPT-4.1 (Powerful model)
β”‚     (Coordination & Vietnamese)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       Document Retriever Agent      β”‚  ← GPT-4o-mini (Fast model)
β”‚        (Document Operations)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           MCP Server               β”‚
β”‚    (Document Retrieval Tools)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Features:

  • Separate Models: Orchestrator uses powerful model, sub-agents use fast models
  • Dynamic Delegation: Automatically chooses right agent for each task
  • Vietnamese Output: All responses in Vietnamese for accessibility
  • Disability Support: Simple, clear, step-by-step guidance

βš™οΈ Configuration

Environment Variables

# Orchestrator Model (Primary coordination)
ORCHESTRATOR_LLM_PROVIDER=openai
ORCHESTRATOR_LLM_MODEL=gpt-4o

# MCP Agents Model (Task execution)
MCP_AGENTS_LLM_PROVIDER=openai
MCP_AGENTS_LLM_MODEL=gpt-4o-mini

# API Keys
OPENAI_API_KEY=your_key_here
ANTHROPIC_API_KEY=your_key_here

Adding New MCP Servers

  1. Create MCP Server (in mcp_servers/ directory)
  2. Add to Configuration (automatically discovered)
  3. Restart System (agents are created automatically)

The system automatically:

  • Creates one agent per MCP server
  • Generates dynamic delegation guidelines
  • Updates orchestrator prompt with new capabilities

πŸ§ͺ Testing Your Setup

Test 1: Basic Response

python chat_with_agent.py
# Ask: "Xin chΓ o"
# Expect: Vietnamese greeting response

Test 2: Agent Capabilities

# Ask: "BαΊ‘n cΓ³ thể lΓ m gΓ¬?"
# Expect: Vietnamese description + delegation to document agent

Test 3: Document Tasks

# Ask: "GiΓΊp tΓ΄i viαΊΏt mα»™t bΓ‘o cΓ‘o"
# Expect: Step-by-step guidance in Vietnamese

πŸ”§ Troubleshooting

Common Issues

1. API Key Errors

# Check your .env file has the right keys
cat .env | grep API_KEY

2. Docker Not Starting

# Check Docker status
docker-compose ps

# View logs
docker logs write-sense-agent

3. Agent Not Responding in Vietnamese

# Check system prompt in logs
docker logs write-sense-agent | grep "Vietnamese"

4. No Tool Calls/Delegation

# Check MCP agent registration
docker logs write-sense-agent | grep "Registered agents"

Getting Help

  1. Check the logs: docker logs write-sense-agent
  2. Verify environment: docker-compose ps
  3. Test basic endpoints: curl http://localhost:8123/ok

πŸ“ Project Structure

write-sense-agent/
β”œβ”€β”€ src/write_sense_agent/
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ config.py           # Configuration management
β”‚   β”‚   β”œβ”€β”€ orchestrator.py     # Main orchestrator agent
β”‚   β”‚   └── mcp_agent.py        # MCP agent wrapper
β”‚   └── graph.py                # Agent graph creation
β”œβ”€β”€ mcp_servers/
β”‚   └── document_retriever.py   # Document MCP server
β”œβ”€β”€ examples/
β”‚   └── basic_usage.py          # Simple test script
β”œβ”€β”€ docker-compose.yml          # Docker services
β”œβ”€β”€ chat_with_agent.py          # Interactive chat client
β”œβ”€β”€ env.template               # Environment template
└── README.md                  # This file

πŸŽ‰ Next Steps

  1. Customize for Your Needs: Modify system prompts in config.py
  2. Add More MCP Servers: Create new servers in mcp_servers/
  3. Extend Capabilities: Add new tools to existing servers
  4. Deploy to Production: Use langgraph deploy for cloud deployment

🀝 Contributing

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/my-feature
  3. Make changes and test: python examples/basic_usage.py
  4. Commit: git commit -m "Add my feature"
  5. Push: git push origin feature/my-feature
  6. Create Pull Request

Built with LangGraph + MCP for accessible document creation πŸš€

Designed specifically to help people with disabilities create and work with documents through simple, Vietnamese language interactions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors