File size: 1,383 Bytes
1fc07a8
 
 
 
fad0d5e
 
1fc07a8
 
 
 
 
 
 
 
 
 
 
 
 
 
c3c1bed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import gradio as gr
import openai
import os

# Set your OpenAI key (use HF secrets)
client = openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY"))

def seo_audit(url):
    if not url:
        return "Please enter a valid URL."

    prompt = f"""
You are SEOlytics AI, a world-class SEO Analyst.
Audit this URL as if it's a live site: {url}

Break your analysis into these parts:
1. Basic Info (Title, Meta, OG tags)
2. Technical SEO (Speed, HTTPS, Schema, Robots.txt)
3. On-Page SEO (Headings, Keywords, Alt Tags)
4. Content Quality (Readability, Word Count, Keyword Density)
5. UX and Performance (Mobile-friendliness, CTA, Accessibility)
6. SEO Score (0–100)
7. Top 5 Priority Recommendations
"""

    try:
        response = client.chat.completions.create(
            model="gpt-4",
            messages=[
                {"role": "system", "content": "You are an expert SEO analyst."},
                {"role": "user", "content": prompt}
            ]
        )
        return response.choices[0].message.content
    except Exception as e:
        return f"Error: {str(e)}"

demo = gr.Interface(
    fn=seo_audit,
    inputs=gr.Textbox(label="Enter Website URL"),
    outputs=gr.Textbox(label="SEO Audit Report", lines=25),
    title="SEOlytics AI",
    description="AI-Powered SEO Analyzer – Just paste a URL and get insights!"
)

if __name__ == "__main__":
    demo.launch()