TextGen / article_conversion_to_x_thread.py
abdullah10's picture
Upload 35 files
8bc7dc5
raw
history blame contribute delete
726 Bytes
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
def article_to_x_thread_gen(article, llm):
article_to_x_thread_prompt = f"Transform the ensuing article into a sequence of Twitter posts, creating a coherent Twitter thread between 5 to 20 tweets\nArticle: β€œ{article}.β€œ"
article_to_x_thread_promptTemp = PromptTemplate(
input_variables=["text_input"],
template="You are a twitter copywriter\n{text_input}\n\nCoherent Twitter Thread:")
article_to_x_thread_extraction_chain = LLMChain(llm=llm, prompt=article_to_x_thread_promptTemp)
article_to_x_thread = article_to_x_thread_extraction_chain.run(article_to_x_thread_prompt)
return article_to_x_thread