Parcourir la source

Fix incorrect exception reference for `json.dumps()` (#24329)

Co-authored-by: Yongtao Huang <99629139+hyongtao-db@users.noreply.github.com>
tags/1.8.0
Yongtao Huang il y a 2 mois
Parent
révision
1d09708eb7
Aucun compte lié à l'adresse e-mail de l'auteur
2 fichiers modifiés avec 5 ajouts et 5 suppressions
  1. 1
    1
      api/core/agent/cot_agent_runner.py
  2. 4
    4
      api/core/agent/fc_agent_runner.py

+ 1
- 1
api/core/agent/cot_agent_runner.py Voir le fichier

@@ -197,7 +197,7 @@ class CotAgentRunner(BaseAgentRunner, ABC):
final_answer = scratchpad.action.action_input
else:
final_answer = f"{scratchpad.action.action_input}"
except json.JSONDecodeError:
except TypeError:
final_answer = f"{scratchpad.action.action_input}"
else:
function_call_state = True

+ 4
- 4
api/core/agent/fc_agent_runner.py Voir le fichier

@@ -126,8 +126,8 @@ class FunctionCallAgentRunner(BaseAgentRunner):
tool_call_inputs = json.dumps(
{tool_call[1]: tool_call[2] for tool_call in tool_calls}, ensure_ascii=False
)
except json.JSONDecodeError:
# ensure ascii to avoid encoding error
except TypeError:
# fallback: force ASCII to handle non-serializable objects
tool_call_inputs = json.dumps({tool_call[1]: tool_call[2] for tool_call in tool_calls})

if chunk.delta.message and chunk.delta.message.content:
@@ -153,8 +153,8 @@ class FunctionCallAgentRunner(BaseAgentRunner):
tool_call_inputs = json.dumps(
{tool_call[1]: tool_call[2] for tool_call in tool_calls}, ensure_ascii=False
)
except json.JSONDecodeError:
# ensure ascii to avoid encoding error
except TypeError:
# fallback: force ASCII to handle non-serializable objects
tool_call_inputs = json.dumps({tool_call[1]: tool_call[2] for tool_call in tool_calls})

if result.usage:

Chargement…
Annuler
Enregistrer