Datasourceforcryptocurrency / archive /docs /MODELS_AS_DATA_SOURCES.md
Really-amin's picture
Upload 295 files
d6d843f verified

استفاده از مدل‌های Hugging Face به عنوان منابع داده

📊 Endpoint‌های جدید

1. لیست مدل‌های موجود

GET /api/models/list

Response:

{
  "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. اطلاعات یک مدل خاص

GET /api/models/{model_key}/info

Example:

GET /api/models/crypto_sent_0/info

3. استفاده از یک مدل برای تولید داده

POST /api/models/{model_key}/predict

Body:

{
  "text": "Bitcoin is going to the moon!"
}

Response:

{
  "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. پردازش دسته‌ای با چند مدل

POST /api/models/batch/predict

Body:

{
  "texts": [
    "Bitcoin is bullish",
    "Ethereum price dropping"
  ],
  "models": ["crypto_sent_0", "financial_sent_0"]
}

5. دریافت داده‌های تولید شده توسط مدل‌ها

GET /api/models/data/generated?limit=50&model_key=crypto_sent_0&symbol=BTC

6. آمار داده‌های تولید شده

GET /api/models/data/stats

🔗 مدل‌ها به عنوان Providers

مدل‌های HF به صورت خودکار در /api/providers نمایش داده می‌شوند:

{
  "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"
}

📝 مثال استفاده

تحلیل احساسات با یک مدل خاص:

curl -X POST http://localhost:7860/api/models/crypto_sent_0/predict \
  -H "Content-Type: application/json" \
  -d '{"text": "Bitcoin is bullish today"}'

پردازش دسته‌ای:

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"]
  }'

دریافت داده‌های تولید شده:

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 در دسترس هستند!