Spaces:
Sleeping
Sleeping
Upload get_stack.py
Browse files- get_stack.py +34 -0
get_stack.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import google.generativeai as genai
|
| 3 |
+
|
| 4 |
+
genai.configure(api_key=os.environ['GOOGLE_API_KEY'])
|
| 5 |
+
llm = genai.GenerativeModel('gemini-pro')
|
| 6 |
+
|
| 7 |
+
def get_folder_paths(directory = "githubCode"):
|
| 8 |
+
folder_paths = []
|
| 9 |
+
for root, dirs, files in os.walk(directory):
|
| 10 |
+
if '.git' in dirs:
|
| 11 |
+
# Skip the directory if a .git folder is found
|
| 12 |
+
dirs.remove('.git')
|
| 13 |
+
for dir_name in dirs:
|
| 14 |
+
folder_paths.append(os.path.join(root, dir_name))
|
| 15 |
+
return folder_paths
|
| 16 |
+
|
| 17 |
+
directory_paths = get_folder_paths()
|
| 18 |
+
|
| 19 |
+
files = []
|
| 20 |
+
|
| 21 |
+
for directory_path in directory_paths:
|
| 22 |
+
for filename in os.listdir(directory_path):
|
| 23 |
+
if filename.endswith((".py",".js", ".ts")):
|
| 24 |
+
filepath = os.path.join(directory_path, filename)
|
| 25 |
+
with open(filepath, "r", encoding='utf-8') as file:
|
| 26 |
+
files.append(filepath)
|
| 27 |
+
|
| 28 |
+
def get_techstack():
|
| 29 |
+
print(files)
|
| 30 |
+
prompt= f"the files used in a project are these {files}. Based on this data, generate a file structure of this project."
|
| 31 |
+
response = llm.generate_content(prompt)
|
| 32 |
+
return response.text
|
| 33 |
+
|
| 34 |
+
techStack = get_techstack()
|