File size: 4,585 Bytes
10ceccd
e02dee9
 
 
 
10ceccd
e02dee9
0443374
10ceccd
 
e02dee9
 
 
10ceccd
e02dee9
d7d61d7
10ceccd
056045e
e02dee9
056045e
e02dee9
056045e
10ceccd
 
e02dee9
 
 
 
 
 
056045e
10ceccd
056045e
e02dee9
 
056045e
 
 
 
 
 
 
e02dee9
 
056045e
 
 
 
 
 
 
 
e02dee9
056045e
 
 
 
e02dee9
 
056045e
e02dee9
 
056045e
e02dee9
056045e
e02dee9
 
 
 
056045e
e02dee9
 
 
 
 
 
056045e
e02dee9
056045e
e02dee9
 
 
 
 
 
 
 
056045e
 
e02dee9
056045e
e02dee9
10ceccd
e02dee9
 
 
 
 
 
 
056045e
 
e02dee9
056045e
10ceccd
e02dee9
056045e
 
e02dee9
 
 
 
 
056045e
e02dee9
056045e
e02dee9
 
 
0443374
 
056045e
e02dee9
 
 
0443374
056045e
10ceccd
056045e
e02dee9
 
 
 
10ceccd
056045e
e02dee9
 
 
 
 
 
 
056045e
e02dee9
 
 
 
 
056045e
10ceccd
056045e
10ceccd
056045e
10ceccd
fa31b27
e02dee9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
---
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.