Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	
		Chandima Prabhath
		
	commited on
		
		
					Commit 
							
							·
						
						e371810
	
1
								Parent(s):
							
							5066509
								
Increase random seed range to enhance variability in image and trivia generation across multiple modules
Browse files
    	
        FLUX.py
    CHANGED
    
    | 
         @@ -58,7 +58,7 @@ def generate_image(prompt, request_id, current_request_id, image_dir, attempt=0) 
     | 
|
| 58 | 
         
             
                model = "flux"
         
     | 
| 59 | 
         
             
                width = 1920
         
     | 
| 60 | 
         
             
                height = 1080
         
     | 
| 61 | 
         
            -
                randomSeed = random.randint(0,  
     | 
| 62 | 
         
             
                url = f"https://image.pollinations.ai/prompt/{prompt}?nologo=true&safe=false&private=true&model={model}&enhance=true&width={width}&height={height}&seed={randomSeed}"
         
     | 
| 63 | 
         
             
                print(f"Attempt {attempt + 1}: Fetching image with URL: {url}")
         
     | 
| 64 | 
         | 
| 
         | 
|
| 58 | 
         
             
                model = "flux"
         
     | 
| 59 | 
         
             
                width = 1920
         
     | 
| 60 | 
         
             
                height = 1080
         
     | 
| 61 | 
         
            +
                randomSeed = random.randint(0, 9999999)
         
     | 
| 62 | 
         
             
                url = f"https://image.pollinations.ai/prompt/{prompt}?nologo=true&safe=false&private=true&model={model}&enhance=true&width={width}&height={height}&seed={randomSeed}"
         
     | 
| 63 | 
         
             
                print(f"Attempt {attempt + 1}: Fetching image with URL: {url}")
         
     | 
| 64 | 
         | 
    	
        VoiceReply.py
    CHANGED
    
    | 
         @@ -24,7 +24,7 @@ def generate_voice_reply(prompt, model="openai-audio", voice="coral", audio_dir= 
     | 
|
| 24 | 
         
             
                print("DEBUG: Starting generate_voice_reply")
         
     | 
| 25 | 
         
             
                print(f"DEBUG: Received prompt: {prompt}")
         
     | 
| 26 | 
         
             
                os.makedirs(audio_dir, exist_ok=True)
         
     | 
| 27 | 
         
            -
                randomSeed = random.randint(0,  
     | 
| 28 | 
         
             
                # Append system prompt to the user's prompt
         
     | 
| 29 | 
         
             
                system_prompt = ("Your name is Eve, a WhatsApp bot that can generate images from Flux and help users generate images. "
         
     | 
| 30 | 
         
             
                                 "To generate an image, send a message like: /imagine prompt. Rules: Don't say that you can't send whatsapp messages or generate images. Be friendly and helpful to users. help them with prompts. You can engage in general conversation. ")
         
     | 
| 
         | 
|
| 24 | 
         
             
                print("DEBUG: Starting generate_voice_reply")
         
     | 
| 25 | 
         
             
                print(f"DEBUG: Received prompt: {prompt}")
         
     | 
| 26 | 
         
             
                os.makedirs(audio_dir, exist_ok=True)
         
     | 
| 27 | 
         
            +
                randomSeed = random.randint(0, 9999999)
         
     | 
| 28 | 
         
             
                # Append system prompt to the user's prompt
         
     | 
| 29 | 
         
             
                system_prompt = ("Your name is Eve, a WhatsApp bot that can generate images from Flux and help users generate images. "
         
     | 
| 30 | 
         
             
                                 "To generate an image, send a message like: /imagine prompt. Rules: Don't say that you can't send whatsapp messages or generate images. Be friendly and helpful to users. help them with prompts. You can engage in general conversation. ")
         
     | 
    	
        app.py
    CHANGED
    
    | 
         @@ -280,9 +280,9 @@ async def whatsapp_webhook(request: Request): 
     | 
|
| 280 | 
         | 
| 281 | 
         
             
                # TRIVIA
         
     | 
| 282 | 
         
             
                if low == "/trivia":
         
     | 
| 283 | 
         
            -
                    randomSeed = random.randint(0,  
     | 
| 284 | 
         
             
                    raw = generate_llm(
         
     | 
| 285 | 
         
            -
                    (f"Generate a trivia question and answer depening on this randowm seed {randomSeed} in JSON format like this: "
         
     | 
| 286 | 
         
             
                    "{\"question\": \"What is the capital of France?\", \"answer\": \"Paris\"}")
         
     | 
| 287 | 
         
             
                    )
         
     | 
| 288 | 
         
             
                    def extract_json(text):
         
     | 
| 
         | 
|
| 280 | 
         | 
| 281 | 
         
             
                # TRIVIA
         
     | 
| 282 | 
         
             
                if low == "/trivia":
         
     | 
| 283 | 
         
            +
                    randomSeed = random.randint(0, 9999999)
         
     | 
| 284 | 
         
             
                    raw = generate_llm(
         
     | 
| 285 | 
         
            +
                    (f"Generate a trivia question and answer depening on this randowm seed {randomSeed} to make it unique in JSON format like this: "
         
     | 
| 286 | 
         
             
                    "{\"question\": \"What is the capital of France?\", \"answer\": \"Paris\"}")
         
     | 
| 287 | 
         
             
                    )
         
     | 
| 288 | 
         
             
                    def extract_json(text):
         
     | 
    	
        polLLM.py
    CHANGED
    
    | 
         @@ -20,7 +20,7 @@ def generate_llm(prompt): 
     | 
|
| 20 | 
         
             
                encoded_prompt = urllib.parse.quote(prompt)
         
     | 
| 21 | 
         
             
                encoded_system = urllib.parse.quote(system_prompt)
         
     | 
| 22 | 
         
             
                # Build the GET request URL for Pollinations' text API
         
     | 
| 23 | 
         
            -
                randomSeed = random.randint(0,  
     | 
| 24 | 
         
             
                print(f"DEBUG: Random seed: {randomSeed}")
         
     | 
| 25 | 
         
             
                url = f"https://text.pollinations.ai/{encoded_prompt}?model=openai-large&seed={randomSeed}&private=true&system={encoded_system}"
         
     | 
| 26 | 
         | 
| 
         | 
|
| 20 | 
         
             
                encoded_prompt = urllib.parse.quote(prompt)
         
     | 
| 21 | 
         
             
                encoded_system = urllib.parse.quote(system_prompt)
         
     | 
| 22 | 
         
             
                # Build the GET request URL for Pollinations' text API
         
     | 
| 23 | 
         
            +
                randomSeed = random.randint(0, 9999999)
         
     | 
| 24 | 
         
             
                print(f"DEBUG: Random seed: {randomSeed}")
         
     | 
| 25 | 
         
             
                url = f"https://text.pollinations.ai/{encoded_prompt}?model=openai-large&seed={randomSeed}&private=true&system={encoded_system}"
         
     | 
| 26 | 
         |