Spaces:
Build error
Build error
File size: 978 Bytes
36f9b4d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
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
|