This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Specify the Base image | |
FROM python:3.8-slim | |
# Update and install the basic OS-related packages | |
RUN apt-get update -y && \ | |
apt-get dist-upgrade -y && \ | |
apt-get install -y && \ | |
apt-get install build-essential -y \ | |
supervisor wget unzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// URL at which the API server is running | |
base_url = "http://127.0.0.1:8000"; | |
// Issue a POST request with a request body | |
function doPost(url, body, callback){ | |
var xmlHttp = new XMLHttpRequest(); | |
xmlHttp.onreadystatechange = function() { | |
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) | |
callback(xmlHttp.responseText); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inject _getSelectedTextFromTab into current page and | |
// populate the textarea for user input in the popup with the selected text | |
function getSelectedText() { | |
// Get information about the currently active tab | |
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { | |
let tab = tabs[0]; | |
// Inject JavaScript into the active tab to get the text selected by the user | |
chrome.scripting.executeScript( | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<!-- Use Bootstrap 5 by loading it as a stylesheet from jsDelivr, a free open source CDN --> | |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> | |
<title>Janus AI: Paraphrasing Tool</title> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Janus AI", | |
"description": "AI-based Smart Paraphrasing Solution", | |
"version": "1.0", | |
"manifest_version": 3, | |
"permissions": [ | |
"tabs", | |
"scripting" | |
], | |
"host_permissions": ["https://*/"], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import FastAPI | |
from starlette.middleware.cors import CORSMiddleware | |
from pydantic import BaseModel | |
import paraphrasingModule | |
# Load the paraphrasing, keyword extraction and synonym finding modules | |
paraphraser = paraphrasingModule.PegasusParaphraser() | |
kw_syn = paraphrasingModule.KeywordSynonyms() | |
# User's input text is sent as a request body. The structure of this body can be defined by extending Pydantic's BaseModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keybert import KeyBERT | |
import nltk | |
# Use NLTK's data downloader to download the required data packages (WordNet and Open Multilingual Wordnet) if not present already | |
for resource in ["wordnet", "omw-1.4"]: | |
try: | |
nltk_path = nltk.find("corpora/{0}".format(resource)) | |
except Exception: | |
nltk.download(resource) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from transformers import PegasusForConditionalGeneration, PegasusTokenizer | |
from sentence_splitter import SentenceSplitter | |
class PegasusParaphraser: | |
def __init__(self, num_beams=10): | |
if(torch.cuda.is_available()): | |
self.device = torch.device("cuda:0") | |
else: | |
self.device = torch.device("cpu:0") |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mlf_run_3.log_webapp_file('streamlit_roberta.py') |
NewerOlder