Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Latest commit

 

History

History
221 lines (181 loc) · 4.95 KB

File metadata and controls

221 lines (181 loc) · 4.95 KB

Agent Bot - Quick Reference

Service Information

  • Name: Agent_Bot
  • Type: Python FastAPI Microservice
  • Port: 8091
  • API Endpoint: /api/v1/ai/chat

Quick Commands

Local Development

# Navigate to Agent_Bot directory
cd Agent_Bot

# Activate virtual environment
source venv/bin/activate  # Linux/Mac
# OR
.\venv\Scripts\activate    # Windows

# Install dependencies
pip install -r requirements.txt

# Run locally
python main.py
# OR
uvicorn main:app --reload --port 8091

Docker

# Build image
docker build -t agent-bot:latest .

# Run container
docker run -p 8091:8091 --env-file .env agent-bot:latest

# Run with docker-compose (if configured)
docker-compose up agent-bot

k3s (Kubernetes - lightweight)

# Apply configurations (from k8s-config repo) — tested on k3s
kubectl apply -f k8s/configmaps/agent-bot-configmap.yaml
kubectl apply -f k8s/services/agent-bot-deployment.yaml

# Check status
kubectl get pods -l app=agent-bot-service
kubectl get svc agent-bot-service

# View logs
kubectl logs -l app=agent-bot-service --tail=100 -f

# Scale
kubectl scale deployment agent-bot-deployment --replicas=3

# Restart
kubectl rollout restart deployment/agent-bot-deployment

# Rollback
kubectl rollout undo deployment/agent-bot-deployment

GitHub Actions

# Workflows are triggered automatically on push/PR to:
# - main
# - devOps  
# - dev

# View workflow status at:
# https://github.com/TechTorque-2025/Agent_Bot/actions

Environment Variables

Required (Sensitive)

GOOGLE_API_KEY=<your-gemini-api-key>
PINECONE_API_KEY=<your-pinecone-api-key>

Required (Non-Sensitive)

PORT=8091
BASE_SERVICE_URL=http://localhost:8080/api/v1
GEMINI_MODEL=gemini-2.5-flash
PINECONE_ENVIRONMENT=us-east-1-aws
PINECONE_INDEX_NAME=techtorque-kb

Optional (with defaults)

RAG_CHUNK_SIZE=500
RAG_CHUNK_OVERLAP=50
MAX_CONTEXT_LENGTH=2000

API Endpoints

Health Check

curl http://localhost:8091/health

Root

curl http://localhost:8091/

Chat (Main endpoint)

curl -X POST http://localhost:8091/api/v1/ai/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d '{
    "message": "Hello, how can you help me?",
    "session_id": "test-session-123"
  }'

Troubleshooting

Import errors

pip install --upgrade -r requirements.txt

Port already in use

# Find process using port 8091
lsof -i :8091
# Kill it
kill -9 <PID>

API Key errors

  • Verify .env file exists in Agent_Bot directory
  • Check API keys are valid
  • For Pinecone, ensure index is created

Docker build fails

# Clean build
docker build --no-cache -t agent-bot:latest .

# Check logs
docker logs <container-id>

K8s pod not starting

# Check pod status
kubectl describe pod <pod-name>

# Check secrets exist
kubectl get secret agent-bot-secrets
kubectl describe secret agent-bot-secrets

# Check configmap
kubectl get configmap agent-bot-config
kubectl describe configmap agent-bot-config

File Structure

Agent_Bot/
├── .github/
│   └── workflows/
│       ├── build.yaml       # Build and push Docker image
│       └── deploy.yaml      # Deploy to K8s
├── config/
│   └── settings.py          # Configuration management
├── models/
│   └── chat.py             # Pydantic models
├── routes/
│   └── chatAgent.py        # FastAPI routes
├── services/
│   ├── agent_core.py       # Main agent logic
│   ├── agent_tools.py      # LangChain tools
│   ├── microservice_client.py  # Service integration
│   ├── rag.py              # RAG implementation
│   ├── vector.py           # Pinecone integration
│   └── embedding.py        # Embedding service
├── Dockerfile              # Container definition
├── requirements.txt        # Python dependencies
├── main.py                 # Application entry point
└── README.md              # Service documentation

Links

Common Issues

Issue Solution
ModuleNotFoundError Run pip install -r requirements.txt
API key invalid Check .env or K8s secrets
Can't reach microservices Verify API Gateway is running
Pinecone errors Ensure index exists and API key is valid
Memory errors Increase K8s resource limits
Slow responses Check Gemini API rate limits

Dependencies

  • FastAPI
  • LangChain
  • Google Gemini API
  • Pinecone
  • sentence-transformers
  • httpx

Notes

  • Unlike Java services, this is Python-based
  • Uses uvicorn instead of Spring Boot
  • Requires external AI services (Gemini, Pinecone)
  • No database required (stateless)
  • Communicates with other services via API Gateway