-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRepoRadar.py
47 lines (34 loc) · 1.57 KB
/
RepoRadar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import asyncio
import streamlit as st
from User import get_repos
from Opensource import get_projects
from Chroma import recommend
from linkpreview import link_preview
def get_link_preview(url):
preview = link_preview(url)
return preview.title, preview.description, preview.image
st.title('🦜🔗 RepoRadar')
prompt = st.text_input('Enter your GitHub username')
with st.expander("Enter your OpenAI API key for better recommendations"):
api_key = st.text_input("API Key", type="password")
if prompt:
if st.button("Generate Recommendations"):
status_placeholder = st.empty()
status_placeholder.text('Crawling your repositories...')
user_details, languages_topics = get_repos(prompt)
status_placeholder.text('Crawling open source projects...')
unique_repos = asyncio.run(get_projects(languages_topics))
status_placeholder.text('Generating recommendations...')
if api_key:
urls = recommend(user_details, unique_repos, api_key)
else:
urls = recommend(user_details, unique_repos)
status_placeholder.empty()
with st.expander("Recommended Projects"):
for url in urls:
if url:
title, description, image = get_link_preview(url)
if image:
st.markdown(f'[<img src="{image}" width="300" align="center"/>]({url})', unsafe_allow_html=True)
else:
st.markdown(f'[{title}]({url})', unsafe_allow_html=True)