hover show errorMsg when plugin run error
This commit is contained in:
parent
9c577ad9d5
commit
919ee51dca
|
@ -1815,6 +1815,7 @@ function _Chat() {
|
|||
{message?.tools?.map((tool) => (
|
||||
<div
|
||||
key={tool.id}
|
||||
title={tool?.errorMsg}
|
||||
className={styles["chat-message-tool"]}
|
||||
>
|
||||
{tool.isError === false ? (
|
||||
|
|
|
@ -37,6 +37,7 @@ export type ChatMessageTool = {
|
|||
};
|
||||
content?: string;
|
||||
isError?: boolean;
|
||||
errorMsg?: string;
|
||||
};
|
||||
|
||||
export type ChatMessage = RequestMessage & {
|
||||
|
|
|
@ -322,8 +322,10 @@ export function adapter(config: Record<string, unknown>) {
|
|||
: 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 }));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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) => ({
|
||||
|
|
Loading…
Reference in New Issue