from typing import override

from srs2std.generate.standardize_strategies.naive_all_prompt import construct_prompt
from srs2std.generate.standardize_strategies.strategy import StandardizeStrategy
from srs2std.llms import LLM, FinishReason
from srs2std.srs.template import Template


class NaiveAll(StandardizeStrategy):
    def __init__(self, llm: LLM):
        self.llm = llm

    @override
    def run(self, srs_orig: str, template: Template) -> str:
        prompt = construct_prompt(srs_orig, template)

        # request to generate
        response = self.llm.ask(prompt)
        if response.finish_reason != FinishReason.STOP or response.content is None:
            return ""

        srs_std = response.content

        # trim response
        srs_std = srs_std.strip().strip("`").removeprefix("markdown").strip()

        return srs_std
