Spaces:
Running
Running
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
@@ -1,10 +1,85 @@
|
|
1 |
-
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
-
sdk: docker
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: LLM AI Agent API
|
3 |
+
emoji: π€
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: purple
|
6 |
+
sdk: docker
|
7 |
+
app_port: 7860
|
8 |
+
pinned: false
|
9 |
+
license: mit
|
10 |
+
---
|
11 |
+
|
12 |
+
# LLM AI Agent API
|
13 |
+
|
14 |
+
A secure, production-ready AI agent API powered by local LLM deployment on Hugging Face Spaces.
|
15 |
+
|
16 |
+
## π Quick Start
|
17 |
+
|
18 |
+
1. **Set Environment Variables** in your Space settings:
|
19 |
+
- `API_KEY_1`: Your secure API key
|
20 |
+
- `API_KEY_2`: Additional API key (optional)
|
21 |
+
- `MODEL_NAME`: LLM model to use (default: microsoft/DialoGPT-medium)
|
22 |
+
|
23 |
+
2. **Access your API** at: `https://your-username-your-space.hf.space`
|
24 |
+
|
25 |
+
3. **Test the API**:
|
26 |
+
```bash
|
27 |
+
curl -X POST "https://your-space-url.hf.space/chat" \
|
28 |
+
-H "Authorization: Bearer your-api-key" \
|
29 |
+
-H "Content-Type: application/json" \
|
30 |
+
-d '{"message": "Hello, how are you?"}'
|
31 |
+
```
|
32 |
+
|
33 |
+
## π Documentation
|
34 |
+
|
35 |
+
- **API Docs**: `/docs` (Interactive Swagger UI)
|
36 |
+
- **Health Check**: `/health`
|
37 |
+
- **Model Info**: `/models` (requires authentication)
|
38 |
+
|
39 |
+
## π Security Features
|
40 |
+
|
41 |
+
- API key authentication
|
42 |
+
- Rate limiting (10 requests/minute per key)
|
43 |
+
- CORS support
|
44 |
+
- Request logging
|
45 |
+
|
46 |
+
## π οΈ Integration
|
47 |
+
|
48 |
+
See `client_examples.py` and `client_examples.js` for integration examples in Python and JavaScript.
|
49 |
+
|
50 |
+
## π API Reference
|
51 |
+
|
52 |
+
### POST /chat
|
53 |
+
```json
|
54 |
+
{
|
55 |
+
"message": "Your input message",
|
56 |
+
"max_length": 200,
|
57 |
+
"temperature": 0.7,
|
58 |
+
"system_prompt": "Optional system prompt"
|
59 |
+
}
|
60 |
+
```
|
61 |
+
|
62 |
+
Response:
|
63 |
+
```json
|
64 |
+
{
|
65 |
+
"response": "AI response",
|
66 |
+
"model_used": "microsoft/DialoGPT-medium",
|
67 |
+
"timestamp": "2024-01-01T12:00:00",
|
68 |
+
"tokens_used": 45,
|
69 |
+
"processing_time": 1.23
|
70 |
+
}
|
71 |
+
```
|
72 |
+
|
73 |
+
## π§ Configuration
|
74 |
+
|
75 |
+
Set these environment variables in your Space:
|
76 |
+
|
77 |
+
- `API_KEY_1`, `API_KEY_2`: Authentication keys
|
78 |
+
- `MODEL_NAME`: Hugging Face model ID
|
79 |
+
- `MAX_LENGTH`: Maximum response length
|
80 |
+
- `TEMPERATURE`: Response creativity (0.1-2.0)
|
81 |
+
- `RATE_LIMIT`: Requests per minute per key
|
82 |
+
|
83 |
+
## π License
|
84 |
+
|
85 |
+
MIT License - see LICENSE file for details.
|