Erpg12 commited on
Commit
5373208
·
1 Parent(s): f257ac1

feat: use larger model

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -11,8 +11,8 @@ from transformers import (
11
  # ▸ For a causal code model (no T5 errors):
12
  # MODEL_ID = "Salesforce/codegen-350M-multi"
13
  # ▸ Or, for a seq‑to‑seq model:
14
- # MODEL_ID = "google/flan-t5-base"
15
- MODEL_ID = "google/flan-t5-small"
16
  # MODEL_ID = "Salesforce/codegen-350M-multi"
17
 
18
  # ── 2) Load tokenizer + model ────────────────────────────────────────
@@ -46,10 +46,17 @@ def review_code(diff: str, guidelines: str):
46
  f"DIFF:\n{diff}\n\n"
47
  f"GUIDELINES:\n{guidelines}\n\n"
48
  "OUTPUT FORMAT EXAMPLE:\n"
49
- '[{"line":12,"comment":"…"}]\n'
 
50
  )
51
 
 
52
  out = pipe(prompt)[0]["generated_text"]
 
 
 
 
 
53
  start = out.find("[")
54
  end = out.rfind("]") + 1
55
  if start < 0 or end < 0:
 
11
  # ▸ For a causal code model (no T5 errors):
12
  # MODEL_ID = "Salesforce/codegen-350M-multi"
13
  # ▸ Or, for a seq‑to‑seq model:
14
+ MODEL_ID = "google/flan-t5-base"
15
+ # MODEL_ID = "google/flan-t5-small"
16
  # MODEL_ID = "Salesforce/codegen-350M-multi"
17
 
18
  # ── 2) Load tokenizer + model ────────────────────────────────────────
 
46
  f"DIFF:\n{diff}\n\n"
47
  f"GUIDELINES:\n{guidelines}\n\n"
48
  "OUTPUT FORMAT EXAMPLE:\n"
49
+ '[{"line":12,"comment":"…"}]\n\n'
50
+ "<<<END_JSON>>>\n"
51
  )
52
 
53
+ # Run the model
54
  out = pipe(prompt)[0]["generated_text"]
55
+
56
+ # Truncate at our stop marker, if present
57
+ if "<<<END_JSON>>>" in out:
58
+ out = out.split("<<<END_JSON>>>")[0]
59
+
60
  start = out.find("[")
61
  end = out.rfind("]") + 1
62
  if start < 0 or end < 0: