style: playground collapse button
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { createFromIconfontCN } from '@ant-design/icons';
|
import { createFromIconfontCN } from '@ant-design/icons';
|
||||||
|
|
||||||
const IconFont = createFromIconfontCN({
|
const IconFont = createFromIconfontCN({
|
||||||
scriptUrl: '//at.alicdn.com/t/c/font_4613488_68kh94h3e2r.js'
|
scriptUrl: '//at.alicdn.com/t/c/font_4613488_cpb5yo1pk77.js'
|
||||||
});
|
});
|
||||||
|
|
||||||
export default IconFont;
|
export default IconFont;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { listFiles } from '@huggingface/hub';
|
import { listFiles, listModels } from '@huggingface/hub';
|
||||||
import { request } from '@umijs/max';
|
import { request } from '@umijs/max';
|
||||||
import {
|
import {
|
||||||
FormData,
|
FormData,
|
||||||
@@ -116,6 +116,23 @@ export async function callHuggingfaceQuickSearch(params: any) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function queryHuggingfaceModels(params: {
|
||||||
|
search: {
|
||||||
|
query: string;
|
||||||
|
tags: string[];
|
||||||
|
};
|
||||||
|
}) {
|
||||||
|
const result = [];
|
||||||
|
for await (const model of listModels({
|
||||||
|
...params,
|
||||||
|
limit: 100,
|
||||||
|
additionalFields: ['author']
|
||||||
|
})) {
|
||||||
|
result.push(model);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
export async function queryHuggingfaceModelFiles(params: { repo: string }) {
|
export async function queryHuggingfaceModelFiles(params: { repo: string }) {
|
||||||
const result = [];
|
const result = [];
|
||||||
for await (const fileInfo of listFiles(params)) {
|
for await (const fileInfo of listFiles(params)) {
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ import { useIntl } from '@umijs/max';
|
|||||||
import { Form, Input, Modal } from 'antd';
|
import { Form, Input, Modal } from 'antd';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { memo, useEffect, useState } from 'react';
|
import { memo, useEffect, useState } from 'react';
|
||||||
import {
|
import { queryHuggingfaceModelFiles, queryHuggingfaceModels } from '../apis';
|
||||||
callHuggingfaceQuickSearch,
|
|
||||||
queryHuggingfaceModelFiles
|
|
||||||
} from '../apis';
|
|
||||||
import { ollamaModelOptions } from '../config';
|
import { ollamaModelOptions } from '../config';
|
||||||
import { FormData, ListItem } from '../config/types';
|
import { FormData, ListItem } from '../config/types';
|
||||||
|
|
||||||
@@ -106,14 +103,17 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
const handleOnSearchRepo = async (text: string) => {
|
const handleOnSearchRepo = async (text: string) => {
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
q: `${text}`,
|
search: {
|
||||||
type: 'model'
|
query: text,
|
||||||
|
tags: ['gguf']
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const res = await callHuggingfaceQuickSearch(params);
|
const models = await queryHuggingfaceModels(params);
|
||||||
const list = _.map(res.models || [], (item: any) => {
|
const list = _.map(models || [], (item: any) => {
|
||||||
return {
|
return {
|
||||||
value: item.id,
|
...item,
|
||||||
label: item.id
|
value: item.name,
|
||||||
|
label: item.name
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
setRepoOptions(list);
|
setRepoOptions(list);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ const ChatFooter: React.FC<ChatFooterProps> = (props) => {
|
|||||||
style={{ textAlign: 'right' }}
|
style={{ textAlign: 'right' }}
|
||||||
>
|
>
|
||||||
<Space size={20}>
|
<Space size={20}>
|
||||||
<Button
|
{/* <Button
|
||||||
icon={
|
icon={
|
||||||
<IconFont type="icon-code" className="font-size-16"></IconFont>
|
<IconFont type="icon-code" className="font-size-16"></IconFont>
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ const ChatFooter: React.FC<ChatFooterProps> = (props) => {
|
|||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
{intl.formatMessage({ id: 'playground.viewcode' })}
|
{intl.formatMessage({ id: 'playground.viewcode' })}
|
||||||
</Button>
|
</Button> */}
|
||||||
{!disabled ? (
|
{!disabled ? (
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
|||||||
@@ -6,7 +6,13 @@ import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons';
|
|||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Button, Input, Spin, Tooltip } from 'antd';
|
import { Button, Input, Spin, Tooltip } from 'antd';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import {
|
||||||
|
forwardRef,
|
||||||
|
useEffect,
|
||||||
|
useImperativeHandle,
|
||||||
|
useRef,
|
||||||
|
useState
|
||||||
|
} from 'react';
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
import { CHAT_API } from '../apis';
|
import { CHAT_API } from '../apis';
|
||||||
import { Roles } from '../config';
|
import { Roles } from '../config';
|
||||||
@@ -19,6 +25,7 @@ import ViewCodeModal from './view-code-modal';
|
|||||||
|
|
||||||
interface MessageProps {
|
interface MessageProps {
|
||||||
parameters: any;
|
parameters: any;
|
||||||
|
ref?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MessageItemProps {
|
interface MessageItemProps {
|
||||||
@@ -27,7 +34,7 @@ interface MessageItemProps {
|
|||||||
uid: number;
|
uid: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MessageList: React.FC<MessageProps> = (props) => {
|
const MessageList: React.FC<MessageProps> = forwardRef((props, ref) => {
|
||||||
const { parameters } = props;
|
const { parameters } = props;
|
||||||
const messageId = useRef<number>(0);
|
const messageId = useRef<number>(0);
|
||||||
const [messageList, setMessageList] = useState<MessageItemProps[]>([
|
const [messageList, setMessageList] = useState<MessageItemProps[]>([
|
||||||
@@ -59,6 +66,13 @@ const MessageList: React.FC<MessageProps> = (props) => {
|
|||||||
updateScrollerPosition();
|
updateScrollerPosition();
|
||||||
}, [messageList]);
|
}, [messageList]);
|
||||||
|
|
||||||
|
useImperativeHandle(ref, () => {
|
||||||
|
return {
|
||||||
|
viewCode() {
|
||||||
|
setShow(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
const handleSystemMessageChange = (e: any) => {
|
const handleSystemMessageChange = (e: any) => {
|
||||||
setSystemMessage(e.target.value);
|
setSystemMessage(e.target.value);
|
||||||
};
|
};
|
||||||
@@ -301,6 +315,6 @@ const MessageList: React.FC<MessageProps> = (props) => {
|
|||||||
></ViewCodeModal>
|
></ViewCodeModal>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
export default MessageList;
|
export default MessageList;
|
||||||
|
|||||||
@@ -1,38 +1,71 @@
|
|||||||
import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
|
import IconFont from '@/components/icon-font';
|
||||||
import { PageContainer } from '@ant-design/pro-components';
|
import { PageContainer } from '@ant-design/pro-components';
|
||||||
import { useSearchParams } from '@umijs/max';
|
import { useIntl, useSearchParams } from '@umijs/max';
|
||||||
import { Button, Divider } from 'antd';
|
import { Button, Divider } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
import GroundLeft from './components/ground-left';
|
import GroundLeft from './components/ground-left';
|
||||||
import ParamsSettings from './components/params-settings';
|
import ParamsSettings from './components/params-settings';
|
||||||
import './style/play-ground.less';
|
import './style/play-ground.less';
|
||||||
|
|
||||||
const Playground: React.FC = () => {
|
const Playground: React.FC = () => {
|
||||||
|
const intl = useIntl();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const selectModel = searchParams.get('model') || '';
|
const selectModel = searchParams.get('model') || '';
|
||||||
const [params, setParams] = useState({});
|
const [params, setParams] = useState({});
|
||||||
const [collapse, setCollapse] = useState(false);
|
const [collapse, setCollapse] = useState(false);
|
||||||
|
const groundLeftRef = useRef<any>(null);
|
||||||
|
|
||||||
|
const handleViewCode = () => {
|
||||||
|
groundLeftRef.current?.viewCode?.();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer ghost extra={[]} className="playground-container">
|
<PageContainer
|
||||||
|
ghost
|
||||||
|
extra={[
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
size="middle"
|
||||||
|
onClick={handleViewCode}
|
||||||
|
icon={
|
||||||
|
<IconFont type="icon-code" className="font-size-16"></IconFont>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{intl.formatMessage({ id: 'playground.viewcode' })}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="middle"
|
||||||
|
className="m-l-5"
|
||||||
|
onClick={() => setCollapse(!collapse)}
|
||||||
|
icon={
|
||||||
|
<IconFont
|
||||||
|
type="icon-a-layout6-line"
|
||||||
|
className="font-size-16"
|
||||||
|
></IconFont>
|
||||||
|
}
|
||||||
|
></Button>
|
||||||
|
</>
|
||||||
|
]}
|
||||||
|
className="playground-container"
|
||||||
|
>
|
||||||
<div className="play-ground">
|
<div className="play-ground">
|
||||||
<div className="chat">
|
<div className="chat">
|
||||||
<GroundLeft parameters={params}></GroundLeft>
|
<GroundLeft parameters={params} ref={groundLeftRef}></GroundLeft>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={classNames('left', {
|
className={classNames('left', {
|
||||||
collapse: collapse
|
collapse: collapse
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Button
|
{/* <Button
|
||||||
onClick={() => setCollapse(!collapse)}
|
onClick={() => setCollapse(!collapse)}
|
||||||
icon={collapse ? <MenuFoldOutlined /> : <MenuUnfoldOutlined />}
|
icon={collapse ? <MenuFoldOutlined /> : <MenuUnfoldOutlined />}
|
||||||
style={{ color: 'var(--ant-color-text-tertiary)' }}
|
style={{ color: 'var(--ant-color-text-tertiary)' }}
|
||||||
size="small"
|
size="small"
|
||||||
type="text"
|
type="text"
|
||||||
className="collapse-btn"
|
className="collapse-btn"
|
||||||
></Button>
|
></Button> */}
|
||||||
<div
|
<div
|
||||||
className={classNames('divider-line', {
|
className={classNames('divider-line', {
|
||||||
collapse: collapse
|
collapse: collapse
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
width: 391px;
|
width: 391px;
|
||||||
|
overflow-x: hidden;
|
||||||
|
transition: width 0.3s ease;
|
||||||
|
|
||||||
.collapse-btn {
|
.collapse-btn {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -15,12 +17,9 @@
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
transition: width 0.3s ease;
|
|
||||||
|
|
||||||
&.collapse {
|
&.collapse {
|
||||||
width: 33px;
|
width: 0;
|
||||||
padding-left: 32px;
|
overflow: hidden;
|
||||||
// overflow: hidden;
|
|
||||||
transition: width 0.3s ease;
|
transition: width 0.3s ease;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user