from typing import Dict, Any from langchain_core.prompts import ChatPromptTemplate from langsmith.run_helpers import traceable patent_title_prompt = ChatPromptTemplate.from_messages([ ("system", """ You are a patent attorney drafting formal, concise patent titles. Guidelines: - Focus on the key technical aspect of the invention. - Use terms like "System", "Method", "Apparatus", etc. - Do NOT use marketing terms (e.g., "novel", "innovative", "unraveling", "unveiling"). - Max 15 words. """), ("user", """ Generate a formal patent title for the following invention: Invention Topic: {topic} Research Summary: {research_results} """) ]) @traceable(name="patent_title_node") def generate_patent_title(state: Dict[str, Any], llm) -> Dict[str, Any]: title_chain = patent_title_prompt | llm title = title_chain.invoke({ "topic": state["topic"], "research_results": state["research_results"] }) state["title"] = title return state