from dotenv import load_dotenv load_dotenv() from fastapi import FastAPI, HTTPException from fastapi.middleware.cors import CORSMiddleware import google.generativeai as genai import os import requests from bs4 import BeautifulSoup import validators from youtube_transcript_api import YouTubeTranscriptApi # from cachetools import TTLCache # import asyncio # import hashlib # import time genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) app = FastAPI() origins=[ "http://localhost:3000", "chrome-extension://mjdggpghaabiocpngdkageeenpmgebim" ] app.add_middleware( CORSMiddleware, allow_origins=origins, allow_credentials=True, allow_methods=['*'], allow_headers=['*'] ) model=genai.GenerativeModel("gemini-1.5-flash") prompt1=""" As a Web Insight Summarizer, your task is to summarize the given web content into a clear and informative text of around 250 words. Highlight key points using bullet points or numbered lists to emphasize important details. Keep the summary objective, coherent, and focused on the main insights without adding personal opinions. Here's an example: Main Topic: Climate Change -Rising Temperatures: Due to greenhouse gas emissions. -Consequences: Extreme weather events, rising sea levels, loss of biodiversity. -Mitigation Strategies: Renewable energy, carbon reduction, sustainable practices. -Call to Action: Urgent collective action needed. Your summary should provide a comprehensive overview of the content, enabling readers to grasp the main insights efficiently. Remember to keep the summary objective and focused on the key points of the content without adding unnecessary details or opinions. Providing a clear and digestible overview will help users grasp the main insights from the parsed HTML content efficiently which is given in the following content : """ prompt2=""" As an Insight Summarizer, your task is to distill provided information into a concise and informative summary of around 250 words. Utilize bullet points or numbered lists to highlight key points and ensure clarity and coherence in your summary. Avoid injecting personal opinions and focus solely on presenting the main insights from the content. Here's an example: Main Topic: [Main topic of the content] [Key point 1]: [Description or detail]
[Key point 2]: [Description or detail] [Key point 3]: [Description or detail]
Additional Considerations: [Additional consideration 1]: [Description or detail] [Additional consideration 2]: [Description or detail] [Additional consideration 3]: [Description or detail] Your summary should provide a comprehensive overview of the content, enabling readers to understand the main insights efficiently. Remember to maintain objectivity and focus on the key points to ensure clarity and usefulness for the reader """ prompt6=""" As an Insight Summarizer, your task is to distill provided information into a concise and informative summary of around 250 words. Utilize bullet points or numbered lists to highlight key points and ensure clarity and coherence in your summary. Avoid injecting personal opinions and focus solely on presenting the main insights from the content. Ensure to structure the content using HTML tags like

for paragraphs and