from langchain.prompts import ChatPromptTemplate from langchain_core.output_parsers import StrOutputParser def post_from_content(model , content): template=""" As a professional LinkedIn post creator tool, your task is to craft a compelling post based on the content provided. Adhere to the following guidelines: 1. Post length should not exceed 3000 characters. 2. Select a fitting title, employ professional formatting, incorporate stickers, emojis, relevant hashtags, links (if applicable in the content), and references. 3. Additionally, if the content includes code snippets, ensure to present them appropriately within the post. Execute these steps thoughtfully to create an engaging and polished LinkedIn post. Content: {content}\n\n Output should only be generated LinkedIn post so that I can quickly copy it and put on my LinkedIn page without doing any modifications. """ prompt = ChatPromptTemplate.from_template(template) chain = prompt | model | StrOutputParser() generated_post=chain.invoke({"content":content}) return generated_post