File size: 3,656 Bytes
d6d843f |
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 |
# استفاده از مدلهای Hugging Face به عنوان منابع داده
## 📊 Endpointهای جدید
### 1. لیست مدلهای موجود
```bash
GET /api/models/list
```
**Response:**
```json
{
"success": true,
"total_models": 15,
"models": [
{
"id": "crypto_sent_0",
"model_id": "ElKulako/cryptobert",
"task": "sentiment-analysis",
"category": "crypto_sentiment",
"requires_auth": true,
"endpoint": "/api/models/crypto_sent_0/predict"
}
],
"categories": {...}
}
```
### 2. اطلاعات یک مدل خاص
```bash
GET /api/models/{model_key}/info
```
**Example:**
```bash
GET /api/models/crypto_sent_0/info
```
### 3. استفاده از یک مدل برای تولید داده
```bash
POST /api/models/{model_key}/predict
```
**Body:**
```json
{
"text": "Bitcoin is going to the moon!"
}
```
**Response:**
```json
{
"success": true,
"model_key": "crypto_sent_0",
"model_id": "ElKulako/cryptobert",
"task": "sentiment-analysis",
"input": "Bitcoin is going to the moon!",
"output": {
"label": "POSITIVE",
"score": 0.95
},
"timestamp": "2025-01-XX..."
}
```
### 4. پردازش دستهای با چند مدل
```bash
POST /api/models/batch/predict
```
**Body:**
```json
{
"texts": [
"Bitcoin is bullish",
"Ethereum price dropping"
],
"models": ["crypto_sent_0", "financial_sent_0"]
}
```
### 5. دریافت دادههای تولید شده توسط مدلها
```bash
GET /api/models/data/generated?limit=50&model_key=crypto_sent_0&symbol=BTC
```
### 6. آمار دادههای تولید شده
```bash
GET /api/models/data/stats
```
## 🔗 مدلها به عنوان Providers
مدلهای HF به صورت خودکار در `/api/providers` نمایش داده میشوند:
```json
{
"provider_id": "hf_model_crypto_sent_0",
"name": "HF Model: ElKulako/cryptobert",
"category": "crypto_sentiment",
"type": "hf_model",
"status": "available",
"endpoint": "/api/models/crypto_sent_0/predict"
}
```
## 📝 مثال استفاده
### تحلیل احساسات با یک مدل خاص:
```bash
curl -X POST http://localhost:7860/api/models/crypto_sent_0/predict \
-H "Content-Type: application/json" \
-d '{"text": "Bitcoin is bullish today"}'
```
### پردازش دستهای:
```bash
curl -X POST http://localhost:7860/api/models/batch/predict \
-H "Content-Type: application/json" \
-d '{
"texts": ["BTC bullish", "ETH bearish"],
"models": ["crypto_sent_0", "financial_sent_0"]
}'
```
### دریافت دادههای تولید شده:
```bash
curl http://localhost:7860/api/models/data/generated?limit=10&symbol=BTC
```
## 🎯 مزایا
1. ✅ مدلها به عنوان منابع داده قابل دسترسی هستند
2. ✅ میتوانید از هر مدل به صورت مستقل استفاده کنید
3. ✅ دادههای تولید شده در database ذخیره میشوند
4. ✅ میتوانید آمار و تاریخچه را مشاهده کنید
5. ✅ پردازش دستهای برای کارایی بیشتر
## 📊 مدلهای موجود
- **Crypto Sentiment**: `crypto_sent_0`, `crypto_sent_1`, ...
- **Social Sentiment**: `social_sent_0`, `social_sent_1`
- **Financial Sentiment**: `financial_sent_0`, `financial_sent_1`
- **News Sentiment**: `news_sent_0`
همه این مدلها به عنوان endpoint و provider در دسترس هستند!
|