# تنظیمات RAG برای پایگاه دانش CropLogic

embedding:
  provider: "arvancloud"                 # gapgpt یا avalai یا arvancloud
  model: "Bge-m3-smka5"
  base_url: "https://api.gapgpt.app/v1"
  api_key_env: "GAPGPT_API_KEY"
  batch_size: 32
  # تنظیمات Avalai (برای fallback)
  avalai_base_url: "https://api.avalai.ir/v1"
  avalai_api_key_env: "AVALAI_API_KEY"
  # تنظیمات ArvanCloud AI برای BGE-M3
  arvancloud_api_key: "7c4c4eb9-5183-530a-b589-d31c79472847"
  arvancloud_base_url: "https://arvancloudai.ir/gateway/models/Bge-m3/rBA2PgcTC2sfhXwamupI4NvQ8crddUGTYXOsuKVye91PoNuGhbRgpHHNY8sMHBVQWWerZSAi4a0AijUL6YBqY9EW-Y1LhW_0ec6Mxr85GQy41lXiV6M8Od4mvLIeDF-wLRUHIervod0O5ZqGj2MOX8z1zdUpXkCrIS2uDjHlfHBZofledZjsOVDmFZU7IYfvkA__ljQqNeKXSFgpwUR7SmsbRUXGTDB2moLdeRq9zBpQIw/v1"
  arvancloud_api_key_env: "ARVANCLOUD_EMBEDDING_API_KEY"

# فاز یک: Qdrant به‌عنوان vector store
qdrant:
  host: "localhost"       # یا qdrant در Docker
  port: 6333
  collection_name: "croplogic_kb"
  vector_size: 1024       # متناسب با BGE-M3

chunking:
  max_chunk_tokens: 500
  overlap_tokens: 50

# تنظیمات مدل چت (LLM) — Avalai
llm:
  provider: "gapgpt"
  model: "gpt-4o"
  base_url: "https://api.gapgpt.app/v1"
  api_key_env: "GAPGPT_API_KEY"
  avalai_base_url: "https://api.avalai.ir/v1"
  avalai_api_key_env: "AVALAI_API_KEY"

# سه پایگاه دانش مجزا
knowledge_bases:
  chat:
    path: "config/knowledge_base/chat"
    tone_file: "config/tones/chat_tone.txt"
    description: "پایگاه دانش عمومی برای چت با کاربران"
  
  irrigation:
    path: "config/knowledge_base/irrigation"
    tone_file: "config/tones/irrigation_tone.txt"
    description: "پایگاه دانش توصیه آبیاری"
  
  fertilization:
    path: "config/knowledge_base/fertilization"
    tone_file: "config/tones/fertilization_tone.txt"
    description: "پایگاه دانش توصیه کودهی"

  irrigation_plan_parser:
    path: "config/knowledge_base/irrigation_plan_parser"
    tone_file: "config/tones/irrigation_plan_parser_tone.txt"
    description: "پایگاه دانش استخراج برنامه آبیاری از متن آزاد کاربر"

  fertilization_plan_parser:
    path: "config/knowledge_base/fertilization_plan_parser"
    tone_file: "config/tones/fertilization_plan_parser_tone.txt"
    description: "پایگاه دانش استخراج برنامه کودهی از متن آزاد کاربر"

  farm_alerts:
    path: "config/knowledge_base/farm_alerts"
    tone_file: "config/tones/farm_alerts_tone.txt"
    description: "پایگاه دانش تحلیل هشدار و اعلان مزرعه"

  pest_disease:
    path: "config/knowledge_base/pest_disease"
    tone_file: "config/tones/pest_disease_tone.txt"
    description: "پایگاه دانش تشخیص و پیش بینی آفات و بیماری گیاهی"

  soil_anomaly:
    path: "config/knowledge_base/soil_anomaly"
    tone_file: "config/tones/soil_anomaly_tone.txt"
    description: "پایگاه دانش تحلیل ناهنجاری آماری داده های خاک و سنسور"

  water_need_prediction:
    path: "config/knowledge_base/water_need_prediction"
    tone_file: "config/tones/water_need_prediction_tone.txt"
    description: "پایگاه دانش تفسير نياز آبي کوتاه مدت و برنامه ريزي آبياري"

  yield_harvest:
    path: "config/knowledge_base/chat"
    tone_file: "config/tones/yield_harvest_tone.txt"
    description: "پایگاه دانش روایت کاربرپسند برای داشبورد Yield & Harvest Summary"

