Update app.py
Browse files
app.py
CHANGED
@@ -133,10 +133,9 @@ def get_llm_response(prompt: str, model_name: str = "meta-llama/Llama-2-7b-chat-
|
|
133 |
return answer
|
134 |
|
135 |
############################################
|
136 |
-
# Gradio Interface
|
137 |
############################################
|
138 |
|
139 |
-
|
140 |
with gr.Blocks() as demo:
|
141 |
gr.Markdown("# RepoChat - Chat with Repository Files")
|
142 |
|
@@ -145,7 +144,7 @@ with gr.Blocks() as demo:
|
|
145 |
gr.Markdown("### Repository Information")
|
146 |
github_url_input = gr.Textbox(label="GitHub Repository URL", placeholder="https://github.com/username/repository")
|
147 |
load_repo_btn = gr.Button("Load Repository Contents")
|
148 |
-
# Initialize dropdown with empty choices and
|
149 |
file_dropdown = gr.Dropdown(label="Select a File", interactive=True, value="", choices=[])
|
150 |
repo_content_output = gr.Textbox(label="File Content", interactive=False, lines=10)
|
151 |
with gr.Column(scale=2):
|
@@ -171,12 +170,12 @@ with gr.Blocks() as demo:
|
|
171 |
# Callback to update the file dropdown.
|
172 |
def update_file_dropdown(github_url):
|
173 |
files = load_repo_contents_backend(github_url)
|
174 |
-
if isinstance(files, str): #
|
175 |
print("Error loading files:", files)
|
176 |
-
return gr.
|
177 |
print("Files loaded:", files)
|
178 |
-
#
|
179 |
-
return gr.
|
180 |
|
181 |
load_repo_btn.click(fn=update_file_dropdown, inputs=[github_url_input], outputs=[file_dropdown])
|
182 |
|
|
|
133 |
return answer
|
134 |
|
135 |
############################################
|
136 |
+
# Gradio Interface Setup
|
137 |
############################################
|
138 |
|
|
|
139 |
with gr.Blocks() as demo:
|
140 |
gr.Markdown("# RepoChat - Chat with Repository Files")
|
141 |
|
|
|
144 |
gr.Markdown("### Repository Information")
|
145 |
github_url_input = gr.Textbox(label="GitHub Repository URL", placeholder="https://github.com/username/repository")
|
146 |
load_repo_btn = gr.Button("Load Repository Contents")
|
147 |
+
# Initialize dropdown with empty choices and empty default value.
|
148 |
file_dropdown = gr.Dropdown(label="Select a File", interactive=True, value="", choices=[])
|
149 |
repo_content_output = gr.Textbox(label="File Content", interactive=False, lines=10)
|
150 |
with gr.Column(scale=2):
|
|
|
170 |
# Callback to update the file dropdown.
|
171 |
def update_file_dropdown(github_url):
|
172 |
files = load_repo_contents_backend(github_url)
|
173 |
+
if isinstance(files, str): # Error message case.
|
174 |
print("Error loading files:", files)
|
175 |
+
return gr.update(choices=[], value="")
|
176 |
print("Files loaded:", files)
|
177 |
+
# Return the updated dropdown with choices but with no default value selected.
|
178 |
+
return gr.update(choices=files, value="")
|
179 |
|
180 |
load_repo_btn.click(fn=update_file_dropdown, inputs=[github_url_input], outputs=[file_dropdown])
|
181 |
|