Multiverse-of-Projects / NewsAI

A dynamic NewsAI dashboard that uses NLP to analyze news articles, visualize sentiment trends, and extract insights through interactive data visualizations.
https://news-ai-dashboard.streamlit.app/
GNU General Public License v3.0
16 stars 30 forks source link

Add Async Summarization Function with API Rate Limiting #40

Open Devasy23 opened 1 month ago

Devasy23 commented 1 month ago

Description:
This task requires adding a function to summarize the fetched article content using an external API. The function should handle rate-limiting by utilizing an asyncio.Semaphore to ensure no more than a specified number of requests are made per minute (e.g., 10 requests per minute). The summarization should be an asynchronous function to ensure non-blocking I/O operations.

Changes:

Example Dummy Code:

import asyncio

# Semaphore for rate-limiting the API (10 requests per minute)
gemini_semaphore = asyncio.Semaphore(10)

async def summarize_content(article_id, content):
    async with gemini_semaphore:
        try:
            # Simulating a call to the Gemini API with async
            await asyncio.sleep(1)  # Simulate API delay
            summary = f"Summary of article {article_id}"
            return summary
        except Exception as e:
            print(f"Error summarizing content for article {article_id}: {e}")
            raise

# Usage example
async def example_usage():
    content = "This is some article content..."
    summary = await summarize_content('123', content)
tarunkumar2005 commented 1 month ago

@Devasy23 I want to contribute to this. Assign me under GSSOC 2024 - ext and hacktoberfest

Devasy23 commented 1 month ago

Hi @tarunkumar2005 . Thank you for showing some interest. Before starting the issue we would connect once to discuss further as it is complicated to understand from mere description

tarunkumar2005 commented 1 month ago

@Devasy23 Okay we can discuss and i will try to solve this issue then

tarunkumar2005 commented 1 month ago

@Devasy23 Okay we can discuss and i will try to solve this issue then

how would you like to connect

Devasy23 commented 1 month ago

Discord

tarunkumar2005 commented 1 month ago

Okay i will be free after 4:30 pm here is my discord username is tarunkumar8278 we can have a call and you can explain me okay after 4:30 to 7:00 anytime. just inform me @Devasy23

Devasy23 commented 1 month ago

Join this discord of this repo :https://discord.gg/kV4ANf6x

tarunkumar2005 commented 1 month ago

@Devasy23 I am free now and joined the discord we can connect now okay.

Devasy23 commented 1 month ago

Sure will ping you when I'm free