Spaces:
Runtime error
Runtime error
File size: 1,209 Bytes
8bc7dc5 |
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 |
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
def X_thread_gen(topic, num_tweets, tone_of_voice, llm):
X_thread_prompt = f"Write a an engagging Twitter Thread on '{topic}' consists of {num_tweets} tweets. Tone should be {tone_of_voice}"
X_thread_promptTemp = PromptTemplate(
input_variables=["text_input"],
template="You are a Twitter Content Creator:\n{text_input}\n\nTwitter Thread:")
X_thread_extraction_chain = LLMChain(llm=llm, prompt=X_thread_promptTemp)
X_thread = X_thread_extraction_chain.run(X_thread_prompt)
return X_thread
def X_thread_gen_intro(topic, thread, tone_of_voice, llm):
X_thread_prompt = f"Write a an engagging and attractive Introduction head tweet for my twitter thread on {topic}. here is my twitter thread:\n{thread}\nTone should be {tone_of_voice}"
X_thread_promptTemp = PromptTemplate(
input_variables=["text_input"],
template="You are a Twitter Content Creator:\n{text_input}\n\nTweet:")
X_thread_extraction_chain = LLMChain(llm=llm, prompt=X_thread_promptTemp)
X_thread = X_thread_extraction_chain.run(X_thread_prompt)
return X_thread |