update
This commit is contained in:
@@ -8,6 +8,7 @@ from core.db import SessionLocal
|
||||
from apps.ai_core.ollama_client import get_llm
|
||||
from apps.ai_core.tools import describe_for_prompt, get_tool, validate_args
|
||||
from apps.catalog.models import Category, Product
|
||||
from apps.orders.models import Order
|
||||
|
||||
|
||||
SYSTEM_PROMPT = """You are an admin assistant for an e-commerce shop.
|
||||
@@ -44,7 +45,11 @@ def _shop_state_snapshot() -> dict:
|
||||
{"id": c.id, "slug": c.slug, "name_de": (c.name or {}).get("de", "")}
|
||||
for c in db.query(Category).order_by(Category.id).all()
|
||||
]
|
||||
return {"products": products, "categories": categories}
|
||||
orders = [
|
||||
{"id": o.id, "status": o.status, "total": float(o.total)}
|
||||
for o in db.query(Order).order_by(Order.id.desc()).limit(20).all()
|
||||
]
|
||||
return {"products": products, "categories": categories, "orders": orders}
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
@@ -54,7 +59,7 @@ def build_plan(user_prompt: str) -> list[dict]:
|
||||
state = _shop_state_snapshot()
|
||||
user_msg = (
|
||||
f"TOOL CATALOG (JSON):\n{json.dumps(tools, ensure_ascii=False)}\n\n"
|
||||
f"SHOP STATE (current products & categories):\n{json.dumps(state, ensure_ascii=False)}\n\n"
|
||||
f"SHOP STATE (current products, categories, recent orders):\n{json.dumps(state, ensure_ascii=False)}\n\n"
|
||||
f"USER REQUEST:\n{user_prompt}\n\n"
|
||||
"Reply with ONLY the JSON object described in the rules."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user