from fastapi import FastAPI, HTTPException, APIRouter
from pydantic import BaseModel
from app.utils.system_prompt import system_prompt, agentic_prompt

prompt_router = APIRouter()

# Define a model for the prompts
class Prompt(BaseModel):
    system_prompt: str = None
    agentic_prompt: str = None

# API endpoint to get the current prompts
@prompt_router.get("/prompts")
def get_prompts():
    return {
        "system_prompt": system_prompt,
        "agentic_prompt": agentic_prompt,
    }

# API endpoint to update the prompts
@prompt_router.put("/prompts")
def update_prompts(prompts: Prompt):
    global system_prompt, agentic_prompt
    if prompts.system_prompt is not None:
        system_prompt = prompts.system_prompt
    if prompts.agentic_prompt is not None:
        agentic_prompt = prompts.agentic_prompt
    return {
        "message": "Prompts updated successfully",
        "system_prompt": system_prompt,
        "agentic_prompt": agentic_prompt,
    }