New code
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
import os
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
# Use the openai API key
|
| 6 |
+
openai.api_key = os.environ["api"]
|
| 7 |
+
openai.ChatCompletion.create(
|
| 8 |
+
model="gpt-3.5-turbo",
|
| 9 |
+
messages=[
|
| 10 |
+
{"role": "system", "content": "You are a website content generator that provides detailed website content with multiple sections based on the "{product_name}" and "{product_description}" with keywords of the websites"},
|
| 11 |
+
{"role": "user", "content": 'You are a website content generator that provides detailed website content with multiple sections based on the "{product_name}" and "{product_description}"'},
|
| 12 |
+
]
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
# Get the generated website content
|
| 16 |
+
website_content = completions.choices[0].text
|
| 17 |
+
|
| 18 |
+
return website_content
|
| 19 |
+
|
| 20 |
+
# Create the Gradio interface
|
| 21 |
+
input_components = [
|
| 22 |
+
gr.inputs.Textbox(label="Brand Name"),
|
| 23 |
+
gr.inputs.Textbox(lines=5, label="Brand Description")
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
output_components = [
|
| 27 |
+
gr.outputs.Textbox(label="Website Content")
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
gr.Interface(fn=generate_website_content, inputs=input_components, outputs=output_components, title="Website Content Generator", ).launch()
|