Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,7 @@ def github_tool(
|
|
25 |
labels: str = None, # etykiety oddzielone przecinkami
|
26 |
tag: str = None,
|
27 |
name: str = None, # nazwa release
|
|
|
28 |
):
|
29 |
"""Narz臋dzie do zarz膮dzania repozytoriami GitHub."""
|
30 |
user = g.get_user()
|
@@ -71,8 +72,15 @@ def github_tool(
|
|
71 |
if not all([repo_name, path]):
|
72 |
raise ValueError("Brakuj膮ce parametry: repo_name, path")
|
73 |
repo = user.get_repo(repo_name)
|
74 |
-
file_content = repo.get_contents(path)
|
75 |
-
return file_content.decoded_content.decode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
elif action == "delete_file":
|
78 |
if not all([repo_name, path]):
|
@@ -228,6 +236,7 @@ with gr.Blocks() as demo:
|
|
228 |
"create_repository",
|
229 |
"create_file",
|
230 |
"get_file",
|
|
|
231 |
"delete_file",
|
232 |
"update_file",
|
233 |
"list_branches",
|
@@ -263,6 +272,7 @@ with gr.Blocks() as demo:
|
|
263 |
labels = gr.Textbox(label="Etykiety (oddzielone przecinkami)")
|
264 |
tag = gr.Textbox(label="Tag")
|
265 |
release_name = gr.Textbox(label="Nazwa release") # Zmieniona nazwa
|
|
|
266 |
|
267 |
with gr.Row():
|
268 |
run_button = gr.Button("Wykonaj")
|
@@ -287,6 +297,7 @@ with gr.Blocks() as demo:
|
|
287 |
labels,
|
288 |
tag,
|
289 |
release_name, # U偶ycie zmienionej nazwy
|
|
|
290 |
],
|
291 |
outputs=output,
|
292 |
api_name="github_tool"
|
|
|
25 |
labels: str = None, # etykiety oddzielone przecinkami
|
26 |
tag: str = None,
|
27 |
name: str = None, # nazwa release
|
28 |
+
file_url: str = None, # URL pliku do pobrania
|
29 |
):
|
30 |
"""Narz臋dzie do zarz膮dzania repozytoriami GitHub."""
|
31 |
user = g.get_user()
|
|
|
72 |
if not all([repo_name, path]):
|
73 |
raise ValueError("Brakuj膮ce parametry: repo_name, path")
|
74 |
repo = user.get_repo(repo_name)
|
75 |
+
file_content = repo.get_contents(path, ref=branch)
|
76 |
+
return file_content.decoded_content.decode() # Zdekoduj zawarto艣膰 pliku i zwr贸膰 jako string
|
77 |
+
|
78 |
+
elif action == "get_file_content_by_url":
|
79 |
+
if not file_url:
|
80 |
+
raise ValueError("Brakuj膮cy parametr: file_url")
|
81 |
+
response = requests.get(file_url)
|
82 |
+
response.raise_for_status() # Sprawd藕 czy nie ma b艂臋du HTTP
|
83 |
+
return response.text
|
84 |
|
85 |
elif action == "delete_file":
|
86 |
if not all([repo_name, path]):
|
|
|
236 |
"create_repository",
|
237 |
"create_file",
|
238 |
"get_file",
|
239 |
+
"get_file_content_by_url", # Dodana akcja
|
240 |
"delete_file",
|
241 |
"update_file",
|
242 |
"list_branches",
|
|
|
272 |
labels = gr.Textbox(label="Etykiety (oddzielone przecinkami)")
|
273 |
tag = gr.Textbox(label="Tag")
|
274 |
release_name = gr.Textbox(label="Nazwa release") # Zmieniona nazwa
|
275 |
+
file_url = gr.Textbox(label="URL pliku") # Dodane pole
|
276 |
|
277 |
with gr.Row():
|
278 |
run_button = gr.Button("Wykonaj")
|
|
|
297 |
labels,
|
298 |
tag,
|
299 |
release_name, # U偶ycie zmienionej nazwy
|
300 |
+
file_url, # Dodany argument
|
301 |
],
|
302 |
outputs=output,
|
303 |
api_name="github_tool"
|