feat: add ppt generation feat

This commit is contained in:
He Tao
2025-04-21 16:43:06 +08:00
parent d81eb40a80
commit 0d2f93c773
10 changed files with 256 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
# SPDX-License-Identifier: MIT
import logging
import os
import uuid
from langchain.schema import HumanMessage, SystemMessage
from src.config.agents import AGENT_LLM_MAP
from src.llms.llm import get_llm_by_type
from src.prompts.template import get_prompt_template
from .state import PPTState
logger = logging.getLogger(__name__)
def ppt_composer_node(state: PPTState):
logger.info("Generating ppt content...")
model = get_llm_by_type(AGENT_LLM_MAP["ppt_composer"])
ppt_content = model.invoke(
[
SystemMessage(content=get_prompt_template("ppt_composer")),
HumanMessage(content=state["input"]),
],
)
logger.info(f"ppt_content: {ppt_content}")
# save the ppt content in a temp file
temp_ppt_file_path = os.path.join(os.getcwd(), f"ppt_content_{uuid.uuid4()}.md")
with open(temp_ppt_file_path, "w") as f:
f.write(ppt_content.content)
return {"ppt_content": ppt_content, "ppt_file_path": temp_ppt_file_path}