Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import json | |
| import time | |
| urls = [ | |
| "https://huggingface.co/spaces/awacke1/CB-GR-Chatbot-Blenderbot", | |
| "https://huggingface.co/spaces/awacke1/TTS-STT-Blocks", | |
| "https://huggingface.co/spaces/awacke1/Prompt-Refinery-Text-to-Image-Generation", | |
| "https://huggingface.co/spaces/awacke1/Video-Summary", | |
| "https://huggingface.co/spaces/awacke1/AI-MovieMaker-Comedy", | |
| "https://huggingface.co/spaces/awacke1/ChatGPT-Memory-Chat-Story-Generator", | |
| "https://huggingface.co/spaces/awacke1/CloneAnyVoice", | |
| "https://huggingface.co/spaces/awacke1/ChatGPT-Streamlit-2", | |
| "https://huggingface.co/spaces/awacke1/WikipediaUltimateAISearch", | |
| "https://huggingface.co/spaces/awacke1/RLHF.Cognitive.Episodic.Semantic.Memory", | |
| "https://huggingface.co/spaces/awacke1/Memory-Shared", | |
| "https://huggingface.co/spaces/awacke1/VideoSwap", | |
| "https://huggingface.co/spaces/awacke1/AI-Wikipedia-Search", | |
| "https://huggingface.co/spaces/awacke1/AutoMLUsingStreamlit-Plotly", | |
| "https://huggingface.co/spaces/awacke1/NLP-Lyric-Chorus-Image", | |
| "https://huggingface.co/spaces/awacke1/OpenAssistant-Chatbot-FTW-Open-Source", | |
| "https://huggingface.co/spaces/awacke1/ChatGPTStreamlit7", | |
| "https://huggingface.co/spaces/awacke1/MultiPDF-QA-ChatGPT-Langchain", | |
| "https://huggingface.co/spaces/awacke1/SOTA-Plan", | |
| "https://huggingface.co/spaces/awacke1/AIandSmartTools", | |
| "https://huggingface.co/spaces/awacke1/3DVirtualFood", | |
| "https://huggingface.co/spaces/awacke1/Gradio-Gallery-Health-Medical-Icon-Sets", | |
| "https://huggingface.co/spaces/awacke1/DatasetAnalyzer", | |
| "https://huggingface.co/spaces/awacke1/PrompTart", | |
| "https://huggingface.co/spaces/awacke1/sileod-deberta-v3-base-tasksource-nli", | |
| "https://huggingface.co/spaces/awacke1/File-Memory-Operations-Human-Feedback-Gradio", | |
| "https://huggingface.co/spaces/awacke1/Bloom.Big.Science.Continual.Generator", | |
| "https://huggingface.co/spaces/awacke1/Ontology-Gradio", | |
| "https://huggingface.co/spaces/awacke1/HTML5-Aframe-3dMap-Flight", | |
| "https://huggingface.co/spaces/awacke1/Bloom.Generative.Writer", | |
| "https://huggingface.co/spaces/awacke1/Voice-ChatGPT-Streamlit-12", | |
| "https://huggingface.co/spaces/awacke1/HTML5-AR-VR", | |
| "https://huggingface.co/spaces/awacke1/AnimationAI", | |
| "https://huggingface.co/spaces/awacke1/GenerativeWordsandImages", | |
| "https://huggingface.co/spaces/awacke1/AR-VR-IOT-Demo", | |
| "https://huggingface.co/spaces/awacke1/ArtStyleFoodsandNutrition", | |
| "https://huggingface.co/spaces/awacke1/CarePlanQnAWithContext", | |
| "https://huggingface.co/spaces/awacke1/VideoSummaryYoutube3", | |
| "https://huggingface.co/spaces/awacke1/AW-01ST-CSV-Dataset-Analyzer", | |
| "https://huggingface.co/spaces/awacke1/Try.Playing.Learning.Sharing.On.This", | |
| "https://huggingface.co/spaces/awacke1/google-flan-t5-base", | |
| "https://huggingface.co/spaces/awacke1/PubMed-Parrot-Paraphraser-on-T5", | |
| "https://huggingface.co/spaces/awacke1/Writing-Grammar-And-Paraphrase-w-Pegasus", | |
| "https://huggingface.co/spaces/awacke1/runwayml-stable-diffusion-v1-5", | |
| "https://huggingface.co/spaces/awacke1/DockerGoFlanT5", | |
| "https://huggingface.co/spaces/awacke1/GradioContinualGenerator", | |
| "https://huggingface.co/spaces/awacke1/StreamlitSuperPowerCheatSheet" | |
| ] | |
| # Extract the last part of each URL (after the last '/') to serve as the name of the button | |
| url_names = [url.split('/')[-1] for url in urls] | |
| # Associate each URL with a relevant emoji based on keywords in its name | |
| emoji_mapping = { | |
| "Chatbot": "π€", | |
| "TTS": "π£οΈ", | |
| "STT": "π", | |
| "Video": "π₯", | |
| "MovieMaker": "πΏ", | |
| "ChatGPT": "π¬", | |
| "Voice": "ποΈ", | |
| "Wikipedia": "π", | |
| "Memory": "π§ ", | |
| "AI": "π§ ", | |
| "OpenAssistant": "π€", | |
| "3D": "πΆοΈ", | |
| "AR": "π", | |
| "VR": "πΆοΈ", | |
| "Animation": "ποΈ", | |
| "Dataset": "π", | |
| "Gradio": "π»", | |
| "HTML5": "π", | |
| "Writing": "βοΈ", | |
| "Grammar": "ποΈ", | |
| "Paraphrase": "π", | |
| "Streamlit": "π " | |
| } | |
| def get_emoji(name): | |
| for key, emoji in emoji_mapping.items(): | |
| if key in name: | |
| return emoji | |
| return "π" | |
| def load_votes(): | |
| try: | |
| with open("votes.json", "r") as f: | |
| return json.load(f) | |
| except FileNotFoundError: | |
| return {url: 0 for url in urls} | |
| def save_votes(votes): | |
| with open("votes.json", "w") as f: | |
| json.dump(votes, f) | |
| def main(): | |
| st.set_page_config(layout="wide") | |
| if "selected_url" not in st.session_state: | |
| st.session_state.selected_url = None | |
| votes = load_votes() | |
| col1, col2 = st.columns([1, 2]) | |
| with col1: | |
| items = [ | |
| { | |
| "url": url, | |
| "name": url.split("/")[-1], | |
| "emoji": get_emoji(url.split("/")[-1]), | |
| "votes": votes[url], | |
| } | |
| for url in urls | |
| ] | |
| items.sort(key=lambda x: (-x["votes"], x["name"])) | |
| button_cols = st.columns(2) | |
| for i, item in enumerate(items): | |
| with button_cols[i % 2]: | |
| if st.button(f"{item['emoji']} {item['name']}", key=item["url"]): | |
| votes[item["url"]] += 1 | |
| save_votes(votes) | |
| st.session_state.selected_url = item["url"] | |
| st.rerun() | |
| st.write(f"Votes: {item['votes']}") | |
| with col2: | |
| if "selected_url" in st.session_state and st.session_state.selected_url: | |
| selected_url = st.session_state.selected_url | |
| st.info(f"You selected: {selected_url}") | |
| # Open the selected URL in a new browser tab or window | |
| st.markdown( | |
| f""" | |
| <a href="{selected_url}" target="_blank" style="text-decoration: none;"> | |
| <button style="padding: 10px; background-color: #4CAF50; color: white; border: none; cursor: pointer;"> | |
| Open in New Tab | |
| </button> | |
| </a> | |
| """, | |
| unsafe_allow_html=True, | |
| ) | |
| else: | |
| st.info("Select a space from the list on the left to view details.") | |
| if any(votes.values()): | |
| with col1: | |
| df = pd.DataFrame( | |
| [ | |
| {"name": i["name"], "votes": i["votes"]} | |
| for i in items if votes[i["url"]] > 0 | |
| ] | |
| ) | |
| st.bar_chart(df.set_index("name")) | |
| if __name__ == "__main__": | |
| main() |