import gradio as gr import openai import os import requests as r from bs4 import BeautifulSoup openai.api_key = os.getenv("api_key") def run_ai(name, website, additional_info, specific_request): test = r.get(website) soup = BeautifulSoup(test.text) website_content = soup.get_text().replace('\n', '') name = name.lower() if name == 'mauldin': testing = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ {"role": "user", "content": "You are a public relations consultant that works woth companies to get articles published for them. Your current task is to draft an email about the company or product that will be used to email editors at large news publications."}, {"role": "user", "content": "I will be adding information that is relevent. Can you aggregate this information into an email to sent?"}, {"role": "user", "content": f"Additional Background information: {website_content}"}, {"role": "user", "content": f"{additional_info}"}, {"role": "user", "content": f"The action you are asking is:{specific_request}"}, {"role": "user", "content": "Draft email."} ] ) return testing['choices'][0]['message']['content'] else: return "You are not JUSTIN!!!" demo = gr.Interface( fn=run_ai, inputs=[ gr.Textbox(label="Last Name"), gr.Textbox(label="Website (So we can learn more about your company or product.)", type='text', placeholder='https://huggingface.co./'), gr.Textbox(lines=2, label="Anything specific that you want broadcasted?", placeholder='New product release that will disrupt public relations'), gr.Textbox(lines=2, label="What do you want this person to do?", placeholder='Publish article on new release') ], outputs=["text"], ) demo.launch() # demo.launch(share=True) #pip list --format=freeze > requirements.txt