Skip to content

Commit

Permalink
UI v2 update
Browse files Browse the repository at this point in the history
* UI Changes: Standardised each section and buttons

* UI Changes: Changes made according to suggestions

* UI Changes: Python linting corrected!

---------

Co-authored-by: Garvit Shah <[email protected]>
  • Loading branch information
gobbledy-gook and Garvit Shah authored Aug 31, 2023
1 parent b90fa2d commit f25bc3b
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 43 deletions.
1 change: 0 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash
export API_KEY=APIKEY
export MONGO_URI=MONGOURL
python3 server.py
44 changes: 29 additions & 15 deletions report_ai/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta>
<link rel="stylesheet" href="rating.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" />
<link rel="stylesheet" href="ai.css">
<!-- <link rel="stylesheet" href="ai.css"> -->
<style>
h1 {
padding-top: 3%;
Expand Down Expand Up @@ -75,29 +75,43 @@
</form>
</div>
<div class="wordcloud">
<div style="font-size:18px;">Word Cloud:<span>
<button id="generate_words" class="generate">Generate</button></span></div>
<div class = "sectionContainer">
<div class = "subHeading">Word Cloud:</div>
<div class = "btn">
<button id="generate_words" class="generate">Generate</button>
</div>
</div>
<div class="worldcloudpara" style="padding:5px; display:inline; float:left">

</div>
</div>
<div class="wordcloud" id="SummaryParent">
<div style="font-size:18px;">Summary:<span><button id="summary" class="generate">Generate</button></span></div>
<div style = "justify-content: center; margin-top: 2%;" id = "loader"></div>
<div class="Summary" id="summarizerDiv">

<div class="wordcloud">
<div class="sectionContainer" id="SummaryParent">
<div class="subHeading">Summary:</div>
<div class = "btn">
<button id="summary" class="generate">Generate</button>
</div>
<div style = "justify-content: center; margin-top: 2%;" id = "loaderSummary"></div>
<div class="Summary" id="summarizerDiv">

</div>
</div>
</div>

<div class="wordcloud">
<div class="textarea2">
<textarea id="ask" cols="50" placeholder="Enter your query related to the content"></textarea>
</div>
<div class="btn">
<button id="askbtn" type="submit" class="generate">Ask a Question</button>
</div>
<div id="Answer" style="overflow-y: scrollable;">
<div class = "sectionContainer" id = "qnaParent">
<div class = "subHeading">QnA: </div>
<div class = "textarea">
<textarea class = "textarea2" id="ask" cols="50" placeholder="Enter your query related to the content"></textarea>
</div>
<div class="btn">
<button id="askbtn" type="submit" class="generate">Ask a Question</button>
</div>

<div style = "justify-content: center; margin-top: 2%;" id = "loaderQNA"></div>
<div id="Answer">

</div>
</div>
</div>

Expand Down
13 changes: 12 additions & 1 deletion report_ai/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function logger (result) {
btn2.onclick = async () => {
btn2.style.display = 'none'
const Parent = document.getElementById('SummaryParent')
const gifParent = document.getElementById('loader')
const gifParent = document.getElementById('loaderSummary')
gifParent.style.display = 'flex'
const gif = document.createElement('img')
gif.src = 'assets/rotate-right.png'
Expand Down Expand Up @@ -101,6 +101,15 @@ function logger (result) {
question: document.getElementById('ask').value,
context: result.key.text
}
btn3.disabled = true
const Parent = document.getElementById('qnaParent')
const gifParent = document.getElementById('loaderQNA')
gifParent.style.display = 'flex'
const gif = document.createElement('img')
gif.src = 'assets/rotate-right.png'
gif.style.animation = 'spin 1.5s linear infinite'
gif.style.width = '6%'
gifParent.appendChild(gif)
const response = await fetch('http://127.0.0.1:5000/ask-question', {
method: 'POST',
headers: {
Expand All @@ -120,6 +129,8 @@ function logger (result) {
// Update the UI with the received answer
const answerDiv = document.getElementById('Answer')
answerDiv.style.display = 'block'
Parent.removeChild(gifParent)
btn3.disabled = false
answerDiv.innerHTML = answer
} catch (error) {
console.error('Error fetching answer:', error)
Expand Down
65 changes: 44 additions & 21 deletions report_ai/rating.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ body {
padding-top: 20px;
padding-left: 20px;
padding-right: 20px;
padding-bottom:20px;
width: 400px;
display: flex;
flex-direction: row;
Expand All @@ -30,18 +31,16 @@ body {
.container {
position: relative;
width: 400px;
padding-left: 10px;
padding-right: 10px;
padding-top: 10px;
margin: 8px;

margin-left: 8px;
margin-right: 8px;
border-radius: 5px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
border-top: 1px solid rgba(197, 197, 197, 0.308);
}

.container .post {
display: none;
}
Expand Down Expand Up @@ -71,14 +70,15 @@ body {
.star-widget label {
font-size: 15px;
color: #444;
padding: 5px;
padding: 10px;
float: right;
transition: all 0.2s ease;
text-align: right;
}

.star-widget {
margin-bottom: 10px;
margin-top:10px;
}

input:not(:checked) ~ label:hover,
Expand Down Expand Up @@ -156,8 +156,8 @@ form .btn button {
width: 100%;
border: 1px solid #444;
outline: none;
background: #222;
color: #999;
background: #e0e0e0;
color: #1e1e1e;
font-size: 12px;
font-weight: 500;
text-transform: uppercase;
Expand All @@ -166,19 +166,24 @@ form .btn button {
}
form .btn button:hover {
background: #1b1b1b;
color: white
}

.review {
.btn{
display:flex;
justify-content: flex-end;
padding-top: 2%;
padding-bottom: 2%;
}

#review {
display: flex;
justify-content: center;
flex-direction: column;
}

.wordcloud {
padding-top: 20px;
padding-left: 10px;
padding-right: 10px;
margin-bottom: 10px;
padding:20px;
width: 100%;
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -206,14 +211,20 @@ form .btn button:hover {
.Summary {
background-color: #272727;
width: 360;
height: 200;
padding: 5px;
height: 150;
margin-top:10px;
padding-top: 10px;
padding-left: 7px;
padding-right: 7px;
padding-bottom: 10px;
/* display:block; */
display: none;
float: left;
text-align: left;
overflow-y: hidden;
overflow-x:hidden;
overflow-y:auto;
color: #c6c6c6;
border: 0.5px solid rgb(95, 95, 95)
}

.loader {
Expand All @@ -240,26 +251,26 @@ form .btn button:hover {
}

.generate {
border: 1px solid rgba(255, 255, 255, 0.794);
border: 1px solid rgba(255, 255, 255, 0.7);
/* border: 1px solid rgba(255, 255, 255, 0.712); */
border-radius: 7px;
/* border-radius: 7px; */
background-color: rgb(211, 118, 48);
padding-left: 7px;
padding-right: 7px;
margin-left: 40%;
}

.generate:hover {
border: 1px solid rgba(255, 255, 255, 0.794);
border-radius: 7px;
border: 1px solid rgba(255, 255, 255, 0.7);
/* border-radius: 7px; */
background-color: rgb(51, 51, 51);
padding-left: 7px;
padding-right: 7px;
margin-left: 40%;
color: white;
}

#textarea2 {
.textarea2 {
height: 100%;
width: 100%;
outline: none;
Expand Down Expand Up @@ -325,3 +336,15 @@ form .btn button:hover {
border: 1px solid #00000000;
background-color: #dadada;
}

.sectionContainer{
display:flex;
flex-direction: column;
}

.subHeading{
justify-content: flex-start;
text-align: left;
font-size: 140%;
padding-bottom: 2%;
}
12 changes: 7 additions & 5 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
cors = CORS(app)


API_KEY = os.environ.get("GPTNEO", None)
headers = {"Authorization": API_KEY}
BART = os.environ.get("BART", None)
ROBERTA = os.environ.get("BART", None)
headersBart = {"Authorization": BART}
headersRoberta = {"Authorization": ROBERTA}
MONGO_URI = os.environ.get("mongo_uri","mongodb+srv://admin:[email protected]/")
client = MongoClient(MONGO_URI, server_api=ServerApi("1"))
try:
Expand All @@ -44,14 +46,14 @@ def summarizer(text):
def query(payload):
data = json.dumps(payload)
response = requests.request(
"POST", api_url_summarizer, headers=headers, data=data, timeout=10
"POST", api_url_summarizer, headers=headersBart, data=data, timeout=10
)
return json.loads(response.content.decode("utf-8"))

output = query(
{
"inputs": text,
"parameters": {"do_sample": False},
"parameters": {"min_length": 100},
}
)
print(output)
Expand All @@ -68,7 +70,7 @@ def ask_qna(text):
def query(payload):
data = json.dumps(payload)
response = requests.request(
"POST", api_url_qna, headers=headers, data=data, timeout=10
"POST", api_url_qna, headers=headersRoberta, data=data, timeout=10
)
return json.loads(response.content.decode("utf-8"))

Expand Down

0 comments on commit f25bc3b

Please sign in to comment.