Spaces:
Sleeping
Sleeping
Commit Β·
e48bc80
1
Parent(s): ff6527e
remove silent fallback in call_model
Browse files- inference.py +23 -33
inference.py
CHANGED
|
@@ -106,39 +106,29 @@ def format_bug(obs) -> str:
|
|
| 106 |
|
| 107 |
|
| 108 |
def call_model(client: OpenAI, bug_text: str) -> TriageAction:
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
)
|
| 133 |
-
except Exception as exc:
|
| 134 |
-
print(f"[DEBUG] model call failed: {exc}", flush=True)
|
| 135 |
-
return TriageAction(
|
| 136 |
-
priority="P2",
|
| 137 |
-
labels=["bug"],
|
| 138 |
-
assigned_team="backend",
|
| 139 |
-
milestone="backlog",
|
| 140 |
-
reasoning="fallback due to model error",
|
| 141 |
-
)
|
| 142 |
|
| 143 |
|
| 144 |
# ββ main ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 106 |
|
| 107 |
|
| 108 |
def call_model(client: OpenAI, bug_text: str) -> TriageAction:
|
| 109 |
+
completion = client.chat.completions.create(
|
| 110 |
+
model=MODEL_NAME,
|
| 111 |
+
messages=[
|
| 112 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
| 113 |
+
{"role": "user", "content": bug_text},
|
| 114 |
+
],
|
| 115 |
+
temperature=TEMPERATURE,
|
| 116 |
+
max_tokens=MAX_TOKENS,
|
| 117 |
+
stream=False,
|
| 118 |
+
)
|
| 119 |
+
raw = (completion.choices[0].message.content or "").strip()
|
| 120 |
+
if raw.startswith("```"):
|
| 121 |
+
raw = raw.split("```")[1]
|
| 122 |
+
if raw.startswith("json"):
|
| 123 |
+
raw = raw[4:]
|
| 124 |
+
data = json.loads(raw)
|
| 125 |
+
return TriageAction(
|
| 126 |
+
priority=data.get("priority", "P2"),
|
| 127 |
+
labels=data.get("labels", ["bug"]),
|
| 128 |
+
assigned_team=data.get("assigned_team", "backend"),
|
| 129 |
+
milestone=data.get("milestone", "backlog"),
|
| 130 |
+
reasoning=data.get("reasoning", ""),
|
| 131 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
|
| 134 |
# ββ main ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|