mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-16 19:34:44 +08:00
28 lines
782 B
Python
28 lines
782 B
Python
|
|
import logging
|
||
|
|
|
||
|
|
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 ..types import Script
|
||
|
|
from .state import PodcastState
|
||
|
|
|
||
|
|
logger = logging.getLogger(__name__)
|
||
|
|
|
||
|
|
|
||
|
|
def script_writer_node(state: PodcastState):
|
||
|
|
logger.info("Generating script for podcast...")
|
||
|
|
model = get_llm_by_type(
|
||
|
|
AGENT_LLM_MAP["podcast_script_writer"]
|
||
|
|
).with_structured_output(Script)
|
||
|
|
script = model.invoke(
|
||
|
|
[
|
||
|
|
SystemMessage(content=get_prompt_template("podcast_script_writer")),
|
||
|
|
HumanMessage(content=state["input"]),
|
||
|
|
],
|
||
|
|
)
|
||
|
|
logging.info(script)
|
||
|
|
return {"script": script, "audio_chunks": []}
|