Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -69,7 +69,6 @@ class MyChatbot(gr.Chatbot):
|
|
69 |
}
|
70 |
]
|
71 |
|
72 |
-
# Update the Blocks implementation
|
73 |
with gr.Blocks() as demo:
|
74 |
with gr.Row():
|
75 |
github_api_token = gr.Textbox(label="GitHub API Token", type="password")
|
@@ -108,36 +107,40 @@ with gr.Blocks() as demo:
|
|
108 |
# Create state for storing conversation history
|
109 |
state = gr.State([])
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
|
|
|
|
141 |
user,
|
142 |
[msg, chatbot],
|
143 |
[msg, chatbot]
|
@@ -159,56 +162,37 @@ with gr.Blocks() as demo:
|
|
159 |
[chatbot]
|
160 |
)
|
161 |
|
162 |
-
# Add
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
)
|
176 |
|
177 |
-
#
|
178 |
-
issue_dropdown = gr.Dropdown(label="Select Issue", choices=[], interactive=True)
|
179 |
-
|
180 |
-
def select_issue(selected, chatbot):
|
181 |
-
"""Handle issue selection"""
|
182 |
-
if selected:
|
183 |
-
issue_num = int(selected.split('.')[0]) - 1
|
184 |
-
chatbot.current_issue = chatbot.issues[issue_num]
|
185 |
-
return chatbot.postprocess({
|
186 |
-
'command': str(issue_num + 1),
|
187 |
-
'github_api_token': github_api_token.value,
|
188 |
-
'github_username': github_username.value,
|
189 |
-
'github_repository': github_repository.value,
|
190 |
-
'selected_model': model_dropdown.value,
|
191 |
-
'severity': severity_dropdown.value,
|
192 |
-
'programming_language': programming_language_textbox.value
|
193 |
-
})
|
194 |
-
return []
|
195 |
-
|
196 |
issue_dropdown.change(
|
197 |
select_issue,
|
198 |
inputs=[issue_dropdown, chatbot],
|
199 |
outputs=[chatbot]
|
200 |
)
|
201 |
|
202 |
-
#
|
203 |
-
resolve_issue_button = gr.Button(label="Resolve Issue")
|
204 |
-
|
205 |
-
def resolve_selected_issue(api_token, username, repo, resolution):
|
206 |
-
"""Resolve the currently selected issue"""
|
207 |
-
if chatbot.current_issue:
|
208 |
-
issue_number = chatbot.issues.index(chatbot.current_issue)
|
209 |
-
return resolve_issue(api_token, username, repo, issue_number, resolution)
|
210 |
-
return "No issue selected"
|
211 |
-
|
212 |
resolve_issue_button.click(
|
213 |
resolve_selected_issue,
|
214 |
inputs=[
|
|
|
69 |
}
|
70 |
]
|
71 |
|
|
|
72 |
with gr.Blocks() as demo:
|
73 |
with gr.Row():
|
74 |
github_api_token = gr.Textbox(label="GitHub API Token", type="password")
|
|
|
107 |
# Create state for storing conversation history
|
108 |
state = gr.State([])
|
109 |
|
110 |
+
# Add buttons with correct syntax
|
111 |
+
fetch_issues_button = gr.Button("Fetch Issues")
|
112 |
+
resolve_issue_button = gr.Button("Resolve Issue")
|
113 |
+
clear_button = gr.Button("Clear Chat")
|
114 |
+
submit_button = gr.Button("Submit Message")
|
115 |
|
116 |
+
# Add a dropdown to select an issue
|
117 |
+
issue_dropdown = gr.Dropdown(
|
118 |
+
choices=[],
|
119 |
+
label="Select Issue",
|
120 |
+
interactive=True
|
121 |
+
)
|
122 |
+
|
123 |
+
def clear_chat():
|
124 |
+
return [], []
|
125 |
+
|
126 |
+
def fetch_issues(api_token, username, repo):
|
127 |
+
issues = fetch_github_issues(api_token, username, repo)
|
128 |
+
chatbot.issues = issues
|
129 |
+
return gr.Dropdown(choices=[f"{i+1}. {issue['title']}" for i, issue in enumerate(issues)])
|
130 |
+
|
131 |
+
# Connect button events
|
132 |
+
fetch_issues_button.click(
|
133 |
+
fetch_issues,
|
134 |
+
inputs=[github_api_token, github_username, github_repository],
|
135 |
+
outputs=[issue_dropdown]
|
136 |
+
)
|
137 |
+
|
138 |
+
clear_button.click(
|
139 |
+
clear_chat,
|
140 |
+
outputs=[chatbot, state]
|
141 |
+
)
|
142 |
+
|
143 |
+
submit_button.click(
|
144 |
user,
|
145 |
[msg, chatbot],
|
146 |
[msg, chatbot]
|
|
|
162 |
[chatbot]
|
163 |
)
|
164 |
|
165 |
+
# Add message input handler
|
166 |
+
msg.submit(
|
167 |
+
user,
|
168 |
+
[msg, chatbot],
|
169 |
+
[msg, chatbot]
|
170 |
+
).then(
|
171 |
+
bot,
|
172 |
+
[
|
173 |
+
chatbot,
|
174 |
+
system_message,
|
175 |
+
gr.Slider(minimum=1, maximum=8192, value=2048, step=1, label="Max new tokens"),
|
176 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.71, step=0.1, label="Temperature"),
|
177 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.01, label="Top-p"),
|
178 |
+
github_api_token,
|
179 |
+
github_username,
|
180 |
+
github_repository,
|
181 |
+
model_dropdown,
|
182 |
+
severity_dropdown,
|
183 |
+
programming_language_textbox
|
184 |
+
],
|
185 |
+
[chatbot]
|
186 |
)
|
187 |
|
188 |
+
# Issue selection handler
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
issue_dropdown.change(
|
190 |
select_issue,
|
191 |
inputs=[issue_dropdown, chatbot],
|
192 |
outputs=[chatbot]
|
193 |
)
|
194 |
|
195 |
+
# Issue resolution handler
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
resolve_issue_button.click(
|
197 |
resolve_selected_issue,
|
198 |
inputs=[
|