Bilalst commited on
Commit
057e55c
1 Parent(s): 661dbfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -38
app.py CHANGED
@@ -63,46 +63,16 @@ index.add(sentence_embeddings)
63
 
64
 
65
  #---------------------------------------------
 
 
66
 
67
- def get_video_links(input_text):
68
- # Encode input text using SentenceTransformer
69
- input_embedding = model.encode([input_text])[0]
70
 
71
- # Perform nearest neighbor search in FAISS index
72
- k = 15 # Number of nearest neighbors to retrieve
73
- _, T = index.search(np.array([input_embedding]), k) # search
74
-
75
- # Return the list of video links with thumbnails and titles as an HTML string
76
- video_links = []
77
- visited_ids = set()
78
- for i in T[0]:
79
- video_id = ids[i]
80
- if video_id in visited_ids:
81
- continue # Skip if the video_id has already been visited
82
- visited_ids.add(video_id)
83
-
84
- # Retrieve video details using YouTube Data API
85
- video_info_url = f"https://www.googleapis.com/youtube/v3/videos?part=snippet&id={video_id}&key={api_key}"
86
- response = requests.get(video_info_url)
87
- data = response.json()
88
- video_title = data['items'][0]['snippet']['title']
89
- video_thumbnail = data['items'][0]['snippet']['thumbnails']['default']['url']
90
-
91
- # Generate HTML code for the video link with thumbnail and title
92
- video_link = f"https://www.youtube.com/watch?v={video_id}"
93
- video_html = f'<a href="{video_link}" target="_blank"><img src="{video_thumbnail}"><br>{video_title}</a><br>'
94
- video_links.append(video_html)
95
-
96
- return ''.join(video_links)
97
-
98
- # Create Gradio interface with "html" output type
99
- iface = gr.Interface(fn=get_video_links, inputs=[gr.inputs.Textbox(label="Add what you are looking to find in Dr. Joe's testimonials!")], outputs="html", title="Dr. Joe Dispenza testimonials Search")
100
-
101
-
102
-
103
- # Launch the Gradio interface on Hugging Face Spaces
104
- if __name__ == '__main__':
105
- iface.launch()
106
 
107
 
108
 
 
63
 
64
 
65
  #---------------------------------------------
66
+ # Pause message from Dr. Joe's team
67
+ pause_message = "This app has been paused upon a request from Dr. Joe's team because they are working on implementing semantic search for testimonials. We appreciate your understanding and patience."
68
 
69
+ # Create a function that returns the pause message
70
+ def pause_message_fn(Type_your_search):
71
+ return pause_message
72
 
73
+ # Create Gradio interface with the pause message
74
+ iface = gr.Interface(fn=pause_message_fn, inputs="text", outputs="text", title="Dr. Joe Dispenza Testimonials Search.\n\nThis app has been paused upon a request from Dr. Joe's team because they are working on implementing semantic search for testimonials. We appreciate your understanding and patience.")
75
+ iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
 
78