miaoyibo commited on
Commit
ad1769a
·
1 Parent(s): 29918c0

update location

Browse files
Files changed (2) hide show
  1. app.py +1 -3
  2. kimi_dev/serve/templates.py +17 -8
app.py CHANGED
@@ -138,7 +138,6 @@ def predict(
138
  raw_answer=post_process(response)
139
  model_found_files = raw_answer.strip().split("\n")
140
 
141
-
142
  files, _, _ = get_full_file_paths_and_classes_and_functions(structure)
143
  model_found_files = [correct_file_path_in_structure(file, structure) for file in model_found_files]
144
  found_files = correct_file_paths(model_found_files, files)
@@ -146,7 +145,6 @@ def predict(
146
  highlight_response = highlight_thinking(response)
147
  yield [[prompt,highlight_response]], [["null test","null test2"]], "Generate: Success"
148
 
149
-
150
  contents = ""
151
  for file_path in found_files:
152
  file_name = file_path.replace("```","")
@@ -337,7 +335,7 @@ if __name__ == "__main__":
337
  print("Start serving vllm...")
338
  script_path = os.path.join(os.path.dirname(__file__), "serve_vllm.sh")
339
  subprocess.Popen(["bash", script_path])
340
- time.sleep(480)
341
  print("Served vllm!")
342
 
343
 
 
138
  raw_answer=post_process(response)
139
  model_found_files = raw_answer.strip().split("\n")
140
 
 
141
  files, _, _ = get_full_file_paths_and_classes_and_functions(structure)
142
  model_found_files = [correct_file_path_in_structure(file, structure) for file in model_found_files]
143
  found_files = correct_file_paths(model_found_files, files)
 
145
  highlight_response = highlight_thinking(response)
146
  yield [[prompt,highlight_response]], [["null test","null test2"]], "Generate: Success"
147
 
 
148
  contents = ""
149
  for file_path in found_files:
150
  file_name = file_path.replace("```","")
 
335
  print("Start serving vllm...")
336
  script_path = os.path.join(os.path.dirname(__file__), "serve_vllm.sh")
337
  subprocess.Popen(["bash", script_path])
338
+ time.sleep(450)
339
  print("Served vllm!")
340
 
341
 
kimi_dev/serve/templates.py CHANGED
@@ -119,15 +119,15 @@ def create_structure(directory_path):
119
  """
120
  structure = {}
121
  for root, _, files in os.walk(directory_path):
122
- repo_name = os.path.basename(directory_path)
123
  relative_root = os.path.relpath(root, directory_path)
124
  if relative_root == ".":
125
- relative_root = repo_name
126
- curr_struct = structure
127
- for part in relative_root.split(os.sep):
128
- if part not in curr_struct:
129
- curr_struct[part] = {}
130
- curr_struct = curr_struct[part]
 
131
  for file_name in files:
132
  if file_name.endswith(".py"):
133
  file_path = os.path.join(root, file_name)
@@ -138,7 +138,16 @@ def create_structure(directory_path):
138
  "text": file_lines,
139
  }
140
  else:
141
- curr_struct[file_name] = {}
 
 
 
 
 
 
 
 
 
142
  return structure
143
 
144
  def build_repo_structure(root_path):
 
119
  """
120
  structure = {}
121
  for root, _, files in os.walk(directory_path):
 
122
  relative_root = os.path.relpath(root, directory_path)
123
  if relative_root == ".":
124
+ curr_struct = structure
125
+ else:
126
+ curr_struct = structure
127
+ for part in relative_root.split(os.sep):
128
+ if part not in curr_struct:
129
+ curr_struct[part] = {}
130
+ curr_struct = curr_struct[part]
131
  for file_name in files:
132
  if file_name.endswith(".py"):
133
  file_path = os.path.join(root, file_name)
 
138
  "text": file_lines,
139
  }
140
  else:
141
+ file_path = os.path.join(root, file_name)
142
+ try:
143
+ with open(file_path, 'r', encoding='utf-8') as f:
144
+ file_content = f.read()
145
+ curr_struct[file_name] = {
146
+ "text": file_content.splitlines()
147
+ }
148
+ except Exception as e:
149
+ print(f"fail to read {file_path}: {e}")
150
+ curr_struct[file_name] = {}
151
  return structure
152
 
153
  def build_repo_structure(root_path):