diff --git a/app/components/chat.tsx b/app/components/chat.tsx
index 3d519dee7..b45d36f95 100644
--- a/app/components/chat.tsx
+++ b/app/components/chat.tsx
@@ -1815,6 +1815,7 @@ function _Chat() {
{message?.tools?.map((tool) => (
{tool.isError === false ? (
diff --git a/app/store/chat.ts b/app/store/chat.ts
index 968d8cb64..931cad768 100644
--- a/app/store/chat.ts
+++ b/app/store/chat.ts
@@ -37,6 +37,7 @@ export type ChatMessageTool = {
};
content?: string;
isError?: boolean;
+ errorMsg?: string;
};
export type ChatMessage = RequestMessage & {
diff --git a/app/utils.ts b/app/utils.ts
index 95880115a..83bcea5c0 100644
--- a/app/utils.ts
+++ b/app/utils.ts
@@ -322,8 +322,10 @@ export function adapter(config: Record) {
: path;
return fetch(fetchUrl as string, { ...rest, responseType: "text" }).then(
(res) => {
- const { status, headers } = res;
- return res.text().then((data) => ({ status, headers, data }));
+ const { status, headers, statusText } = res;
+ return res
+ .text()
+ .then((data: string) => ({ status, statusText, headers, data }));
},
);
}
diff --git a/app/utils/chat.ts b/app/utils/chat.ts
index 3d7960480..46f232638 100644
--- a/app/utils/chat.ts
+++ b/app/utils/chat.ts
@@ -222,10 +222,7 @@ export function stream(
),
)
.then((res) => {
- let content = res.data;
- try {
- content = JSON.stringify(res.data);
- } catch (e) {}
+ let content = res.data || res?.statusText;
if (res.status >= 300) {
return Promise.reject(content);
}
@@ -240,7 +237,11 @@ export function stream(
return content;
})
.catch((e) => {
- options?.onAfterTool?.({ ...tool, isError: true });
+ options?.onAfterTool?.({
+ ...tool,
+ isError: true,
+ errorMsg: e.toString(),
+ });
return e.toString();
})
.then((content) => ({