Spaces:
Sleeping
Sleeping
File size: 7,903 Bytes
b30ed6a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# Import required libraries
import streamlit as st
import youtube
import confluence
import modJira
import time
import similarity
import ingest
# global transcript_result
# transcript_result = ""
# Set page configuration and title for Streamlit
st.set_page_config(page_title="AI-Seeker", page_icon="📼", layout="wide")
# Add header with title and description
st.markdown(
'<p style="display:inline-block;font-size:40px;font-weight:bold;">AI-Seeker</p> <p style="display:inline-block;font-size:16px;">AI-Seeker is a web-app tool that utilizes APIs to extract text content from YouTube, Confluence and Jira. It incorporates Llama-2-7B-Chat-GGML model with Langchain to provide users with a summary and query-based smart response depending on the content of the media source.<br><br></p>',
unsafe_allow_html=True
)
txtInputBox = "YouTube"
with st.sidebar.title("Configuration"):
usecase = st.sidebar.selectbox("Select Media Type:",("YouTube", "Confluence", "Jira"))
if usecase == "YouTube":
txtInputBox = "Enter ID of YouTube Video"
default_value = "Y8Tko2YC5hA"
elif usecase == "Confluence":
txtInputBox = "Enter ID of your Confluence Page"
default_value = "393217"
elif usecase == "Jira":
txtInputBox = "Enter the name of your JIRA Project"
default_value = "jira_test"
video_id = st.sidebar.text_input(txtInputBox,value=default_value)
strTranscript = ""
training_status = "yet_to_start"
btnTranscript = st.sidebar.button("Transcript")
btnSummary = st.sidebar.button("Summary")
btnTrain = st.sidebar.button("Train")
if btnTrain:
with st.spinner("Training in Progress..."):
ingest.main()
query = st.sidebar.text_input('Enter your question below:', value="What is Python?")
btnAsk = st.sidebar.button("Query")
btnClear = st.sidebar.button("Clear Data")
if btnClear:
st.session_state.clear()
def fnJira():
st.info("Transcription")
if btnTranscript:
if 'transcript_result' not in st.session_state:
st.session_state['transcript_result'] = modJira.get_details(video_id)
transcript_result = st.session_state['transcript_result']
st.dataframe(transcript_result)
else:
if 'transcript_result' in st.session_state:
transcript_result = st.session_state['transcript_result']
st.dataframe(transcript_result)
st.info("Query")
if btnAsk:
with st.spinner(text="Retrieving..."):
if 'transcript_answer' not in st.session_state:
answer = modJira.ask_question(query)
st.session_state['transcript_answer'] = answer
#st.success(answer)
if 'transcript_answer' in st.session_state:
answer = st.session_state['transcript_answer']
st.success(answer)
else:
if 'transcript_answer' in st.session_state:
answer = st.session_state['transcript_answer']
st.success(answer)
def fnConfluence():
st.info("Transcription")
if btnTranscript:
if 'transcript_result' not in st.session_state:
st.session_state['transcript_result'] = confluence.transcript(video_id)
transcript_result = st.session_state['transcript_result']
st.markdown(f"<div style='height: 100px; overflow-y: scroll;'>{transcript_result}</div>", unsafe_allow_html=True)
else:
if 'transcript_result' in st.session_state:
transcript_result = st.session_state['transcript_result']
st.markdown(f"<div style='height: 100px; overflow-y: scroll;'>{transcript_result}</div>", unsafe_allow_html=True)
col1, col2 = st.columns([1, 1])
with col1:
# with col12:
st.info("Summary")
if btnSummary:
if 'transcript_summary' not in st.session_state:
with st.spinner(text="Retrieving..."):
st.session_state['transcript_summary'] = confluence.summarize()
summary = st.session_state['transcript_summary']
st.success(summary)
else:
if 'transcript_summary' in st.session_state:
summary = st.session_state['transcript_summary']
st.success(summary)
with col2:
st.info("Query")
if btnAsk:
with st.spinner(text="Retrieving..."):
if 'transcript_answer' not in st.session_state:
answer = confluence.ask_question(query)
st.session_state['transcript_answer'] = answer
#st.success(answer)
if 'transcript_answer' in st.session_state:
answer = st.session_state['transcript_answer']
st.success(answer)
else:
if 'transcript_answer' in st.session_state:
answer = st.session_state['transcript_answer']
st.success(answer)
def fnYoutube():
st.info("Transcription")
if btnTranscript:
if 'transcript_result' not in st.session_state:
st.session_state['transcript_result'] = youtube.audio_to_transcript(video_id)
transcript_result = st.session_state['transcript_result']
st.markdown(f"<div style='height: 100px; overflow-y: scroll;'>{transcript_result}</div>", unsafe_allow_html=True)
else:
if 'transcript_result' in st.session_state:
transcript_result = st.session_state['transcript_result']
st.markdown(f"<div style='height: 100px; overflow-y: scroll;'>{transcript_result}</div>", unsafe_allow_html=True)
col1, col2 = st.columns([1, 1])
with col1:
# with col12:
st.info("Summary")
if btnSummary:
if 'transcript_summary' not in st.session_state:
with st.spinner(text="Retrieving..."):
st.session_state['transcript_summary'] = youtube.summarize()
summary = st.session_state['transcript_summary']
st.success(summary)
else:
if 'transcript_summary' in st.session_state:
summary = st.session_state['transcript_summary']
st.success(summary)
with col2:
st.info("Query")
if btnAsk:
with st.spinner(text="Retrieving..."):
if 'transcript_answer' not in st.session_state:
answer = youtube.ask_question(query)
st.session_state['transcript_answer'] = answer
#st.success(answer)
if 'transcript_answer' in st.session_state:
answer = st.session_state['transcript_answer']
st.success(answer)
transcript_start_time, transcript_end_time = similarity.similarity(strQuery=answer)
st.video(f"https://www.youtube.com/embed/{video_id}", format="video/mp4", start_time=int(transcript_start_time))
else:
if 'transcript_answer' in st.session_state:
answer = st.session_state['transcript_answer']
st.success(answer)
transcript_start_time, transcript_end_time = similarity.similarity(strQuery=answer)
st.video(f"https://www.youtube.com/embed/{video_id}", format="video/mp4", start_time=int(transcript_start_time))
if usecase == "YouTube":
fnYoutube()
elif usecase == "Confluence":
fnConfluence()
elif usecase == "Jira":
fnJira()
# Hide Streamlit header, footer, and menu
hide_st_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
header {visibility: hidden;}
</style>
"""
#"""footer {visibility: hidden;}
# header {visibility: hidden;}"""
# Apply CSS code to hide header, footer, and menu
st.markdown(hide_st_style, unsafe_allow_html=True) |