fix: chat error message
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ const isProduction = env === 'production';
|
|||||||
const t = Date.now();
|
const t = Date.now();
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
proxy: {
|
proxy: {
|
||||||
...proxy()
|
...proxy('http://192.168.50.166:8080')
|
||||||
},
|
},
|
||||||
history: {
|
history: {
|
||||||
type: 'hash'
|
type: 'hash'
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const AutoTooltip: React.FC<AutoTooltipProps> = ({
|
|||||||
const { scrollWidth, clientWidth } = contentRef.current;
|
const { scrollWidth, clientWidth } = contentRef.current;
|
||||||
setIsOverflowing(scrollWidth > clientWidth);
|
setIsOverflowing(scrollWidth > clientWidth);
|
||||||
}
|
}
|
||||||
}, []);
|
}, [contentRef.current]);
|
||||||
|
|
||||||
const debouncedCheckOverflow = useMemo(
|
const debouncedCheckOverflow = useMemo(
|
||||||
() => debounce(checkOverflow, 200),
|
() => debounce(checkOverflow, 200),
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
height: 68px;
|
height: 68px;
|
||||||
|
|
||||||
|
.cell-content {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
&-left {
|
&-left {
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const list = _.filter(fileList, (file: any) => {
|
const list = _.filter(fileList, (file: any) => {
|
||||||
return filterReg.test(file.path) || _.includes(includeReg, file.path);
|
return filterRegGGUF.test(file.path) || _.includes(file.path, '.gguf');
|
||||||
});
|
});
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@@ -160,9 +160,7 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
const fileList = _.filter(_.get(data, ['Data', 'Files']), (file: any) => {
|
const fileList = _.filter(_.get(data, ['Data', 'Files']), (file: any) => {
|
||||||
return (
|
return filterRegGGUF.test(file.Path) || _.includes(file.Path, '.gguf');
|
||||||
filterRegGGUF.test(file.Path) || _.includes(filterRegGGUF, file.Path)
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const list = _.map(fileList, (item: any) => {
|
const list = _.map(fileList, (item: any) => {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import AutoTooltip from '@/components/auto-tooltip';
|
||||||
import DeleteModal from '@/components/delete-modal';
|
import DeleteModal from '@/components/delete-modal';
|
||||||
import DropdownButtons from '@/components/drop-down-buttons';
|
import DropdownButtons from '@/components/drop-down-buttons';
|
||||||
import IconFont from '@/components/icon-font';
|
import IconFont from '@/components/icon-font';
|
||||||
@@ -518,8 +519,10 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
span={5}
|
span={5}
|
||||||
render={(text, record: ListItem) => {
|
render={(text, record: ListItem) => {
|
||||||
return (
|
return (
|
||||||
<span>
|
<span className="flex" style={{ maxWidth: '100%' }}>
|
||||||
<span className="m-r-5">{text}</span>
|
<AutoTooltip className="m-r-5" showTitle={true} ghost>
|
||||||
|
{text}
|
||||||
|
</AutoTooltip>
|
||||||
<span>
|
<span>
|
||||||
{record.embedding_only && (
|
{record.embedding_only && (
|
||||||
<Tag style={{ marginTop: 6 }} color="geekblue">
|
<Tag style={{ marginTop: 6 }} color="geekblue">
|
||||||
|
|||||||
@@ -172,13 +172,17 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
...parameters,
|
...parameters,
|
||||||
stream: true
|
stream: true
|
||||||
};
|
};
|
||||||
const result = await fetchChunkedData({
|
const result: any = await fetchChunkedData({
|
||||||
data: chatParams,
|
data: chatParams,
|
||||||
url: CHAT_API,
|
url: CHAT_API,
|
||||||
signal
|
signal
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!result) {
|
if (result?.error) {
|
||||||
|
setTokenResult({
|
||||||
|
error: true,
|
||||||
|
errorMessage: result?.data?.message
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setMessageId();
|
setMessageId();
|
||||||
@@ -186,10 +190,9 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
await readStreamData(reader, decoder, (chunk: any) => {
|
await readStreamData(reader, decoder, (chunk: any) => {
|
||||||
joinMessage(chunk);
|
joinMessage(chunk);
|
||||||
});
|
});
|
||||||
setLoading(false);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('error=====', error);
|
// console.log('error:', error);
|
||||||
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,9 +15,15 @@ interface ActiveModelsProps {
|
|||||||
const ActiveModels: React.FC<ActiveModelsProps> = (props) => {
|
const ActiveModels: React.FC<ActiveModelsProps> = (props) => {
|
||||||
const { spans, modelSelections, setModelRefs } = props;
|
const { spans, modelSelections, setModelRefs } = props;
|
||||||
return (
|
return (
|
||||||
<Row gutter={[16, 16]} style={{ height: '100%' }}>
|
<Row gutter={[16, 0]} style={{ height: '100%' }}>
|
||||||
{modelSelections.map((model, index) => (
|
{modelSelections.map((model, index) => (
|
||||||
<Col span={spans.span} key={`${model.value || 'empty'}-${model.uid}`}>
|
<Col
|
||||||
|
span={spans.span}
|
||||||
|
key={`${model.value || 'empty'}-${model.uid}`}
|
||||||
|
style={{
|
||||||
|
height: spans.count < 4 ? 'calc(100% - 16px)' : 'calc(50% - 16px)'
|
||||||
|
}}
|
||||||
|
>
|
||||||
<ModelItem
|
<ModelItem
|
||||||
key={`${model.value || 'empty'}-${model.uid}`}
|
key={`${model.value || 'empty'}-${model.uid}`}
|
||||||
ref={(el: React.MutableRefObject<any>) =>
|
ref={(el: React.MutableRefObject<any>) =>
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ const ModelItem: React.FC<ModelItemProps> = forwardRef(
|
|||||||
const currentMessageRef = useRef<MessageItem[]>([]);
|
const currentMessageRef = useRef<MessageItem[]>([]);
|
||||||
const modelScrollRef = useRef<any>(null);
|
const modelScrollRef = useRef<any>(null);
|
||||||
|
|
||||||
const { initialize } = useOverlayScroller();
|
const { initialize, updateScrollerPosition } = useOverlayScroller();
|
||||||
|
|
||||||
const setMessageId = () => {
|
const setMessageId = () => {
|
||||||
messageId.current = messageId.current + 1;
|
messageId.current = messageId.current + 1;
|
||||||
@@ -180,13 +180,17 @@ const ModelItem: React.FC<ModelItemProps> = forwardRef(
|
|||||||
stream: true
|
stream: true
|
||||||
};
|
};
|
||||||
// ============== payload end ================
|
// ============== payload end ================
|
||||||
const result = await fetchChunkedData({
|
const result: any = await fetchChunkedData({
|
||||||
data: chatParams,
|
data: chatParams,
|
||||||
url: CHAT_API,
|
url: CHAT_API,
|
||||||
signal
|
signal
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!result) {
|
if (result?.error) {
|
||||||
|
setTokenResult({
|
||||||
|
error: true,
|
||||||
|
errorMessage: result?.data?.message
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setMessageId();
|
setMessageId();
|
||||||
@@ -194,8 +198,9 @@ const ModelItem: React.FC<ModelItemProps> = forwardRef(
|
|||||||
await readStreamData(reader, decoder, (chunk: any) => {
|
await readStreamData(reader, decoder, (chunk: any) => {
|
||||||
joinMessage(chunk);
|
joinMessage(chunk);
|
||||||
});
|
});
|
||||||
setLoadingStatus(instanceId, false);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// console.log('error:', error);
|
||||||
|
} finally {
|
||||||
setLoadingStatus(instanceId, false);
|
setLoadingStatus(instanceId, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -338,6 +343,10 @@ const ModelItem: React.FC<ModelItemProps> = forwardRef(
|
|||||||
}
|
}
|
||||||
}, [modelScrollRef.current, initialize]);
|
}, [modelScrollRef.current, initialize]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
updateScrollerPosition();
|
||||||
|
}, [messageList]);
|
||||||
|
|
||||||
useImperativeHandle(ref, () => {
|
useImperativeHandle(ref, () => {
|
||||||
return {
|
return {
|
||||||
submit: handleSubmit,
|
submit: handleSubmit,
|
||||||
@@ -415,11 +424,7 @@ const ModelItem: React.FC<ModelItemProps> = forwardRef(
|
|||||||
applyToAll={handleApplySystemChangeToAll}
|
applyToAll={handleApplySystemChangeToAll}
|
||||||
setSystemMessage={setSystemMessage}
|
setSystemMessage={setSystemMessage}
|
||||||
></SystemMessage>
|
></SystemMessage>
|
||||||
<div
|
<div className="content" ref={modelScrollRef}>
|
||||||
className="content"
|
|
||||||
ref={modelScrollRef}
|
|
||||||
style={{ maxHeight: maxHeight }}
|
|
||||||
>
|
|
||||||
<div>
|
<div>
|
||||||
<MessageContent
|
<MessageContent
|
||||||
spans={spans}
|
spans={spans}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
|
import { WarningOutlined } from '@ant-design/icons';
|
||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Space, Tooltip } from 'antd';
|
import { Alert, Space, Tooltip } from 'antd';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import '../style/reference-params.less';
|
import '../style/reference-params.less';
|
||||||
|
|
||||||
interface ReferenceParamsProps {
|
interface ReferenceParamsProps {
|
||||||
usage: {
|
usage: {
|
||||||
|
error?: boolean;
|
||||||
|
errorMessage?: string;
|
||||||
completion_tokens: number;
|
completion_tokens: number;
|
||||||
prompt_tokens: number;
|
prompt_tokens: number;
|
||||||
total_tokens: number;
|
total_tokens: number;
|
||||||
@@ -17,10 +20,25 @@ interface ReferenceParamsProps {
|
|||||||
const ReferenceParams = (props: ReferenceParamsProps) => {
|
const ReferenceParams = (props: ReferenceParamsProps) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const { usage } = props;
|
const { usage } = props;
|
||||||
if (!usage) {
|
if (!usage || _.isEmpty(usage)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
console.log('ReferenceParams usage:', usage);
|
if (usage.error) {
|
||||||
|
return (
|
||||||
|
<Alert
|
||||||
|
type="error"
|
||||||
|
style={{ textAlign: 'center', paddingBlock: 0 }}
|
||||||
|
message={
|
||||||
|
<span style={{ color: 'var(--ant-color-error)' }}>
|
||||||
|
<WarningOutlined className="m-r-8" />
|
||||||
|
{usage?.errorMessage}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
banner
|
||||||
|
showIcon={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div className="reference-params">
|
<div className="reference-params">
|
||||||
<span className="usage">
|
<span className="usage">
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
.chat-list {
|
.chat-list {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding-bottom: 16px;
|
|
||||||
padding-inline: var(--layout-content-inlinepadding);
|
padding-inline: var(--layout-content-inlinepadding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,10 @@ export const fetchChunkedData = async (params: {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Network response was not ok');
|
return {
|
||||||
return null;
|
error: true,
|
||||||
|
data: await response.json()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
const reader = response?.body?.getReader();
|
const reader = response?.body?.getReader();
|
||||||
const decoder = new TextDecoder('utf-8');
|
const decoder = new TextDecoder('utf-8');
|
||||||
|
|||||||
Reference in New Issue
Block a user