Compare commits
2 commits
16d88e951b
...
c19a161a62
| Author | SHA1 | Date | |
|---|---|---|---|
| c19a161a62 | |||
|
|
7956bf4873 |
1 changed files with 10 additions and 4 deletions
|
|
@ -448,7 +448,7 @@ class WebResearcher:
|
||||||
|
|
||||||
response = self.client.messages.create(
|
response = self.client.messages.create(
|
||||||
model=self.model_id,
|
model=self.model_id,
|
||||||
max_tokens=4096,
|
max_tokens=16384,
|
||||||
messages=[{"role": "user", "content": prompt}],
|
messages=[{"role": "user", "content": prompt}],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -457,6 +457,7 @@ class WebResearcher:
|
||||||
|
|
||||||
# Parse the JSON response
|
# Parse the JSON response
|
||||||
raw_text = response.content[0].text.strip()
|
raw_text = response.content[0].text.strip()
|
||||||
|
stop_reason = response.stop_reason
|
||||||
# Strip markdown fences if the model added them despite instructions
|
# Strip markdown fences if the model added them despite instructions
|
||||||
if raw_text.startswith("```"):
|
if raw_text.startswith("```"):
|
||||||
raw_text = raw_text.split("\n", 1)[1] if "\n" in raw_text else raw_text[3:]
|
raw_text = raw_text.split("\n", 1)[1] if "\n" in raw_text else raw_text[3:]
|
||||||
|
|
@ -465,11 +466,16 @@ class WebResearcher:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = json.loads(raw_text)
|
data = json.loads(raw_text)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError as parse_err:
|
||||||
trace.log_step(
|
trace.log_step(
|
||||||
"synthesis_error",
|
"synthesis_error",
|
||||||
decision="Failed to parse synthesis JSON, returning fallback",
|
decision=(
|
||||||
raw_response=raw_text[:1000],
|
f"Failed to parse synthesis JSON ({parse_err}); "
|
||||||
|
f"stop_reason={stop_reason}"
|
||||||
|
),
|
||||||
|
stop_reason=stop_reason,
|
||||||
|
parse_error=str(parse_err),
|
||||||
|
raw_response=raw_text,
|
||||||
)
|
)
|
||||||
return self._fallback_result(
|
return self._fallback_result(
|
||||||
question, evidence, trace, total_tokens, iterations,
|
question, evidence, trace, total_tokens, iterations,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue