Upload Web_gen.py
Browse files- Web_gen.py +31 -0
Web_gen.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
# Use the openai API key
|
5 |
+
openai.api_key = "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"
|
6 |
+
model_engine = "text-davinci-003"
|
7 |
+
|
8 |
+
# Function to generate website content based on product name and description
|
9 |
+
def generate_website_content(product_name, product_description):
|
10 |
+
# Use the OpenAI API to generate website content
|
11 |
+
prompt = (f"Write a full in-depth website content with mulitple sections for a product called '{product_name}'. "
|
12 |
+
f"The product description is: '{product_description}' "
|
13 |
+
f"The content should include proper SEO and keywords.")
|
14 |
+
completions = openai.Completion.create(engine=model_engine, prompt=prompt, max_tokens=2048, n=1, stop=None, temperature=0.7)
|
15 |
+
|
16 |
+
# Get the generated website content
|
17 |
+
website_content = completions.choices[0].text
|
18 |
+
|
19 |
+
return website_content
|
20 |
+
|
21 |
+
# Create the Gradio interface
|
22 |
+
input_components = [
|
23 |
+
gr.inputs.Textbox(label="Brand Name"),
|
24 |
+
gr.inputs.Textbox(lines=5, label="Brand Description")
|
25 |
+
]
|
26 |
+
|
27 |
+
output_components = [
|
28 |
+
gr.outputs.Textbox(label="Website Content")
|
29 |
+
]
|
30 |
+
|
31 |
+
gr.Interface(fn=generate_website_content, inputs=input_components, outputs=output_components, title="Website Content Generator", ).launch(share=True)
|