An intelligent agentic learning application powered by LangChain, LangGraph, and web search capabilities using Groq LLM.
- π€ Agentic Workflow: Intelligent agent-based processing using LangGraph
- π Web Search Integration: Real-time web search capabilities
- π¬ Chat API: RESTful API endpoints for querying the agentic workflow
- π₯ Health Monitoring: Built-in health check endpoint
- β‘ Fast Performance: Built with FastAPI and Uvicorn
Agentic-learner/
βββ main.py # FastAPI application with chat endpoints
βββ agents/
β βββ agentic_workflow.py # Core agentic workflow using LangGraph
βββ config/
β βββ config.yaml # Configuration settings
βββ prompt_library/
β βββ socrates_p1.py # Prompt templates
βββ tools/
β βββ medium_tool.py # Medium integration tool
β βββ scraper_tool.py # Web scraping tool
βββ utils/
β βββ config_loader.py # Configuration loader
β βββ model_loader.py # LLM model loader
β βββ scraping.py # Scraping utilities
β βββ medium_tool_utils.py# Medium tool utilities
βββ requirements.txt # Python dependencies
βββ notebook.ipynb # Jupyter notebook for experimentation
- Python 3.8+
- Groq API key (set as environment variable
GROQ_API_KEY)
-
Clone and navigate to the project:
cd Agentic-learner -
Create a virtual environment:
python -m venv env source env/bin/activate # On Windows: env\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables: Create a
.envfile in the project root:GROQ_API_KEY=your_groq_api_key_here
Start the FastAPI application:
python main.pyThe API will be available at http://localhost:8000
Once the server is running, access the interactive API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
POST /api/chat
Processes user queries through the agentic workflow with web search capabilities.
Request:
{
"query": "What is quantum computing?"
}Response:
{
"query": "What is quantum computing?",
"response": "Quantum computing is...",
"message_count": 5
}GET /health
Check the service status.
Response:
{
"status": "healthy",
"service": "agentic-learner"
}Using cURL:
curl -X POST "http://localhost:8000/api/chat" \
-H "Content-Type: application/json" \
-d '{"query": "How does machine learning work?"}'Using Python:
import requests
response = requests.post(
"http://localhost:8000/api/chat",
json={"query": "Explain artificial intelligence"}
)
print(response.json())Using JavaScript/Fetch:
fetch('http://localhost:8000/api/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({query: 'What is deep learning?'})
})
.then(response => response.json())
.then(data => console.log(data));Edit config/config.yaml to customize:
- Model provider settings
- Tool configurations
- Prompt templates
- Search parameters
- FastAPI: Modern web framework for building APIs
- LangChain: Framework for developing LLM applications
- LangGraph: Agentic workflow orchestration
- Groq: High-performance LLM provider
- BeautifulSoup4: Web scraping
- Pydantic: Data validation
- Uvicorn: ASGI server
Explore the project interactively:
jupyter notebook notebook.ipynb- User sends a query via the
/api/chatendpoint - Request is processed by FastAPI
- GraphWorkflow initializes the agentic chain
- Agent performs web searches using available tools
- LLM (Groq) generates a comprehensive response
- Response is returned to the client
See requirements.txt for all dependencies. Key packages:
- fastapi
- langchain
- langgraph
- groq
- beautifulsoup4
- pydantic
GROQ_API_KEY: Your Groq API key for LLM access- Additional configuration can be set in
config/config.yaml
The API includes built-in error handling:
- Invalid requests return appropriate HTTP status codes
- Query processing errors are caught and logged
- Error messages are included in the response
- The workflow is initialized once at startup for efficiency
- Web searches are performed asynchronously where possible
- Response times depend on query complexity and web search availability
- Chat history/conversation memory
- Rate limiting and authentication
- Caching for repeated queries
- Multiple model provider support
- Custom tool integration framework
- Analytics and usage metrics
Issue: GROQ_API_KEY not found
- Solution: Ensure your API key is set in the
.envfile or environment variables
Issue: Module not found errors
- Solution: Run
pip install -r requirements.txtto install all dependencies
Issue: Port 8000 already in use
- Solution: Modify the port in
main.pyor kill the process using the port
[Add your license information here]
[Add contribution guidelines here]
For issues or questions, please open an issue on the project repository.