jyo01 commited on
Commit
bb6fa93
·
verified ·
1 Parent(s): 9f42960

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -166,6 +166,7 @@ def get_file_content_for_choice(github_url: str, file_choice: int):
166
  content = get_file_content(owner, repo, selected_file)
167
  return content, selected_file
168
 
 
169
  def chat_with_file(github_url: str, file_choice: int, user_query: str):
170
  result = get_file_content_for_choice(github_url, file_choice)
171
  if isinstance(result, str):
@@ -193,7 +194,7 @@ with gr.Blocks() as demo:
193
  github_url_input = gr.Textbox(label="GitHub Repository URL", placeholder="https://github.com/username/repository")
194
  load_repo_btn = gr.Button("Load Repository Contents")
195
  # Set allow_custom_value=True to avoid errors when the selected value is not in the choices.
196
- file_dropdown = gr.Dropdown(label="Select a File", interactive=True, allow_custom_value=True)
197
  repo_content_output = gr.Textbox(label="File Content", interactive=False, lines=10)
198
  with gr.Column(scale=2):
199
  gr.Markdown("### Chat Interface")
@@ -218,8 +219,12 @@ with gr.Blocks() as demo:
218
  file_index = int(file_choice)
219
  except:
220
  file_index = 1
221
- content, _ = get_file_content_for_choice(github_url, file_index)
 
 
 
222
  return content
 
223
 
224
  file_dropdown.change(fn=update_repo_content, inputs=[github_url_input, file_dropdown], outputs=[repo_content_output])
225
 
 
166
  content = get_file_content(owner, repo, selected_file)
167
  return content, selected_file
168
 
169
+
170
  def chat_with_file(github_url: str, file_choice: int, user_query: str):
171
  result = get_file_content_for_choice(github_url, file_choice)
172
  if isinstance(result, str):
 
194
  github_url_input = gr.Textbox(label="GitHub Repository URL", placeholder="https://github.com/username/repository")
195
  load_repo_btn = gr.Button("Load Repository Contents")
196
  # Set allow_custom_value=True to avoid errors when the selected value is not in the choices.
197
+ file_dropdown = gr.Dropdown(label="Select a File", interactive=True) # Remove allow_custom_value=True
198
  repo_content_output = gr.Textbox(label="File Content", interactive=False, lines=10)
199
  with gr.Column(scale=2):
200
  gr.Markdown("### Chat Interface")
 
219
  file_index = int(file_choice)
220
  except:
221
  file_index = 1
222
+ # Debug: print file_choice and file_index
223
+ print(f"Selected file index: {file_index}")
224
+ content, selected_file = get_file_content_for_choice(github_url, file_index)
225
+ print(f"Selected file: {selected_file}")
226
  return content
227
+
228
 
229
  file_dropdown.change(fn=update_repo_content, inputs=[github_url_input, file_dropdown], outputs=[repo_content_output])
230