Files
deer-flow/src/prose/graph/prose_improve_node.py

32 lines
994 B
Python
Raw Normal View History

2025-04-26 23:12:13 +08:00
# 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__)
2025-04-27 10:39:02 +08:00
prompt = """
You are an AI writing assistant that improves existing text.
- Limit your response to no more than 200 characters, but make sure to construct complete sentences.
- Use Markdown formatting when appropriate.
"""
2025-04-26 23:12:13 +08:00
def prose_improve_node(state: ProseState):
logger.info("Generating prose improve content...")
model = get_llm_by_type(AGENT_LLM_MAP["prose_writer"])
prose_content = model.invoke(
[
2025-04-27 10:39:02 +08:00
SystemMessage(content=prompt),
2025-04-26 23:12:13 +08:00
HumanMessage(content=f"The existing text is: {state['content']}"),
],
)
logger.info(f"prose_content: {prose_content}")
return {"output": prose_content.content}