services:
  support_bot:
    knowledge_base: "chat"
    tone_file: "config/tones/chat_tone.txt"
    use_user_embeddings: false
    description: "سرویس پشتیبانی عمومی"
    llm:
      provider: "gapgpt"
      model: "gpt-4o"
      base_url: "https://api.gapgpt.app/v1"
      api_key_env: "GAPGPT_API_KEY"
      avalai_base_url: "https://api.avalai.ir/v1"
      avalai_api_key_env: "AVALAI_API_KEY"
    system_prompt: "You are a friendly support assistant. Answer clearly and helpfully."

  chat:
    knowledge_base: "chat"
    tone_file: "config/tones/chat_tone.txt"
    use_user_embeddings: true
    description: "چت عمومی با داده‌های کاربر"
    llm:
      provider: "gapgpt"
      model: "gpt-4o"
      base_url: "https://api.gapgpt.app/v1"
      api_key_env: "GAPGPT_API_KEY"
      avalai_base_url: "https://api.avalai.ir/v1"
      avalai_api_key_env: "AVALAI_API_KEY"

  irrigation:
    knowledge_base: "irrigation"
    tone_file: "config/tones/irrigation_tone.txt"
    use_user_embeddings: true
    description: "سرویس توصیه آبیاری"
    llm:
      provider: "gapgpt"
      model: "gpt-4o"
      base_url: "https://api.gapgpt.app/v1"
      api_key_env: "GAPGPT_API_KEY"
      avalai_base_url: "https://api.avalai.ir/v1"
      avalai_api_key_env: "AVALAI_API_KEY"

  fertilization:
    knowledge_base: "fertilization"
    tone_file: "config/tones/fertilization_tone.txt"
    use_user_embeddings: true
    description: "سرویس توصیه کودهی"
    llm:
      provider: "gapgpt"
      model: "gpt-4o"
      base_url: "https://api.gapgpt.app/v1"
      api_key_env: "GAPGPT_API_KEY"
      avalai_base_url: "https://api.avalai.ir/v1"
      avalai_api_key_env: "AVALAI_API_KEY"

  irrigation_plan_parser:
    knowledge_base: "irrigation_plan_parser"
    tone_file: "config/tones/irrigation_plan_parser_tone.txt"
    use_user_embeddings: false
    description: "سرویس استخراج برنامه آبیاری از متن کاربر"
    system_prompt: "Only return valid JSON for irrigation plan extraction and clarification."
    llm:
      provider: "gapgpt"
      model: "gpt-4o"
      base_url: "https://api.gapgpt.app/v1"
      api_key_env: "GAPGPT_API_KEY"
      avalai_base_url: "https://api.avalai.ir/v1"
      avalai_api_key_env: "AVALAI_API_KEY"

  fertilization_plan_parser:
    knowledge_base: "fertilization_plan_parser"
    tone_file: "config/tones/fertilization_plan_parser_tone.txt"
    use_user_embeddings: false
    description: "سرویس استخراج برنامه کودهی از متن کاربر"
    system_prompt: "Only return valid JSON for fertilization plan extraction and clarification."
    llm:
      provider: "gapgpt"
      model: "gpt-4o"
      base_url: "https://api.gapgpt.app/v1"
      api_key_env: "GAPGPT_API_KEY"
      avalai_base_url: "https://api.avalai.ir/v1"
      avalai_api_key_env: "AVALAI_API_KEY"

  farm_alerts:
    knowledge_base: "farm_alerts"
    tone_file: "config/tones/farm_alerts_tone.txt"
    use_user_embeddings: true
    description: "سرویس تحلیل tracker و timeline هشدارهای مزرعه"
    llm:
      provider: "gapgpt"
      model: "gpt-4o"
      base_url: "https://api.gapgpt.app/v1"
      api_key_env: "GAPGPT_API_KEY"
      avalai_base_url: "https://api.avalai.ir/v1"
      avalai_api_key_env: "AVALAI_API_KEY"

  pest_disease:
    knowledge_base: "pest_disease"
    tone_file: "config/tones/pest_disease_tone.txt"
    use_user_embeddings: true
    description: "سرویس تشخیص و پیش بینی آفات و بیماری"
    llm:
      provider: "gapgpt"
      model: "gpt-4o"
      base_url: "https://api.gapgpt.app/v1"
      api_key_env: "GAPGPT_API_KEY"
      avalai_base_url: "https://api.avalai.ir/v1"
      avalai_api_key_env: "AVALAI_API_KEY"

  soil_anomaly:
    knowledge_base: "soil_anomaly"
    tone_file: "config/tones/soil_anomaly_tone.txt"
    use_user_embeddings: true
    description: "سرویس تفسير ناهنجاري هاي آماري خاک و سنسور"
    llm:
      provider: "gapgpt"
      model: "gpt-4o"
      base_url: "https://api.gapgpt.app/v1"
      api_key_env: "GAPGPT_API_KEY"
      avalai_base_url: "https://api.avalai.ir/v1"
      avalai_api_key_env: "AVALAI_API_KEY"

  water_need_prediction:
    knowledge_base: "water_need_prediction"
    tone_file: "config/tones/water_need_prediction_tone.txt"
    use_user_embeddings: true
    description: "سرویس تفسير نياز آبي کوتاه مدت مزرعه"
    llm:
      provider: "gapgpt"
      model: "gpt-4o"
      base_url: "https://api.gapgpt.app/v1"
      api_key_env: "GAPGPT_API_KEY"
      avalai_base_url: "https://api.avalai.ir/v1"
      avalai_api_key_env: "AVALAI_API_KEY"

  yield_harvest:
    knowledge_base: "yield_harvest"
    tone_file: "config/tones/yield_harvest_tone.txt"
    use_user_embeddings: true
    description: "سرویس روایت داشبورد عملکرد و برداشت"
    fallback_behavior:
      on_invalid_json: "raise_validation_error"
      on_missing_context: "use_only_deterministic_data"
      on_number_conflict: "prefer_deterministic_data"
    prompt_template: "config/tones/yield_harvest_tone.txt"
    llm:
      provider: "gapgpt"
      model: "gpt-4o"
      base_url: "https://api.gapgpt.app/v1"
      api_key_env: "GAPGPT_API_KEY"
      avalai_base_url: "https://api.avalai.ir/v1"
      avalai_api_key_env: "AVALAI_API_KEY"
