adowu commited on
Commit
41a6f7c
1 Parent(s): c5a8b0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -7,6 +7,14 @@ import requests
7
  GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
8
  g = Github(GITHUB_TOKEN)
9
 
 
 
 
 
 
 
 
 
10
 
11
  def github_tool(
12
  action: str,
@@ -242,6 +250,11 @@ def github_tool(
242
  "ostatnia aktualizacja": repo.updated_at
243
  }
244
  return info # Zwraca słownik z informacjami
 
 
 
 
 
245
 
246
  else:
247
  raise ValueError(f"Nieznana akcja: {action}")
@@ -260,7 +273,7 @@ with gr.Blocks() as demo:
260
  "create_repository",
261
  "create_file",
262
  "get_file",
263
- "get_file_content_by_url", # Dodana akcja
264
  "delete_file",
265
  "update_file",
266
  "list_branches",
@@ -278,7 +291,8 @@ with gr.Blocks() as demo:
278
  "fork_repository",
279
  "list_forks",
280
  "list_files",
281
- "get_repository_info", # Dodana akcja
 
282
  ],
283
  label="Akcja",
284
  )
 
7
  GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
8
  g = Github(GITHUB_TOKEN)
9
 
10
+ def get_file_content(owner, repo_name, path, branch="main"):
11
+ url = f"https://raw.githubusercontent.com/{owner}/{repo_name}/{branch}/{path}"
12
+ response = requests.get(url)
13
+ if response.status_code == 200:
14
+ return response.text
15
+ else:
16
+ return f"Błąd pobierania pliku: {response.status_code}"
17
+
18
 
19
  def github_tool(
20
  action: str,
 
250
  "ostatnia aktualizacja": repo.updated_at
251
  }
252
  return info # Zwraca słownik z informacjami
253
+
254
+ elif action == "get_file_content": # Dodana akcja
255
+ if not all([owner, repo_name, path]):
256
+ raise ValueError("Brakujące parametry: owner, repo_name, path")
257
+ return get_file_content(owner, repo_name, path, branch)
258
 
259
  else:
260
  raise ValueError(f"Nieznana akcja: {action}")
 
273
  "create_repository",
274
  "create_file",
275
  "get_file",
276
+ "get_file_content_by_url",
277
  "delete_file",
278
  "update_file",
279
  "list_branches",
 
291
  "fork_repository",
292
  "list_forks",
293
  "list_files",
294
+ "get_repository_info",
295
+ "get_file_content", # Dodana akcja
296
  ],
297
  label="Akcja",
298
  )