heaversm commited on
Commit
65ef3b6
·
1 Parent(s): 486ca8a

User specified username, repo, and file type selector. Need to deal with access token

Browse files
Files changed (1) hide show
  1. github_st.py +14 -4
github_st.py CHANGED
@@ -11,10 +11,8 @@ load_dotenv()
11
 
12
  #get the GITHUB_ACCESS_TOKEN from the .env file
13
  GITHUB_ACCESS_TOKEN = os.getenv("GITHUB_ACCESS_TOKEN")
14
- USER = "heaversm"
15
- REPO = "gdrive-docker"
16
  GITHUB_BASE_URL = "https://github.com/"
17
- FILE_TYPES_TO_LOAD = (".py", ".ts")
18
 
19
  @st.cache_resource
20
  def get_hugging_face_model():
@@ -32,6 +30,16 @@ def get_similar_files(query, db, embeddings):
32
 
33
 
34
  st.title("Find Similar Code")
 
 
 
 
 
 
 
 
 
 
35
  text_input = st.text_area("Enter a Code Example", value =
36
  """
37
  def create_app():
@@ -43,6 +51,8 @@ def create_app():
43
  )
44
 
45
  button = st.button("Find Similar Code")
 
 
46
  if button:
47
  loader = GithubFileLoader(
48
  #repo is USER/REPO
@@ -50,7 +60,7 @@ if button:
50
  access_token=GITHUB_ACCESS_TOKEN,
51
  github_api_url="https://api.github.com",
52
  file_filter=lambda file_path: file_path.endswith(
53
- FILE_TYPES_TO_LOAD
54
  )
55
  )
56
  documents = loader.load()
 
11
 
12
  #get the GITHUB_ACCESS_TOKEN from the .env file
13
  GITHUB_ACCESS_TOKEN = os.getenv("GITHUB_ACCESS_TOKEN")
 
 
14
  GITHUB_BASE_URL = "https://github.com/"
15
+
16
 
17
  @st.cache_resource
18
  def get_hugging_face_model():
 
30
 
31
 
32
  st.title("Find Similar Code")
33
+
34
+ #streamlit text input for USER
35
+ USER = st.text_input("Enter the Github User", value = "heaversm")
36
+ #streamlit text input for REPO
37
+ REPO = st.text_input("Enter the Github Repository", value = "gdrive-docker")
38
+
39
+ #streamlit file type selector
40
+ FILE_TYPES_TO_LOAD = st.multiselect("Select File Types", [".py", ".ts",".js",".css",".html"], default = [".py"])
41
+
42
+
43
  text_input = st.text_area("Enter a Code Example", value =
44
  """
45
  def create_app():
 
51
  )
52
 
53
  button = st.button("Find Similar Code")
54
+
55
+
56
  if button:
57
  loader = GithubFileLoader(
58
  #repo is USER/REPO
 
60
  access_token=GITHUB_ACCESS_TOKEN,
61
  github_api_url="https://api.github.com",
62
  file_filter=lambda file_path: file_path.endswith(
63
+ tuple(FILE_TYPES_TO_LOAD)
64
  )
65
  )
66
  documents = loader.load()