mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-23 06:04:46 +08:00
fix:catch toolCalls doesn't return validate json (#405)
Co-authored-by: Willem Jiang <143703838+willem-bd@users.noreply.github.com>
This commit is contained in:
@@ -22,12 +22,20 @@ export const Link = ({
|
|||||||
|
|
||||||
(toolCalls || []).forEach((call) => {
|
(toolCalls || []).forEach((call) => {
|
||||||
if (call && call.name === "web_search" && call.result) {
|
if (call && call.name === "web_search" && call.result) {
|
||||||
const result = JSON.parse(call.result) as Array<{ url: string }>;
|
try {
|
||||||
result.forEach((r) => {
|
const result = JSON.parse(call.result) as Array<{ url: string }>;
|
||||||
// encodeURI is used to handle the case where the link contains chinese or other special characters
|
if (Array.isArray(result)) {
|
||||||
links.add(encodeURI(r.url));
|
result.forEach((r) => {
|
||||||
links.add(r.url);
|
if (r && typeof r.url === 'string') {
|
||||||
});
|
// encodeURI is used to handle the case where the link contains chinese or other special characters
|
||||||
|
links.add(encodeURI(r.url));
|
||||||
|
links.add(r.url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Failed to parse web_search result:', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return links;
|
return links;
|
||||||
|
|||||||
Reference in New Issue
Block a user