aiagent / README.md
jdewitte's picture
fix yaml
d7d61d7
|
Raw
History Blame Contribute Delete
4.59 kB
---
title: Lightweight LLM with MCP Integration
emoji: 🧠
colorFrom: green
colorTo: blue
sdk: docker
app_port: 7860
pinned: false
license: mit
tags:
- llm
- mcp-integrated
- inference
- fastapi
- prestashop
short_description: Lightweight LLM with integrated PrestaShop MCP tools
---
# Lightweight LLM with Integrated MCP
A lightweight Large Language Model inference endpoint with **integrated** MCP (Model Context Protocol) server for enhanced PrestaShop capabilities. Everything runs in a single container for maximum efficiency and simplicity.
## πŸš€ Features
- **Lightweight Architecture**: Single container with minimal dependencies
- **Hugging Face Compatible**: Standard HF API format support
- **Integrated MCP**: Built-in PrestaShop MCP server (no external dependencies)
- **Fast Inference**: Optimized for quick response times with local MCP calls
- **PrestaShop Ready**: Direct integration with PrestaShop APIs
- **Docker Single Container**: Everything in one container for easy deployment
## πŸ“‘ API Endpoints
### Main Inference Endpoint: `POST /`
**Hugging Face compatible format**
Request:
```json
{
"inputs": "What are the features of product 123?",
"parameters": {
"max_new_tokens": 150,
"temperature": 0.7,
"prestashop_api_url": "https://your-shop.com"
}
}
```
Response:
```json
[
{
"generated_text": "Product 123 is a premium item with advanced features..."
}
]
```
### Health Check: `GET /health`
Service health and configuration status
### Model Info: `GET /info`
Model and configuration information
## πŸ”§ Configuration
### Environment Variables
- `PRESTASHOP_API_URL`: Default PrestaShop API URL
- `MODEL_NAME`: Hugging Face model to use (default: lightweight model)
- `MAX_NEW_TOKENS`: Default max tokens (default: 256)
### Integrated MCP
The LLM includes a built-in MCP server with PrestaShop tools:
- **Direct Integration**: No network overhead, fastest possible responses
- **Auto-Detection**: Automatically detects when to use PrestaShop tools
- **Fallback**: Works without PrestaShop (direct responses)
- **Single Container**: Everything runs together for simplicity
## πŸ› οΈ Usage
### Direct Inference
```bash
curl -X POST https://your-inference-endpoint.hf.space/ \
-H "Content-Type: application/json" \
-d '{
"inputs": "Hello, how are you?",
"parameters": {"max_new_tokens": 100}
}'
```
### Integrated MCP Inference
```bash
curl -X POST https://your-inference-endpoint.hf.space/ \
-H "Content-Type: application/json" \
-d '{
"inputs": "Tell me about product 123",
"parameters": {
"max_new_tokens": 200,
"prestashop_api_url": "https://your-shop.com"
}
}'
```
## πŸ—οΈ Architecture
```
HTTP Request β†’ Lightweight LLM β†’ Integrated MCP Server β†’ Enhanced Response
```
1. **Request Processing**: Analyze user input for PrestaShop tool requirements
2. **Tool Decision**: Determine if PrestaShop tools are needed
3. **MCP Integration**: Call integrated MCP server directly (no network overhead)
4. **Response Generation**: Generate final response with enriched PrestaShop data
5. **HF Format**: Return in standard Hugging Face format
## πŸš€ Deployment
### Hugging Face Spaces
1. Create new Space with Docker SDK
2. Upload all files from `inference_point/` directory
3. Set app_port to 7860 (already configured in README.md header)
4. Configure PRESTASHOP_API_URL environment variable
### Hugging Face Inference Endpoints
1. Use this Docker setup for custom inference endpoints
2. Configure scaling and instance types as needed
3. Set environment variables for PrestaShop integration
## πŸ“Š Performance
- **Startup Time**: < 30 seconds
- **Inference Speed**: 1-3 seconds for direct responses
- **MCP-Enhanced**: 2-5 seconds (local integration, no network overhead)
- **Memory Usage**: Optimized for single container deployment
- **Concurrent Requests**: Supports multiple simultaneous requests
## πŸ”— Integrated MCP Tools
This service includes built-in PrestaShop MCP tools:
- **get_product_details**: Get complete product information
- **get_product_features**: Get product specifications and features
- **get_product_images**: Get product images and media
- **search_products**: Search the product catalog
**Keywords that trigger MCP usage:**
- product, price, stock, inventory
- order, customer, database
- search, find, get, fetch, check
- prestashop, shop, cart, purchase
## πŸ“ License
MIT License - Feel free to use and modify for your projects.
---
⚑ **Lightweight & Fast**: Optimized for production inference workloads.