Spaces:
Runtime error
Runtime error
File size: 726 Bytes
8bc7dc5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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
|