diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 05ae64a..6be5536 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -48,6 +48,7 @@ jobs: CONSUMER_SECRET: ${{ secrets.CONSUMER_SECRET }} ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} ACCESS_TOKEN_SECRET: ${{ secrets.ACCESS_TOKEN_SECRET }} + GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} # Bot configuration BASE_URL: ${{ secrets.BASE_URL }} diff --git a/requirements.txt b/requirements.txt index 79e3151..a4318e9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ aiohappyeyeballs==2.6.1 aiohttp==3.12.15 aiosignal==1.4.0 annotated-types==0.6.0 -anyio==4.3.0 +anyio==4.11.0 appdirs==1.4.4 async-lru==2.0.4 attrs==23.2.0 @@ -12,23 +12,33 @@ black==25.1.0 boolean.py==5.0 bs4==0.0.2 CacheControl==0.14.3 +cachetools==6.2.2 certifi==2025.8.3 charset-normalizer==3.3.2 click==8.2.1 colorama==0.4.6 cssselect==1.2.0 cyclonedx-python-lib==9.1.0 +decorator==5.2.1 defusedxml==0.7.1 distro==1.9.0 +docx==0.2.4 fake-useragent==1.5.1 filelock==3.18.0 flake8==7.3.0 frozenlist==1.4.1 +google-auth==2.43.0 +google-genai==1.50.1 +greenlet==3.2.3 +groq==0.33.0 h11==0.14.0 httpcore==1.0.3 -httpx==0.26.0 +httpx==0.28.1 idna==3.10 +imageio==2.37.0 +imageio-ffmpeg==0.6.0 importlib_metadata==7.1.0 +jiter==0.11.1 license-expression==30.4.4 lxml==5.2.1 lxml_html_clean==0.4.2 @@ -36,45 +46,59 @@ markdown-it-py==3.0.0 mccabe==0.7.0 mdurl==0.1.2 meta_ai_api==1.1.7 +moviepy==2.2.1 msgpack==1.1.1 multidict==6.0.5 mypy_extensions==1.1.0 +numpy==2.3.2 oauthlib==3.2.2 -openai==0.28.0 +openai==2.6.1 packageurl-python==0.17.3 packaging==25.0 parse==1.20.1 pathspec==0.12.1 +pillow==11.3.0 pip-api==0.0.34 pip-requirements-parser==32.0.1 pip_audit==2.9.0 platformdirs==4.3.8 +playwright==1.54.0 +proglog==0.1.12 propcache==0.3.2 py-serializable==2.1.0 +pyasn1==0.6.1 +pyasn1_modules==0.4.2 pycodestyle==2.14.0 -pydantic==2.6.1 -pydantic_core==2.16.2 -pyee==11.1.0 +pydantic==2.12.4 +pydantic_core==2.41.5 +pyee==13.0.0 pyflakes==3.4.0 Pygments==2.19.2 pyparsing==3.2.3 pyppeteer==2.0.0 pyquery==2.0.0 python-decouple==3.8 +python-docx==1.2.0 +python-dotenv==1.1.1 +reportlab==4.4.4 requests==2.32.4 requests-html==0.10.0 requests-oauthlib==1.3.1 rich==14.1.0 +rsa==4.9.1 ruff==0.12.7 sniffio==1.3.0 sortedcontainers==2.4.0 soupsieve==2.5 +tenacity==9.1.2 +TikTokApi==7.1.0 toml==0.10.2 tqdm==4.67.1 tweepy==4.14.0 -typing_extensions==4.9.0 +typing-inspection==0.4.2 +typing_extensions==4.15.0 urllib3==1.26.20 w3lib==2.1.2 -websockets==10.4 +websockets==15.0.1 yarl==1.20.1 zipp==3.18.1 diff --git a/src/bibleAI.py b/src/bibleAI.py index adabba8..a118305 100644 --- a/src/bibleAI.py +++ b/src/bibleAI.py @@ -1,8 +1,11 @@ -from meta_ai_api import MetaAI +from google import genai +import os import time +from decouple import config from utills import fallback_response, logger_setup, check_quotes -ai = MetaAI() +api_key = config("GEMINI_API_KEY") or os.getenv("GEMINI_API_KEY") +client = genai.Client(api_key=api_key) logger = logger_setup() @@ -15,9 +18,11 @@ def get_ai_response(prompt, max_retries=3, retry_delay=1): """Get AI response with retry logic""" for attempt in range(max_retries): try: - response = ai.prompt(message=prompt) - if response and "message" in response: - return response + response = client.models.generate_content( + model="gemini-2.0-flash-001", contents=prompt # "gemini-2.5-pro", + ) + if response.text: + return response.text logger.error(f"Invalid response format, attempt {attempt + 1}") except Exception as e: logger.error(f"API error on attempt {attempt + 1}: {e}") @@ -33,12 +38,12 @@ def bible_verse(verse): """Generate bible verse explanation and prayer with optimizations""" # Primary prompts - more spiritual and engaging - explanation_prompt = f"""Write a powerful, heart-touching explanation of "{verse}" that makes people feel God's love personally. Connect it to real-life struggles, speak with warmth and hope, make it deeply encouraging and relatable. Use simple but profound language that touches both heart and soul. Keep it under 270 characters and make people want to share it. with some nice hashtags.""" - prayer_prompt = f"""faith filled, spirit filled prayer based on "{verse}" that people can declare over their lives with confidence. Make it specific, personal, and powerful - like speaking directly to God as a loving Father. Include breakthrough, blessing, and transformation. Write it as a declaration of faith under 270 characters that builds expectation for God's goodness.""" + explanation_prompt = f"""Write a powerful, heart-touching explanation of "{verse}" that makes people feel God's love personally. Connect it to real-life struggles, speak with warmth and hope, make it deeply encouraging and relatable. Use simple but profound language that touches both heart and soul. Keep it under 270 characters and make people want to share it. with some nice hashtags.eliminate any markdown formatting ,and use only plain text.""" + prayer_prompt = f"""faith filled, spirit filled prayer based on "{verse}" that people can declare over their lives with confidence. Make it specific, personal, and powerful - like speaking directly to God as a loving Father. Include breakthrough, blessing, and transformation. Write it as a declaration of faith under 270 characters that builds expectation for God's goodness.eliminate any markdown formatting , and use only plain text.""" # Backup shorter prompts - short_explanation = f"""Explain "{verse}" in a way that makes people feel God's personal love and care for them. Make it encouraging, hopeful, and relatable to daily life. Use warm, simple language that touches the heart. Under 260 characters. with some nice hashtags.""" - short_prayer = f"""Write a powerful prayer from "{verse}" that people can pray with bold faith. Make it personal, specific, and full of expectation for God's goodness. Under 260 characters.""" + short_explanation = f"""Explain "{verse}" in a way that makes people feel God's personal love and care for them. Make it encouraging, hopeful, and relatable to daily life. Use warm, simple language that touches the heart. Under 260 characters. with some nice hashtags.eliminate any markdown formatting, and use only plain text.""" + short_prayer = f"""Write a powerful prayer from "{verse}" that people can pray with bold faith. Make it personal, specific, and full of expectation for God's goodness. Under 260 characters.eliminate any markdown formatting, and use only plain text.""" # Get initial responses explanation = get_ai_response(explanation_prompt) @@ -48,20 +53,20 @@ def bible_verse(verse): logger.warning("Failed to get AI response, returning fallback") return fall_back["Explanation"], fall_back["Prayer"] - exp_text = check_quotes(explanation.get("message", "")) - prayer_text = check_quotes(prayer_point.get("message", "")) + exp_text = check_quotes(explanation) + prayer_text = check_quotes(prayer_point) # Check if content is too long and retry with shorter prompts if len(exp_text) > 280 or len(prayer_text) > 280: if len(exp_text) > 280: explanation = get_ai_response(short_explanation) if explanation: - exp_text = check_quotes(explanation.get("message", "")) + exp_text = check_quotes(explanation) if len(prayer_text) > 272: prayer_point = get_ai_response(short_prayer) if prayer_point: - prayer_text = check_quotes(prayer_point.get("message", "")) + prayer_text = check_quotes(prayer_point) # Final length check if len(exp_text) > 280: @@ -71,13 +76,14 @@ def bible_verse(verse): return exp_text, prayer_text -if __name__ == "__main__": - verse = "For God so loved the world that whoever believes in him will not perish but have everlasting life. - John 3:16 - NIV" - explanation, prayer = bible_verse(verse) - print("Explanation1:", explanation) - print("Prayer1:", prayer) +# use for testing reasons +# if __name__ == "__main__": +# verse = "For God so loved the world that whoever believes in him will not perish but have everlasting life. - John 3:16 - NIV" +# explanation, prayer = bible_verse(verse) +# print("Explanation1:", explanation) +# print("Prayer1:", prayer) - verse = "For God so loved the world that whoever believes in him will not perish but have everlasting life. - John 3:16 - NIV" - explanation, prayer = bible_verse(verse) - print("Explanation2:", explanation) - print("Prayer2:", prayer) +# verse = "For God so loved the world that whoever believes in him will not perish but have everlasting life. - John 3:16 - NIV" +# explanation, prayer = bible_verse(verse) +# print("Explanation2:", explanation) +# print("Prayer2:", prayer)