import openai import os import gradio as gr # Use the openai API key openai.api_key = os.environ["api"] model_engine = "text-davinci-003" # Function to generate website content based on product name and description def generate_website_content(product_name, product_description): # Use the OpenAI API to generate website content prompt = (f"Write a full in-depth website content with mulitple sections for a product called '{product_name}'. " f"The product description is: '{product_description}' " f"The content should include proper SEO and keywords.") completions = openai.Completion.create(engine=model_engine, prompt=prompt, max_tokens=2048, n=1, stop=None, temperature=0.7) # Get the generated website content website_content = completions.choices[0].text return website_content # Create the Gradio interface input_components = [ gr.inputs.Textbox(label="Brand Name"), gr.inputs.Textbox(lines=5, label="Brand Description") ] output_components = [ gr.outputs.Textbox(label="Website Content") ] gr.Interface(fn=generate_website_content, inputs=input_components, outputs=output_components, title="Website Content Generator", ).launch()