TextGen / x_thread_generation.py
abdullah10's picture
Upload 35 files
8bc7dc5
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