Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,8 +2,8 @@ import gradio as gr
|
|
| 2 |
import openai
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
# Set your OpenAI key (use HF
|
| 6 |
-
openai.api_key
|
| 7 |
|
| 8 |
def seo_audit(url):
|
| 9 |
if not url:
|
|
@@ -18,31 +18,4 @@ Break your analysis into these parts:
|
|
| 18 |
2. Technical SEO (Speed, HTTPS, Schema, Robots.txt)
|
| 19 |
3. On-Page SEO (Headings, Keywords, Alt Tags)
|
| 20 |
4. Content Quality (Readability, Word Count, Keyword Density)
|
| 21 |
-
5. UX and Performance (Mobile-friendliness, CTA, Accessibility
|
| 22 |
-
6. SEO Score (0–100)
|
| 23 |
-
7. Top 5 Priority Recommendations
|
| 24 |
-
"""
|
| 25 |
-
|
| 26 |
-
try:
|
| 27 |
-
response = openai.ChatCompletion.create(
|
| 28 |
-
model="gpt-4",
|
| 29 |
-
messages=[
|
| 30 |
-
{"role": "system", "content": "You are an expert SEO analyst."},
|
| 31 |
-
{"role": "user", "content": prompt}
|
| 32 |
-
]
|
| 33 |
-
)
|
| 34 |
-
return response['choices'][0]['message']['content']
|
| 35 |
-
except Exception as e:
|
| 36 |
-
return f"Error: {str(e)}"
|
| 37 |
-
|
| 38 |
-
# Gradio UI
|
| 39 |
-
demo = gr.Interface(
|
| 40 |
-
fn=seo_audit,
|
| 41 |
-
inputs=gr.Textbox(label="Enter Website URL"),
|
| 42 |
-
outputs=gr.Textbox(label="SEO Audit Report", lines=25),
|
| 43 |
-
title="SEOlytics AI",
|
| 44 |
-
description="AI-Powered SEO Analyzer – Just paste a URL and get insights!"
|
| 45 |
-
)
|
| 46 |
-
|
| 47 |
-
if __name__ == "__main__":
|
| 48 |
-
demo.launch()
|
|
|
|
| 2 |
import openai
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
# Set your OpenAI key (use HF secrets)
|
| 6 |
+
client = openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
| 7 |
|
| 8 |
def seo_audit(url):
|
| 9 |
if not url:
|
|
|
|
| 18 |
2. Technical SEO (Speed, HTTPS, Schema, Robots.txt)
|
| 19 |
3. On-Page SEO (Headings, Keywords, Alt Tags)
|
| 20 |
4. Content Quality (Readability, Word Count, Keyword Density)
|
| 21 |
+
5. UX and Performance (Mobile-friendliness, CTA, Accessibility
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|