from __future__ import annotations

from app.core.agent.processes.base import AgentProcess, ProcessResult
from app.core.agent.processes.v1.workflow import V1FlowMainGraph
from app.core.agent.processes.v1.workflow.flow_main import V1FlowContext
from app.core.agent.utils.llm import AgentLlmService


class V1Process(AgentProcess):
    version = "v1"

    def __init__(self, llm: AgentLlmService, prompt_name: str = "v1_flow_main.answer") -> None:
        self._prompt_name = prompt_name
        self._workflow = V1FlowMainGraph(llm)

    async def run(self, context) -> ProcessResult:
        flow_context = V1FlowContext(
            runtime=context,
            prompt_name=self._prompt_name,
        )
        flow_context = await self._workflow.run(flow_context)
        return ProcessResult(answer=flow_context.answer)
