Dan Conger commited on
Commit
b5e5ab0
·
1 Parent(s): 95cbed9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -45,7 +45,7 @@ def make_query(query, retriever, top_k=10, include_values=True, include_metadata
45
  st.session_state.index = init_pinecone()
46
  retriever = init_retriever()
47
 
48
- def card(thumbnail: str, title: str, urls: list, contexts: list, starts: list, ends: list):
49
  meta = [(e, s, u, c) for e, s, u, c in zip(ends, starts, urls, contexts)]
50
  meta.sort(reverse=False)
51
  text_content = []
@@ -84,6 +84,9 @@ def card(thumbnail: str, title: str, urls: list, contexts: list, starts: list, e
84
  <div class="col-md-8 col-sm-8">
85
  <h2>{title}</h2>
86
  </div>
 
 
 
87
  <div>
88
  {html_text}
89
  <br><br>
@@ -100,7 +103,7 @@ publication_map = {
100
  }
101
 
102
  st.write("""
103
- # YouTube Q&A
104
  """)
105
 
106
  st.info("""
@@ -141,15 +144,18 @@ if query != "":
141
  if video_id not in results:
142
  results[video_id] = {
143
  'title': context['metadata']['title'],
144
- 'urls': [f"{context['metadata']['url']}?t={int(context['metadata']['start_second'])}"],
 
145
  'contexts': [context['metadata']['text']],
146
  'starts': [int(context['metadata']['start_second'])],
147
- 'ends': [int(context['metadata']['end_second'])]
 
 
148
  }
149
  order.append(video_id)
150
  else:
151
  results[video_id]['urls'].append(
152
- f"{context['metadata']['url']}?t={int(context['metadata']['start_second'])}"
153
  )
154
  results[video_id]['contexts'].append(
155
  context['metadata']['text']
@@ -159,10 +165,11 @@ if query != "":
159
  # now display cards
160
  for video_id in order:
161
  card(
162
- thumbnail=f"https://img.youtube.com/vi/{video_id}/maxresdefault.jpg",
163
  title=results[video_id]['title'],
164
  urls=results[video_id]['urls'],
165
  contexts=results[video_id]['contexts'],
166
  starts=results[video_id]['starts'],
167
- ends=results[video_id]['ends']
 
168
  )
 
45
  st.session_state.index = init_pinecone()
46
  retriever = init_retriever()
47
 
48
+ def card(thumbnail: str, title: str, urls: list, contexts: list, starts: list, ends: list, publication: str):
49
  meta = [(e, s, u, c) for e, s, u, c in zip(ends, starts, urls, contexts)]
50
  meta.sort(reverse=False)
51
  text_content = []
 
84
  <div class="col-md-8 col-sm-8">
85
  <h2>{title}</h2>
86
  </div>
87
+ <div class="col-md-8 col-sm-8">
88
+ <h2>{publication}</h2>
89
+ </div>
90
  <div>
91
  {html_text}
92
  <br><br>
 
103
  }
104
 
105
  st.write("""
106
+ # Example
107
  """)
108
 
109
  st.info("""
 
144
  if video_id not in results:
145
  results[video_id] = {
146
  'title': context['metadata']['title'],
147
+ 'thumbnail': context['metadata']['thumbnail'],
148
+ 'urls': [f"{context['metadata']['url']}"],
149
  'contexts': [context['metadata']['text']],
150
  'starts': [int(context['metadata']['start_second'])],
151
+ 'ends': [int(context['metadata']['end_second'])],
152
+ 'publication': context['metadata']['publication'],
153
+ 'category': context['metadata']['category']
154
  }
155
  order.append(video_id)
156
  else:
157
  results[video_id]['urls'].append(
158
+ f"{context['metadata']['url']}"
159
  )
160
  results[video_id]['contexts'].append(
161
  context['metadata']['text']
 
165
  # now display cards
166
  for video_id in order:
167
  card(
168
+ thumbnail=results[video_id]['thumbnail'],
169
  title=results[video_id]['title'],
170
  urls=results[video_id]['urls'],
171
  contexts=results[video_id]['contexts'],
172
  starts=results[video_id]['starts'],
173
+ ends=results[video_id]['ends'],
174
+ publication=results[video_id]['publication']
175
  )