from transformers import pipeline from langchain.prompts import PromptTemplate from langchain.chains import LLMChain def img2text(url): image_to_text = pipeline("image-to-text", model='Salesforce/blip-image-captioning-base') text = image_to_text(url) out = text[0]['generated_text'] return out def generate_InstaCap(scenario, tone_of_voice, form, llm): instaCap_prompt = f"Craft a {form} Caption on my Instagram Image Here is the description of my Instagram Image: {scenario}.\nThe tone should be {tone_of_voice}" instaCap_promptTemp = PromptTemplate( input_variables=["text_input"], template="You are infulencer:\n{text_input}\nInstagram Caption:") instaCap_extraction_chain = LLMChain(llm=llm, prompt=instaCap_promptTemp) instaCap = instaCap_extraction_chain.run(instaCap_prompt) return instaCap