Skip to content

Commit

Permalink
Merge pull request #247 from deepashri30/master
Browse files Browse the repository at this point in the history
AI-Powered Website Content Summarizer (Browser Extension) #132
  • Loading branch information
Sulagna-Dutta-Roy authored May 16, 2024
2 parents 6f8a0d0 + 65778d3 commit 088f5d6
Show file tree
Hide file tree
Showing 10 changed files with 282 additions and 0 deletions.
1 change: 1 addition & 0 deletions Website Content Summarizer/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn your_module_name:app
21 changes: 21 additions & 0 deletions Website Content Summarizer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
**AI Summarizer - Chrome Extension**

This Chrome extension utilizes artificial intelligence to generate summaries of webpages you visit.

**Features**
**AI-powered Summarization:** Get concise summaries of articles, news stories, and other web content with the help of advanced AI algorithms.
**Improved Efficiency:** Quickly grasp the key points of a webpage without having to read through the entire text.
**Time Saver:** Save valuable time by getting the gist of information before diving deeper.
**Simplified Reading:** Make lengthy content more manageable and easier to understand.

**Installation**
1.Download the Zip File and extract it.
2.Open Chrome and navigate to chrome://extensions/.
3.Enable "Developer mode" by clicking the toggle switch in the top right corner.
4.Click Load Unpacked then select the extracted folder.

You are all set and ready to go.

**Privacy
This extension does not collect or store any personal information from your browsing activity.**

45 changes: 45 additions & 0 deletions Website Content Summarizer/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from flask import Flask, request, jsonify
from langchain.prompts import PromptTemplate
from langchain_community.document_loaders import WebBaseLoader
from langchain.schema import StrOutputParser
from langchain.schema.prompt_template import format_document
from flask_cors import CORS
import os
app = Flask(__name__)
CORS(app)
os.environ["GOOGLE_API_KEY"] = "GEMINI-API-KEY"

from langchain_google_genai import ChatGoogleGenerativeAI
@app.route('/api', methods=['POST'])
def generate_summary():
data = request.get_json()
site = data['site']
loader = WebBaseLoader(site)
docs = loader.load()

doc_prompt = PromptTemplate.from_template("{page_content}")
llm_prompt_template = """Write a concise summary of the following:
"{text}"
CONCISE SUMMARY:"""
llm_prompt = PromptTemplate.from_template(llm_prompt_template)

llm = ChatGoogleGenerativeAI(model="gemini-pro",
temperature=0.7, top_p=0.85)

stuff_chain = (
{
"text": lambda docs: "\n\n".join(
format_document(doc, doc_prompt) for doc in docs
)
}
| llm_prompt # Prompt for Gemini
| llm # Gemini function
| StrOutputParser() # output parser
)

response = stuff_chain.invoke(docs)

return jsonify({"summary": response})

if __name__ == '__main__':
app.run(debug=True)
Binary file added Website Content Summarizer/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Website Content Summarizer/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Website Content Summarizer/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"manifest_version": 2,
"name": "Wiki Summary Extension",
"version": "1.0",
"description": "Get Wikipedia summary for the current page",
"browser_action": {
"default_popup": "popup.html",
"default_icon": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
}
},
"permissions": ["activeTab"]
}
57 changes: 57 additions & 0 deletions Website Content Summarizer/popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
body {
width: 250px;
padding: 10px;
font-family: Arial, sans-serif;
}

h2 {
font-size: 18px;
margin-bottom: 15px;
}

.input-container {
display: flex;
margin-bottom: 10px;
}

input[type="text"] {
flex: 1;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px 0 0 4px;
}

button {
padding: 8px 15px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 0 4px 4px 0;
cursor: pointer;
}

ul {
list-style: none;
padding: 0;
}

li {
padding: 10px;
margin: 5px 0;
background-color: #f8f9fa;
border-radius: 4px;
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
display: flex;
justify-content: space-between;
align-items: center;
}

li button {
background-color: #dc3545;
margin-left: 10px;
border-radius: 3px;
padding: 3px 6px;
color: #fff;
border: none;
cursor: pointer;
}
49 changes: 49 additions & 0 deletions Website Content Summarizer/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Summary Extension</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<style>
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}

#summary-container {
width: 300px;
padding: 20px;
border-radius: 10px;
background-color: #ffffff;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

h3 {
color: #26a69a;
}

#summary {
white-space: pre-line;
font-size:15px;
}
</style>
</head>

<body>
<div id="summary-container">
<h3>Web Summa</h3>
<div id="summary">Loading...</div>
</div>

<script src="popup.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</body>

</html>
28 changes: 28 additions & 0 deletions Website Content Summarizer/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
document.addEventListener('DOMContentLoaded', function () {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var currentUrl = tabs[0].url;
var apiUrl = 'https://parapager.onrender.com/api'; // Replace with your actual API endpoint

var requestBody = {
site: currentUrl
};

fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestBody),
})
.then(response => response.json())
.then(data => {
var summaryElement = document.getElementById('summary');
summaryElement.textContent = data.summary;
})
.catch(error => {
console.error('Error fetching data:', error);
var summaryElement = document.getElementById('summary');
summaryElement.textContent = 'Error fetching data';
});
});
});
66 changes: 66 additions & 0 deletions Website Content Summarizer/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
aiohttp==3.9.3
aiosignal==1.3.1
annotated-types==0.6.0
anyio==4.2.0
async-timeout==4.0.3
attrs==23.2.0
beautifulsoup4==4.12.3
blinker==1.7.0
bs4==0.0.2
build==1.0.3
cachetools==5.3.2
certifi==2024.2.2
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
dataclasses-json==0.6.4
exceptiongroup==1.2.0
Flask==3.0.2
Flask-Cors==4.0.0
frozenlist==1.4.1
google-ai-generativelanguage==0.4.0
google-api-core==2.16.2
google-auth==2.27.0
google-generativeai==0.3.2
googleapis-common-protos==1.62.0
greenlet==3.0.3
grpcio==1.60.1
grpcio-status==1.60.1
gunicorn==21.2.0
idna==3.6
itsdangerous==2.1.2
Jinja2==3.1.3
jsonpatch==1.33
jsonpointer==2.4
langchain==0.1.5
langchain-community==0.0.17
langchain-core==0.1.18
langchain-google-genai==0.0.6
langsmith==0.0.86
MarkupSafe==2.1.5
marshmallow==3.20.2
multidict==6.0.5
mypy-extensions==1.0.0
numpy==1.26.4
packaging==23.2
proto-plus==1.23.0
protobuf==4.25.2
pyasn1==0.5.1
pyasn1-modules==0.3.0
pydantic==2.6.1
pydantic_core==2.16.2
pyproject_hooks==1.0.0
PyYAML==6.0.1
requests==2.31.0
rsa==4.9
sniffio==1.3.0
soupsieve==2.5
SQLAlchemy==2.0.25
tenacity==8.2.3
tomli==2.0.1
tqdm==4.66.1
typing-inspect==0.9.0
typing_extensions==4.9.0
urllib3==2.2.0
Werkzeug==3.0.1
yarl==1.9.4

0 comments on commit 088f5d6

Please sign in to comment.