Files
deer-flow/src/prose/graph/prose_shorter_node.py
2025-04-28 10:29:35 +08:00

31 lines
906 B
Python

# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
# SPDX-License-Identifier: MIT
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.prose.graph.state import ProseState
logger = logging.getLogger(__name__)
def prose_shorter_node(state: ProseState):
logger.info("Generating prose shorter content...")
model = get_llm_by_type(AGENT_LLM_MAP["prose_writer"])
prose_content = model.invoke(
[
SystemMessage(
content="""
You are an AI writing assistant that shortens existing text.
- Use Markdown formatting when appropriate.
"""
),
HumanMessage(content=f"The existing text is: {state['content']}"),
],
)
logger.info(f"prose_content: {prose_content}")
return {"output": prose_content.content}