"""Push check_is_stock + tool_routing to Langfuse."""
import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
sys.stdout.reconfigure(encoding="utf-8")
from dotenv import load_dotenv

load_dotenv(os.path.join(os.path.dirname(__file__), "..", "..", ".env"))
from langfuse import Langfuse

lf = Langfuse()
BASE = os.path.dirname(os.path.abspath(__file__))

# 1. Push check_is_stock tool prompt
stock_path = os.path.join(BASE, "..", "tool_prompts", "check_is_stock.txt")
with open(stock_path, "r", encoding="utf-8") as f:
    content = f.read()
lf.create_prompt(name="check_is_stock", prompt=content, labels=["production"], tags=["canifa", "tool-prompt"], type="text")
print(f"✅ check_is_stock updated ({len(content):,} chars)")

# 2. Push tool_routing
with open(os.path.join(BASE, "05_tool_routing.txt"), "r", encoding="utf-8") as f:
    content2 = f.read()
lf.create_prompt(name="canifa-05-tool-routing", prompt=content2, labels=["production"], tags=["canifa", "system-core"], type="text")
print(f"✅ canifa-05-tool-routing updated ({len(content2):,} chars)")

# 3. Push data_retrieval_tool prompt
drt_path = os.path.join(BASE, "..", "tool_prompts", "data_retrieval_tool.txt")
with open(drt_path, "r", encoding="utf-8") as f:
    content3 = f.read()
lf.create_prompt(name="data_retrieval_tool", prompt=content3, labels=["production"], tags=["canifa", "tool-prompt"], type="text")
print(f"✅ data_retrieval_tool updated ({len(content3):,} chars)")

lf.flush()
print("Done!")
