File size: 2,146 Bytes
446bbff
 
 
51c5711
446bbff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d443e19
446bbff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d443e19
446bbff
 
 
 
 
 
 
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
53
import os
import httpx

async def generate_image_script(text):
    try:
        with httpx.Client(timeout=10.0) as client:
            response = client.post(
                url="https://openrouter.ai/api/v1/chat/completions",
                headers={
                    "Authorization": f"Bearer {os.getenv('OPENROUTER_API_KEY')}",
                    "Content-Type": "application/json",
                    "HTTP-Referer": "https://sreepathi-ravikumar-sample.hf.space",
                    "X-Title": "Educational AI Assistant"
                },
                json={
                    "model": "deepseek/deepseek-chat-v3-0324:free",
                    "messages": [{
                        "role": "user",
                        "content": f"""topic:\n{text} \n prompt :\n *Educational Video Image Search Prompt Generator*  
*Task:*  
- You provide a topic or paragraph (e.g., "AC generator").  
- I return *literal, search-friendly terms* for finding concrete 16:9 images (480p/720p).  

*Rules Applied:*  
1. *Concrete Objects/Scenes Only* (e.g., "rotating copper coil in magnetic field" not "electromagnetic induction").  
2. *Natural Language* (phrases you’d actually type into Google Images).  
3. *No Abstraction* (avoid "illustration," "diagram" unless critical).  
4.  *but that image easily available on internet same thing that related to that topics so that simple image that script
*Output Format:*  
- Bulletless list of 3–7 exact search terms.  

---  

### *Example Usage:*  
*Your Input:*  
"Generate image search prompts for this topic: AC generator"  

*My Output:*  
rotating copper coil in magnetic field  
AC generator industrial machine close-up  
sinusoidal alternating current waveform graph  
slip rings and carbon brushes close-up  
power plant turbine generating electricity    """
                    }],
                    "temperature": 0.7,
                    "max_tokens": 500
                }
            )
        response.raise_for_status()
        return response.json()['choices'][0]['message']['content']
    
    except Exception as e:
        return f"Error generating answer: {str(e)}"