import LLM from "./llm";
import type { AppState } from "../contexts/state";

namespace Prompt {
    export function compilePrompt(state: AppState, newMessage?: LLM.ChatMessage): LLM.ChatCompletionRequest | null {
        const { currentStory, model } = state;

        if (!currentStory || !model) {
            return null;
        }

        const messages: LLM.ChatMessage[] = [
            // TODO system prompt
            // TODO part of story
            ...currentStory.chatMessages,
        ];

        if (newMessage) {
            messages.push(newMessage);
        }

        return {
            model,
            messages,
            // TODO banned_tokens
        };
    }
}

export default Prompt;
