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) => (
|
{message?.tools?.map((tool) => (
|
||||||
<div
|
<div
|
||||||
key={tool.id}
|
key={tool.id}
|
||||||
|
title={tool?.errorMsg}
|
||||||
className={styles["chat-message-tool"]}
|
className={styles["chat-message-tool"]}
|
||||||
>
|
>
|
||||||
{tool.isError === false ? (
|
{tool.isError === false ? (
|
||||||
|
|
|
@ -37,6 +37,7 @@ export type ChatMessageTool = {
|
||||||
};
|
};
|
||||||
content?: string;
|
content?: string;
|
||||||
isError?: boolean;
|
isError?: boolean;
|
||||||
|
errorMsg?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ChatMessage = RequestMessage & {
|
export type ChatMessage = RequestMessage & {
|
||||||
|
|
|
@ -322,8 +322,10 @@ export function adapter(config: Record<string, unknown>) {
|
||||||
: path;
|
: path;
|
||||||
return fetch(fetchUrl as string, { ...rest, responseType: "text" }).then(
|
return fetch(fetchUrl as string, { ...rest, responseType: "text" }).then(
|
||||||
(res) => {
|
(res) => {
|
||||||
const { status, headers } = res;
|
const { status, headers, statusText } = res;
|
||||||
return res.text().then((data) => ({ status, headers, data }));
|
return res
|
||||||
|
.text()
|
||||||
|
.then((data: string) => ({ status, statusText, headers, data }));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,10 +222,7 @@ export function stream(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
let content = res.data;
|
let content = res.data || res?.statusText;
|
||||||
try {
|
|
||||||
content = JSON.stringify(res.data);
|
|
||||||
} catch (e) {}
|
|
||||||
if (res.status >= 300) {
|
if (res.status >= 300) {
|
||||||
return Promise.reject(content);
|
return Promise.reject(content);
|
||||||
}
|
}
|
||||||
|
@ -240,7 +237,11 @@ export function stream(
|
||||||
return content;
|
return content;
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
options?.onAfterTool?.({ ...tool, isError: true });
|
options?.onAfterTool?.({
|
||||||
|
...tool,
|
||||||
|
isError: true,
|
||||||
|
errorMsg: e.toString(),
|
||||||
|
});
|
||||||
return e.toString();
|
return e.toString();
|
||||||
})
|
})
|
||||||
.then((content) => ({
|
.then((content) => ({
|
||||||
|
|
Loading…
Reference in New Issue