|
Download SETUP.md from jdewitte/aiagent: direct link, hf CLI and curl.
- Browser
- Download file 2.39 kB
-
https://huggingface.co/spaces/jdewitte/aiagent/resolve/main/SETUP.md
- Command line
-
hf download hf://spaces/jdewitte/aiagent/SETUP.md
-
curl -L -o SETUP.md https://huggingface.co/spaces/jdewitte/aiagent/resolve/main/SETUP.md
2.39 kB
| # Lightweight LLM with MCP Integration | |
| This directory contains a lightweight LLM inference service that can connect to external MCP (Model Context Protocol) servers for enhanced capabilities. | |
| ## ποΈ Quick Setup | |
| ### Local Development | |
| ```bash | |
| # Install dependencies | |
| pip install -r requirements.txt | |
| # Run the service | |
| python app.py | |
| # Or use the start script | |
| ./start.sh | |
| ``` | |
| ### Docker Deployment | |
| ```bash | |
| # Build the image | |
| docker build -t lightweight-llm . | |
| # Run the container | |
| docker run -p 8000:8000 \ | |
| -e MCP_SERVER_URL=https://your-mcp-server.hf.space \ | |
| lightweight-llm | |
| ``` | |
| ### Hugging Face Spaces | |
| 1. Create a new Space with Docker SDK | |
| 2. Upload all files from this directory | |
| 3. Set `app_port: 8000` in README.md header | |
| 4. Configure environment variables in Space settings | |
| ## π‘ API Usage | |
| ### Basic Inference | |
| ```bash | |
| curl -X POST http://localhost:8000/ \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "inputs": "Hello, how are you?", | |
| "parameters": {"max_new_tokens": 100} | |
| }' | |
| ``` | |
| ### MCP-Enhanced Inference | |
| ```bash | |
| curl -X POST http://localhost:8000/ \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "inputs": "Tell me about product 123", | |
| "parameters": { | |
| "max_new_tokens": 200, | |
| "mcp_server_url": "https://your-mcp-server.hf.space" | |
| } | |
| }' | |
| ``` | |
| ## π§ Configuration | |
| Set these environment variables: | |
| - `MCP_SERVER_URL`: Default MCP server URL | |
| - `MODEL_NAME`: Hugging Face model name | |
| - `MAX_NEW_TOKENS`: Default max tokens | |
| - `PORT`: Service port (default: 8000) | |
| ## π§ͺ Testing | |
| Run the test suite: | |
| ```bash | |
| python test_service.py | |
| ``` | |
| ## π Production Notes | |
| - The current implementation uses a simple text generation placeholder | |
| - For production, integrate with: | |
| - Transformers library with a small model | |
| - vLLM for faster inference | |
| - TensorRT for optimized inference | |
| - Any other inference engine | |
| ## π MCP Integration | |
| This service automatically detects when to use MCP tools based on keywords in the input. It can connect to any MCP server that implements the standard protocol. | |
| **Keywords that trigger MCP usage:** | |
| - product, price, stock, inventory | |
| - order, customer, database | |
| - search, find, get, fetch, check | |
| - prestashop, shop, cart, purchase | |
| ## π Endpoints | |
| - `POST /` - Main inference endpoint (HF compatible) | |
| - `GET /health` - Health check | |
| - `GET /info` - Service information | |
| - `GET /docs` - API documentation | |