File size: 1,619 Bytes
d0e0962
b5c4789
d0e0962
b5c4789
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d0e0962
 
 
 
 
 
b5c4789
d0e0962
 
 
 
 
 
b5c4789
d0e0962
 
 
 
 
 
b5c4789
d0e0962
 
 
 
 
 
 
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
49
50
51
52
import os
import requests

def query_modal_gpt(prompt):
    token_id = os.getenv("MODAL_TOKEN_ID")
    token_secret = os.getenv("MODAL_TOKEN_SECRET")

    url = "https://api.modal.com/gpt"  # Update if Modal gives you another endpoint
    headers = {
        "Authorization": f"Bearer {token_id}:{token_secret}",
        "Content-Type": "application/json"
    }

    data = {
        "model": "gpt-4",
        "messages": [
            {"role": "system", "content": "You are a GEO scoring and optimization expert."},
            {"role": "user", "content": prompt}
        ]
    }

    response = requests.post(url, headers=headers, json=data)
    return response.json()["choices"][0]["message"]["content"]

def generate_blog_titles(keyword: str) -> str:
    prompt = (
        f"Generate 3 catchy blog titles featuring '{keyword}', "
        "focused on personal branding and visibility in AI models:"
    )
    return query_modal_gpt(prompt)

def generate_jsonld_schema(keyword: str) -> str:
    prompt = (
        f"Create a JSON-LD 'Person' schema snippet for '{keyword}', "
        "including name, description, and URL."
    )
    return query_modal_gpt(prompt)

def rewrite_prompt(keyword: str) -> str:
    prompt = (
        f"Rewrite the prompt 'Tell me about {keyword}' "
        "to sound more authoritative and AI-SEO-friendly."
    )
    return query_modal_gpt(prompt)

def get_optimizations(keyword: str) -> dict:
    return {
        "blog_titles":      generate_blog_titles(keyword),
        "json_ld":          generate_jsonld_schema(keyword),
        "rewritten_prompt": rewrite_prompt(keyword)
    }