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+
import streamlit as st
|
| 2 |
+
import json
|
| 3 |
+
|
| 4 |
+
urls = [
|
| 5 |
+
"https://huggingface.co/spaces/awacke1/CB-GR-Chatbot-Blenderbot",
|
| 6 |
+
"https://huggingface.co/spaces/awacke1/TTS-STT-Blocks",
|
| 7 |
+
"https://huggingface.co/spaces/awacke1/Prompt-Refinery-Text-to-Image-Generation",
|
| 8 |
+
"https://huggingface.co/spaces/awacke1/Video-Summary",
|
| 9 |
+
"https://huggingface.co/spaces/awacke1/AI-MovieMaker-Comedy",
|
| 10 |
+
"https://huggingface.co/spaces/awacke1/ChatGPT-Memory-Chat-Story-Generator",
|
| 11 |
+
"https://huggingface.co/spaces/awacke1/CloneAnyVoice",
|
| 12 |
+
"https://huggingface.co/spaces/awacke1/ChatGPT-Streamlit-2",
|
| 13 |
+
"https://huggingface.co/spaces/awacke1/WikipediaUltimateAISearch",
|
| 14 |
+
"https://huggingface.co/spaces/awacke1/RLHF.Cognitive.Episodic.Semantic.Memory",
|
| 15 |
+
"https://huggingface.co/spaces/awacke1/Memory-Shared",
|
| 16 |
+
"https://huggingface.co/spaces/awacke1/VideoSwap",
|
| 17 |
+
"https://huggingface.co/spaces/awacke1/AI-Wikipedia-Search",
|
| 18 |
+
"https://huggingface.co/spaces/awacke1/AutoMLUsingStreamlit-Plotly",
|
| 19 |
+
"https://huggingface.co/spaces/awacke1/NLP-Lyric-Chorus-Image",
|
| 20 |
+
"https://huggingface.co/spaces/awacke1/OpenAssistant-Chatbot-FTW-Open-Source",
|
| 21 |
+
"https://huggingface.co/spaces/awacke1/ChatGPTStreamlit7",
|
| 22 |
+
"https://huggingface.co/spaces/awacke1/MultiPDF-QA-ChatGPT-Langchain",
|
| 23 |
+
"https://huggingface.co/spaces/awacke1/SOTA-Plan",
|
| 24 |
+
"https://huggingface.co/spaces/awacke1/AIandSmartTools",
|
| 25 |
+
"https://huggingface.co/spaces/awacke1/3DVirtualFood",
|
| 26 |
+
"https://huggingface.co/spaces/awacke1/Gradio-Gallery-Health-Medical-Icon-Sets",
|
| 27 |
+
"https://huggingface.co/spaces/awacke1/DatasetAnalyzer",
|
| 28 |
+
"https://huggingface.co/spaces/awacke1/PrompTart",
|
| 29 |
+
"https://huggingface.co/spaces/awacke1/sileod-deberta-v3-base-tasksource-nli",
|
| 30 |
+
"https://huggingface.co/spaces/awacke1/File-Memory-Operations-Human-Feedback-Gradio",
|
| 31 |
+
"https://huggingface.co/spaces/awacke1/Bloom.Big.Science.Continual.Generator",
|
| 32 |
+
"https://huggingface.co/spaces/awacke1/Ontology-Gradio",
|
| 33 |
+
"https://huggingface.co/spaces/awacke1/HTML5-Aframe-3dMap-Flight",
|
| 34 |
+
"https://huggingface.co/spaces/awacke1/Bloom.Generative.Writer",
|
| 35 |
+
"https://huggingface.co/spaces/awacke1/Voice-ChatGPT-Streamlit-12",
|
| 36 |
+
"https://huggingface.co/spaces/awacke1/HTML5-AR-VR",
|
| 37 |
+
"https://huggingface.co/spaces/awacke1/AnimationAI",
|
| 38 |
+
"https://huggingface.co/spaces/awacke1/GenerativeWordsandImages",
|
| 39 |
+
"https://huggingface.co/spaces/awacke1/AR-VR-IOT-Demo",
|
| 40 |
+
"https://huggingface.co/spaces/awacke1/ArtStyleFoodsandNutrition",
|
| 41 |
+
"https://huggingface.co/spaces/awacke1/CarePlanQnAWithContext",
|
| 42 |
+
"https://huggingface.co/spaces/awacke1/VideoSummaryYoutube3",
|
| 43 |
+
"https://huggingface.co/spaces/awacke1/AW-01ST-CSV-Dataset-Analyzer",
|
| 44 |
+
"https://huggingface.co/spaces/awacke1/Try.Playing.Learning.Sharing.On.This",
|
| 45 |
+
"https://huggingface.co/spaces/awacke1/google-flan-t5-base",
|
| 46 |
+
"https://huggingface.co/spaces/awacke1/PubMed-Parrot-Paraphraser-on-T5",
|
| 47 |
+
"https://huggingface.co/spaces/awacke1/Writing-Grammar-And-Paraphrase-w-Pegasus",
|
| 48 |
+
"https://huggingface.co/spaces/awacke1/runwayml-stable-diffusion-v1-5",
|
| 49 |
+
"https://huggingface.co/spaces/awacke1/DockerGoFlanT5",
|
| 50 |
+
"https://huggingface.co/spaces/awacke1/GradioContinualGenerator",
|
| 51 |
+
"https://huggingface.co/spaces/awacke1/StreamlitSuperPowerCheatSheet"
|
| 52 |
+
]
|
| 53 |
+
|
| 54 |
+
# Extract the last part of each URL (after the last '/') to serve as the name of the button
|
| 55 |
+
url_names = [url.split('/')[-1] for url in urls]
|
| 56 |
+
|
| 57 |
+
# Associate each URL with a relevant emoji based on keywords in its name
|
| 58 |
+
emoji_mapping = {
|
| 59 |
+
"Chatbot": "π€",
|
| 60 |
+
"TTS": "π£οΈ",
|
| 61 |
+
"STT": "π",
|
| 62 |
+
"Video": "π₯",
|
| 63 |
+
"MovieMaker": "πΏ",
|
| 64 |
+
"ChatGPT": "π¬",
|
| 65 |
+
"Voice": "ποΈ",
|
| 66 |
+
"Wikipedia": "π",
|
| 67 |
+
"Memory": "π§ ",
|
| 68 |
+
"AI": "π§ ",
|
| 69 |
+
"OpenAssistant": "π€",
|
| 70 |
+
"3D": "πΆοΈ",
|
| 71 |
+
"AR": "π",
|
| 72 |
+
"VR": "πΆοΈ",
|
| 73 |
+
"Animation": "ποΈ",
|
| 74 |
+
"Dataset": "π",
|
| 75 |
+
"Gradio": "π»",
|
| 76 |
+
"HTML5": "π",
|
| 77 |
+
"Writing": "βοΈ",
|
| 78 |
+
"Grammar": "ποΈ",
|
| 79 |
+
"Paraphrase": "π",
|
| 80 |
+
"Streamlit": "π "
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
# Map each URL name to its most relevant emoji
|
| 84 |
+
url_emojis = []
|
| 85 |
+
for name in url_names:
|
| 86 |
+
associated_emoji = "π" # Default emoji
|
| 87 |
+
for keyword, emoji in emoji_mapping.items():
|
| 88 |
+
if keyword in name:
|
| 89 |
+
associated_emoji = emoji
|
| 90 |
+
break
|
| 91 |
+
url_emojis.append(associated_emoji)
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def get_emoji(name):
|
| 95 |
+
for key, emoji in emoji_mapping.items():
|
| 96 |
+
if key in name:
|
| 97 |
+
return emoji
|
| 98 |
+
return "π"
|
| 99 |
+
|
| 100 |
+
def load_votes():
|
| 101 |
+
try:
|
| 102 |
+
with open("votes.json", "r") as f:
|
| 103 |
+
return json.load(f)
|
| 104 |
+
except FileNotFoundError:
|
| 105 |
+
return {url: 0 for url in urls}
|
| 106 |
+
|
| 107 |
+
def save_votes(votes):
|
| 108 |
+
with open("votes.json", "w") as f:
|
| 109 |
+
json.dump(votes, f)
|
| 110 |
+
|
| 111 |
+
def main():
|
| 112 |
+
st.set_page_config(layout="wide")
|
| 113 |
+
|
| 114 |
+
if 'current_url' not in st.session_state:
|
| 115 |
+
st.session_state.current_url = None
|
| 116 |
+
|
| 117 |
+
votes = load_votes()
|
| 118 |
+
|
| 119 |
+
# Create two columns
|
| 120 |
+
col1, col2 = st.columns([1, 2])
|
| 121 |
+
|
| 122 |
+
with col1:
|
| 123 |
+
# Create sorted list of items
|
| 124 |
+
items = [{"url": url, "name": url.split('/')[-1],
|
| 125 |
+
"emoji": get_emoji(url.split('/')[-1]),
|
| 126 |
+
"votes": votes[url]} for url in urls]
|
| 127 |
+
items.sort(key=lambda x: (-x["votes"], x["name"]))
|
| 128 |
+
|
| 129 |
+
# Display buttons in 2 columns within col1
|
| 130 |
+
button_cols = st.columns(2)
|
| 131 |
+
for i, item in enumerate(items):
|
| 132 |
+
with button_cols[i % 2]:
|
| 133 |
+
if st.button(f"{item['emoji']} {item['name']}", key=item['url']):
|
| 134 |
+
votes[item['url']] += 1
|
| 135 |
+
save_votes(votes)
|
| 136 |
+
st.session_state.current_url = item['url']
|
| 137 |
+
st.rerun()
|
| 138 |
+
st.write(f"Votes: {item['votes']}")
|
| 139 |
+
|
| 140 |
+
with col2:
|
| 141 |
+
if st.session_state.current_url:
|
| 142 |
+
st.components.iframe(st.session_state.current_url, height=800, scrolling=True)
|
| 143 |
+
else:
|
| 144 |
+
st.write("Select an app to view")
|
| 145 |
+
|
| 146 |
+
# Display vote graph at bottom of col1
|
| 147 |
+
if any(votes.values()):
|
| 148 |
+
with col1:
|
| 149 |
+
source = ColumnDataSource({
|
| 150 |
+
'names': [i["name"] for i in items if votes[i["url"]] > 0],
|
| 151 |
+
'votes': [i["votes"] for i in items if votes[i["url"]] > 0]
|
| 152 |
+
})
|
| 153 |
+
p = figure(x_range=source.data['names'], height=250, title="Vote Counts")
|
| 154 |
+
p.vbar(x='names', top='votes', width=0.9, source=source)
|
| 155 |
+
p.xaxis.major_label_orientation = 1.2
|
| 156 |
+
st.bokeh_chart(p)
|
| 157 |
+
|
| 158 |
+
if __name__ == "__main__":
|
| 159 |
+
main()
|