Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import streamlit as st
|
| 3 |
+
|
| 4 |
+
@st.cache_data(ttl=3600) # Cache the data for 1 hour
|
| 5 |
+
def fetch_readme_content():
|
| 6 |
+
try:
|
| 7 |
+
url = "https://raw.githubusercontent.com/EthicalML/awesome-production-machine-learning/main/README.md"
|
| 8 |
+
response = requests.get(url, timeout=30)
|
| 9 |
+
response.raise_for_status() # Raises HTTPError for bad responses
|
| 10 |
+
return response.text
|
| 11 |
+
except requests.exceptions.RequestException as e:
|
| 12 |
+
st.error(f"Failed to fetch README.md content: {e}")
|
| 13 |
+
return ""
|
| 14 |
+
|
| 15 |
+
class SearchApplication:
|
| 16 |
+
def __init__(self):
|
| 17 |
+
self.title = "Foundation Model Leaderboard Search"
|
| 18 |
+
self.set_page_config()
|
| 19 |
+
|
| 20 |
+
st.header(self.title)
|
| 21 |
+
self.query = st.text_input("Search", value="")
|
| 22 |
+
|
| 23 |
+
st.caption(
|
| 24 |
+
"This search toolkit is a user-friendly platform that enables efficient exploration and filtering of the comprehensive [Awesome Production Machine Learning](https://github.com/EthicalML/awesome-production-machine-learning) list, which includes over 500 machine learning development kits, making it an indispensable resource for researchers, developers, and enthusiasts in the field."
|
| 25 |
+
)
|
| 26 |
+
st.write("#")
|
| 27 |
+
|
| 28 |
+
self.show_search_results()
|
| 29 |
+
|
| 30 |
+
def set_page_config(self):
|
| 31 |
+
st.set_page_config(
|
| 32 |
+
page_title=self.title,
|
| 33 |
+
page_icon="😎",
|
| 34 |
+
layout="centered",
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
def show_search_results(self):
|
| 38 |
+
if self.query:
|
| 39 |
+
st.write("#")
|
| 40 |
+
|
| 41 |
+
readme_content = fetch_readme_content()
|
| 42 |
+
|
| 43 |
+
if readme_content:
|
| 44 |
+
search_results = []
|
| 45 |
+
lines = readme_content.split("\n")
|
| 46 |
+
for line in lines:
|
| 47 |
+
if self.query.lower() in line.lower():
|
| 48 |
+
search_results.append(line)
|
| 49 |
+
|
| 50 |
+
num_search_results = len(search_results)
|
| 51 |
+
st.write(f"A total of {num_search_results} matches found.")
|
| 52 |
+
|
| 53 |
+
if num_search_results > 0:
|
| 54 |
+
for result in search_results:
|
| 55 |
+
st.write(result)
|
| 56 |
+
else:
|
| 57 |
+
st.write("No matches found.")
|
| 58 |
+
|
| 59 |
+
if __name__ == "__main__":
|
| 60 |
+
SearchApplication()
|