UPDATE
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
name: AI Service CI/CD
|
||||
|
||||
on:
|
||||
push:
|
||||
push:
|
||||
branches: [production]
|
||||
paths:
|
||||
- '**'
|
||||
|
||||
@@ -12,11 +12,6 @@ printf '%s\n' \
|
||||
'deb https://mirror-linux.runflare.com/debian/ bookworm-updates main contrib non-free non-free-firmware' \
|
||||
'deb https://mirror-linux.runflare.com/debian-security/ bookworm-security main contrib non-free non-free-firmware' \
|
||||
'' \
|
||||
'deb [trusted=yes] https://mirror2.chabokan.net/debian bookworm main contrib non-free non-free-firmware' \
|
||||
'deb [trusted=yes] https://mirror2.chabokan.net/debian-security bookworm-security main contrib non-free non-free-firmware' \
|
||||
'' \
|
||||
'deb http://mirror.iranserver.com/debian/ bookworm main contrib non-free non-free-firmware' \
|
||||
'deb-src http://mirror.iranserver.com/debian/ bookworm main contrib non-free non-free-firmware' \
|
||||
> /etc/apt/sources.list
|
||||
|
||||
# System deps for MySQL client (pkg-config required by mysqlclient to find libs)
|
||||
|
||||
@@ -32,8 +32,6 @@ services:
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: ai-redis
|
||||
ports:
|
||||
- "6380:6379"
|
||||
|
||||
qdrant:
|
||||
image: qdrant/qdrant:latest
|
||||
|
||||
+2
-3
@@ -2,9 +2,8 @@
|
||||
set -e
|
||||
if [ "${SKIP_MIGRATE}" != "1" ]; then
|
||||
echo "Running migrations..."
|
||||
# python manage.py migrate --noinput --fake-initial
|
||||
# python manage.py makemigrations --merge
|
||||
|
||||
python manage.py repair_location_tables
|
||||
python manage.py migrate --noinput
|
||||
echo "Migrations done."
|
||||
fi
|
||||
echo "Starting command: $*"
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import connection
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Rename legacy soil_data tables to location_data tables when needed"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
table_map = {
|
||||
"soil_data_soillocation": "location_data_soillocation",
|
||||
"soil_data_soildepthdata": "location_data_soildepthdata",
|
||||
}
|
||||
|
||||
existing_tables = set(connection.introspection.table_names())
|
||||
renamed: list[str] = []
|
||||
|
||||
with connection.cursor() as cursor:
|
||||
for old_name, new_name in table_map.items():
|
||||
if new_name in existing_tables:
|
||||
continue
|
||||
if old_name not in existing_tables:
|
||||
continue
|
||||
|
||||
cursor.execute(f"RENAME TABLE `{old_name}` TO `{new_name}`")
|
||||
renamed.append(f"{old_name} -> {new_name}")
|
||||
existing_tables.discard(old_name)
|
||||
existing_tables.add(new_name)
|
||||
|
||||
if renamed:
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS("Renamed legacy tables: " + ", ".join(renamed))
|
||||
)
|
||||
return
|
||||
|
||||
self.stdout.write("No legacy location_data tables needed repair.")
|
||||
@@ -0,0 +1 @@
|
||||
2026-03-27 08:38:35,473 [INFO] django.utils.autoreload: Watching for file changes with StatReloader
|
||||
+20
-4
@@ -12,6 +12,14 @@ from .config import RAGConfig, load_rag_config
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _mask_secret(value: str | None) -> str:
|
||||
if not value:
|
||||
return "<missing>"
|
||||
if len(value) <= 8:
|
||||
return "****"
|
||||
return f"{value[:4]}...{value[-4:]}"
|
||||
|
||||
def get_embedding_client(config: RAGConfig | None = None) -> OpenAI:
|
||||
"""
|
||||
ساخت کلاینت OpenAI برای Embedding بر اساس provider فعال.
|
||||
@@ -19,7 +27,7 @@ def get_embedding_client(config: RAGConfig | None = None) -> OpenAI:
|
||||
"""
|
||||
cfg = config or load_rag_config()
|
||||
emb = cfg.embedding
|
||||
logger.info(emb.provider)
|
||||
logger.info("embedding provider=%s", emb.provider)
|
||||
|
||||
if emb.provider == "avalai":
|
||||
env_var = emb.avalai_api_key_env or emb.api_key_env or "AVALAI_API_KEY"
|
||||
@@ -29,7 +37,11 @@ def get_embedding_client(config: RAGConfig | None = None) -> OpenAI:
|
||||
env_var = emb.api_key_env or "GAPGPT_API_KEY"
|
||||
api_key = os.environ.get(env_var)
|
||||
base_url = emb.base_url or "https://api.gapgpt.app/v1"
|
||||
logger.info(api_key+" "+base_url)
|
||||
logger.info(
|
||||
"embedding base_url=%s api_key=%s",
|
||||
base_url,
|
||||
_mask_secret(api_key),
|
||||
)
|
||||
|
||||
return OpenAI(api_key=api_key, base_url=base_url)
|
||||
|
||||
@@ -44,7 +56,7 @@ def get_chat_client(config: RAGConfig | None = None) -> OpenAI:
|
||||
provider = llm.provider or cfg.embedding.provider
|
||||
|
||||
|
||||
logger.info(provider)
|
||||
logger.info("chat provider=%s", provider)
|
||||
if provider == "avalai":
|
||||
env_var = llm.avalai_api_key_env or llm.api_key_env or "AVALAI_API_KEY"
|
||||
api_key = os.environ.get(env_var)
|
||||
@@ -53,6 +65,10 @@ def get_chat_client(config: RAGConfig | None = None) -> OpenAI:
|
||||
env_var = llm.api_key_env or "GAPGPT_API_KEY"
|
||||
api_key = os.environ.get(env_var)
|
||||
base_url = llm.base_url or "https://api.gapgpt.app/v1"
|
||||
logger.info(api_key,base_url)
|
||||
logger.info(
|
||||
"chat base_url=%s api_key=%s",
|
||||
base_url,
|
||||
_mask_secret(api_key),
|
||||
)
|
||||
|
||||
return OpenAI(api_key=api_key, base_url=base_url)
|
||||
|
||||
@@ -23,6 +23,7 @@ redis>=5.0,<5.1
|
||||
|
||||
# === HTTP & AI ===
|
||||
requests>=2.31,<2.32
|
||||
httpx>=0.27,<0.28
|
||||
openai>=1.0,<1.40
|
||||
|
||||
# === NumPy (pinned for Python 3.10 compatibility) ===
|
||||
|
||||
Reference in New Issue
Block a user