naman1102 commited on
Commit
10a33ac
·
1 Parent(s): b0690d0
Files changed (2) hide show
  1. analyzer.py +8 -1
  2. app.py +10 -8
analyzer.py CHANGED
@@ -14,9 +14,16 @@ def analyze_code(code: str) -> str:
14
  "Return your response strictly in JSON format with the following keys: "
15
  "'strength', 'weaknesses', 'speciality', 'relevance rating'. "
16
  "Do not include any other text outside the JSON."
 
 
 
 
 
 
 
17
  )
18
  response = client.chat.completions.create(
19
- model="gpt-4-1106-preview", # GPT-4.1 mini
20
  messages=[
21
  {"role": "system", "content": system_prompt},
22
  {"role": "user", "content": code}
 
14
  "Return your response strictly in JSON format with the following keys: "
15
  "'strength', 'weaknesses', 'speciality', 'relevance rating'. "
16
  "Do not include any other text outside the JSON."
17
+ "the reply should just be the following format:"
18
+ "{"
19
+ " 'strength': '...', "
20
+ " 'weaknesses': '...', "
21
+ " 'speciality': '...', "
22
+ " 'relevance rating': '...'"
23
+ "}"
24
  )
25
  response = client.chat.completions.create(
26
+ model="gpt-4o-mini", # GPT-4.1 mini
27
  messages=[
28
  {"role": "system", "content": system_prompt},
29
  {"role": "user", "content": code}
app.py CHANGED
@@ -7,6 +7,9 @@ from hf_utils import download_space_repo
7
 
8
  # from hf_utils import download_space_repo
9
 
 
 
 
10
  def process_repo_input(text):
11
  if not text:
12
  return pd.DataFrame(columns=["repo id", "strength", "weaknesses", "speciality", "relevance rating"])
@@ -20,7 +23,7 @@ def process_repo_input(text):
20
  for repo_id in repo_ids:
21
  writer.writerow([repo_id, "", "", "", ""])
22
  # Read the CSV into a DataFrame to display
23
- df = pd.read_csv(csv_filename)
24
  return df
25
 
26
  # Store the last entered repo ids and the current index in global variables for button access
@@ -42,7 +45,7 @@ def process_repo_input_and_store(text):
42
  writer.writerow(["repo id", "strength", "weaknesses", "speciality", "relevance rating"])
43
  for repo_id in repo_ids:
44
  writer.writerow([repo_id, "", "", "", ""])
45
- df = pd.read_csv(csv_filename)
46
  return df
47
 
48
  def show_combined_repo_and_llm():
@@ -50,18 +53,18 @@ def show_combined_repo_and_llm():
50
  if not last_repo_ids:
51
  return "No repo ID available. Please submit repo IDs first.", "", pd.DataFrame()
52
  if current_repo_idx >= len(last_repo_ids):
53
- return "All repo IDs have been processed.", "", pd.read_csv("repo_ids.csv")
54
  repo_id = last_repo_ids[current_repo_idx]
55
  try:
56
  download_space_repo(repo_id, local_dir="repo_files")
57
  except Exception as e:
58
- return f"Error downloading repo: {e}", "", pd.read_csv("repo_ids.csv")
59
  txt_path = combine_repo_files_for_llm()
60
  try:
61
  with open(txt_path, "r", encoding="utf-8") as f:
62
  combined_content = f.read()
63
  except Exception as e:
64
- return f"Error reading {txt_path}: {e}", "", pd.read_csv("repo_ids.csv")
65
  llm_output = analyze_combined_file(txt_path)
66
  llm_json = parse_llm_json_response(llm_output)
67
  # Update CSV for the current repo id
@@ -70,8 +73,7 @@ def show_combined_repo_and_llm():
70
  strengths = ""
71
  weaknesses = ""
72
  try:
73
- df = pd.read_csv(csv_filename)
74
- # Cast columns to string to avoid dtype issues
75
  for col in ["strength", "weaknesses", "speciality", "relevance rating"]:
76
  df[col] = df[col].astype(str)
77
  for idx, row in df.iterrows():
@@ -89,7 +91,7 @@ def show_combined_repo_and_llm():
89
  break
90
  df.to_csv(csv_filename, index=False)
91
  except Exception as e:
92
- df = pd.read_csv(csv_filename)
93
  extraction_status = f"CSV update error: {e}"
94
  # Move to next repo for next click
95
  current_repo_idx += 1
 
7
 
8
  # from hf_utils import download_space_repo
9
 
10
+ def read_csv_as_text(csv_filename):
11
+ return pd.read_csv(csv_filename, dtype=str)
12
+
13
  def process_repo_input(text):
14
  if not text:
15
  return pd.DataFrame(columns=["repo id", "strength", "weaknesses", "speciality", "relevance rating"])
 
23
  for repo_id in repo_ids:
24
  writer.writerow([repo_id, "", "", "", ""])
25
  # Read the CSV into a DataFrame to display
26
+ df = read_csv_as_text(csv_filename)
27
  return df
28
 
29
  # Store the last entered repo ids and the current index in global variables for button access
 
45
  writer.writerow(["repo id", "strength", "weaknesses", "speciality", "relevance rating"])
46
  for repo_id in repo_ids:
47
  writer.writerow([repo_id, "", "", "", ""])
48
+ df = read_csv_as_text(csv_filename)
49
  return df
50
 
51
  def show_combined_repo_and_llm():
 
53
  if not last_repo_ids:
54
  return "No repo ID available. Please submit repo IDs first.", "", pd.DataFrame()
55
  if current_repo_idx >= len(last_repo_ids):
56
+ return "All repo IDs have been processed.", "", read_csv_as_text("repo_ids.csv")
57
  repo_id = last_repo_ids[current_repo_idx]
58
  try:
59
  download_space_repo(repo_id, local_dir="repo_files")
60
  except Exception as e:
61
+ return f"Error downloading repo: {e}", "", read_csv_as_text("repo_ids.csv")
62
  txt_path = combine_repo_files_for_llm()
63
  try:
64
  with open(txt_path, "r", encoding="utf-8") as f:
65
  combined_content = f.read()
66
  except Exception as e:
67
+ return f"Error reading {txt_path}: {e}", "", read_csv_as_text("repo_ids.csv")
68
  llm_output = analyze_combined_file(txt_path)
69
  llm_json = parse_llm_json_response(llm_output)
70
  # Update CSV for the current repo id
 
73
  strengths = ""
74
  weaknesses = ""
75
  try:
76
+ df = read_csv_as_text(csv_filename)
 
77
  for col in ["strength", "weaknesses", "speciality", "relevance rating"]:
78
  df[col] = df[col].astype(str)
79
  for idx, row in df.iterrows():
 
91
  break
92
  df.to_csv(csv_filename, index=False)
93
  except Exception as e:
94
+ df = read_csv_as_text(csv_filename)
95
  extraction_status = f"CSV update error: {e}"
96
  # Move to next repo for next click
97
  current_repo_idx += 1