| | |
| | | "@types/yargs": "^13.0.0" |
| | | } |
| | | }, |
| | | "@microsoft/fetch-event-source": { |
| | | "version": "2.0.1", |
| | | "resolved": "https://registry.npmjs.org/@microsoft/fetch-event-source/-/fetch-event-source-2.0.1.tgz", |
| | | "integrity": "sha512-W6CLUJ2eBMw3Rec70qrsEW0jOm/3twwJv21mrmj2yORiaVmVYGS4sSS5yUwvQc1ZlDLYGPnClVWmUUMagKNsfA==" |
| | | }, |
| | | "@mrmlnc/readdir-enhanced": { |
| | | "version": "2.2.1", |
| | | "resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz", |
| | |
| | | "@antv/x6-plugin-transform": "^2.1.7", |
| | | "@antv/xflow": "^1.0.50", |
| | | "@babel/core": "7.5.5", |
| | | "@microsoft/fetch-event-source": "^2.0.1", |
| | | "@svgr/webpack": "4.3.2", |
| | | "@typescript-eslint/eslint-plugin": "1.13.0", |
| | | "@typescript-eslint/parser": "1.13.0", |
| | |
| | | match: 'like', |
| | | focus: true |
| | | } |
| | | |
| | | if (card.search.length) { |
| | | item.ratio = card.search[card.search.length - 1].ratio |
| | | } |
| | | |
| | | card.search.push(item) |
| | | |
| | | this.setState({card}, () => { |
| | |
| | | let reRequired = {} |
| | | let reReadonly = {} |
| | | |
| | | reTooltip.interface = '' |
| | | reTooltip.proInterface = '正式系统所使用的接口地址。' |
| | | if (['pop', 'prompt', 'exec'].includes(openType)) { |
| | | let intertype = this.record.intertype |
| | | |
| | |
| | | } |
| | | reReadonly.interface = false |
| | | reRequired.interface = true |
| | | reTooltip.interface = `可使用变量@mywebsite@ (域名+虚拟目录)、@mydomain@ (域名),如:@mywebsite@/webapi/dostars 代表 ${window.GLOB.baseurl}webapi/dostars。` |
| | | reTooltip.proInterface += reTooltip.interface |
| | | } else if (intertype === 'outer') { |
| | | shows.push('procMode', 'sysInterface', 'outerFunc', 'callbackType') |
| | | if (this.record.procMode === 'system') { |
| | |
| | | const { config } = this.props |
| | | |
| | | this.setState({loading: true}) |
| | | this.verifyRef.submitDataSource().then(res => { |
| | | this.verifyRef.submitDataSource().then((res, hasMSearch) => { |
| | | |
| | | let MenuType = sessionStorage.getItem('MenuType') |
| | | |
| | |
| | | MKEmitter.emit('mkUpdateInter', {uuid: config.uuid, columns: res.columns}, {delay: 0}) |
| | | }, 150) |
| | | } |
| | | |
| | | if (config.type === 'interface' && res.setting && res.setting.useMSearch === 'true' && !hasMSearch) { |
| | | Modal.warning({ |
| | | title: '数据源中使用了外部搜索,但搜索条件尚未添加!', |
| | | centered: true |
| | | }) |
| | | } |
| | | }, () => { |
| | | this.setState({loading: false}) |
| | | }) |
| | |
| | | |
| | | submitDataSource = () => { |
| | | const { config, mainSearch } = this.props |
| | | const { activeKey, setting, columns, subColumns, scripts, cols, median, searches } = this.state |
| | | const { activeKey, setting, columns, subColumns, scripts, cols, median, searches, hasMainSearch } = this.state |
| | | |
| | | if (config.subtype === 'dualdatacard') { |
| | | let arr = columns.map(col => col.field.toLowerCase()) |
| | |
| | | searches: _searches, |
| | | setting: res |
| | | }, () => { |
| | | this.sqlverify(() => { resolve({setting: res, columns, subColumns, scripts, cols, searches: _searches }) }, reject, 'submit') |
| | | this.sqlverify(() => { resolve({setting: res, columns, subColumns, scripts, cols, searches: _searches }, hasMainSearch) }, reject, 'submit') |
| | | }) |
| | | }, () => { |
| | | reject() |
| | |
| | | reject() |
| | | return |
| | | } |
| | | this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols, searches }) }, reject, 'submit') |
| | | this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols, searches }, hasMainSearch) }, reject, 'submit') |
| | | } else if (activeKey === 'subcolumns') { |
| | | if (this.subdatasource && this.subdatasource.state.editingKey) { |
| | | notification.warning({ |
| | |
| | | reject() |
| | | return |
| | | } |
| | | this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols, searches }) }, reject, 'submit') |
| | | this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols, searches }, hasMainSearch) }, reject, 'submit') |
| | | } else if (activeKey === 'scripts') { |
| | | this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols, searches }) }, reject, 'submit') |
| | | this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols, searches }, hasMainSearch) }, reject, 'submit') |
| | | } |
| | | }) |
| | | } |
| | |
| | | return |
| | | } |
| | | |
| | | let getMsearch = (components) => { |
| | | let val = null |
| | | components.forEach(com => { |
| | | if (com.type !== 'search') return |
| | | |
| | | if (com.wrap && com.wrap.supModule && com.wrap.supModule.length > 0) { |
| | | let supModule = com.wrap.supModule[com.wrap.supModule.length - 1]; |
| | | |
| | | (com.search || []).forEach(item => { |
| | | if (item.type === 'datemonth') { |
| | | if (item.initval && item.dateShift) { |
| | | val = {supModule: supModule, name: com.name} |
| | | } |
| | | } else if (item.type === 'daterange') { |
| | | if (item.initval && item.dateShift) { |
| | | val = {supModule: supModule, name: com.name} |
| | | } |
| | | } else if ((item.type === 'select' || item.type === 'link') && item.resourceType === '1') { |
| | | if (/@BID@/ig.test(item.dataSource)) { |
| | | val = {supModule: supModule, name: com.name} |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | return val |
| | | } |
| | | |
| | | let checkSearch = (components, mSearch) => { |
| | | components.forEach(item => { |
| | | if (error) return |
| | | |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | let _ms = getMsearch(tab.components) |
| | | |
| | | if (_ms) { |
| | | checkSearch(tab.components, _ms) |
| | | } else { |
| | | checkSearch(tab.components, mSearch) |
| | | } |
| | | }) |
| | | return |
| | | } else if (item.type === 'group') { |
| | | checkSearch(item.components, mSearch) |
| | | return |
| | | } else if (!mSearch || !item.setting) { |
| | | return |
| | | } else if (!(item.type === 'table' || (item.type === 'card' && ['datacard', 'dualdatacard'].includes(item.subtype)))) { |
| | | return |
| | | } |
| | | |
| | | if (item.setting.useMSearch === 'true' && item.setting.supModule && item.setting.supModule[0] !== 'empty') { |
| | | let id = item.setting.supModule[item.setting.supModule.length - 1] |
| | | if (mSearch.supModule !== id) { |
| | | error = `${item.name} 使用了外部搜索,但与外部搜索(${mSearch.name})的上级组件不一致。` |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | checkSearch(config.components, getMsearch(config.components)) |
| | | |
| | | if (error) { |
| | | Modal.warning({ |
| | | title: error, |
| | | okText: '知道了' |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.sqlList = [] |
| | | this.linkMain = [] |
| | | |
| | |
| | | } trigger="hover"> |
| | | <ToolOutlined /> |
| | | </Popover> |
| | | <MenuComponent menus={card.menus} columns={card.columns} updateConfig={(menus) => this.updateComponent({...card, menus: menus})}/> |
| | | <MenuComponent menus={card.menus} datatype={card.wrap.datatype} columns={card.columns} updateConfig={(menus) => this.updateComponent({...card, menus: menus})}/> |
| | | </div> |
| | | ) |
| | | } |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { columns } = this.props |
| | | const { columns, datatype } = this.props |
| | | const { menus, visible, editMenu } = this.state |
| | | |
| | | return ( |
| | |
| | | <ElementForm |
| | | menu={editMenu} |
| | | cols={columns} |
| | | datatype={datatype} |
| | | inputSubmit={this.handleSubmit} |
| | | wrappedComponentRef={(inst) => this.menuFormRef = inst} |
| | | /> |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { menu, cols } = this.props |
| | | const { menu, cols, datatype } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { property, appMenus, copyMenu } = this.state |
| | | |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | {datatype === 'dynamic' ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="绑定提示字段后,会在菜单右上角显示提示信息。注:在添加图标时有效。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | </Col> : null} |
| | | <Col span={12}> |
| | | <Form.Item label="隐藏"> |
| | | {getFieldDecorator('hidden', { |
| | |
| | | br { |
| | | content: ""; |
| | | display: block; |
| | | } |
| | | br + br { |
| | | height: 18px; |
| | | } |
| | | hr { |
| | |
| | | padding: 5px 10px; |
| | | font-size: var(--table-font-size, 16px); |
| | | border: 1px solid #ddd; |
| | | |
| | | br:first-of-type { |
| | | height: 0px; |
| | | } |
| | | } |
| | | } |
| | | ul { |
| | |
| | | url = btn.interface |
| | | } |
| | | |
| | | url = url.replace(/@mydomain@/ig, window.GLOB.location) |
| | | |
| | | let param = {} |
| | | |
| | |
| | | this.setState({ |
| | | value: nextProps.config.initval, |
| | | }) |
| | | if (config.linkFields && nextProps.config.initval) { |
| | | config.linkFields.forEach((m, i) => { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkFP', m.uuid, nextProps.config.initval, 0) |
| | | }, (i + 1) * 70) |
| | | }) |
| | | } |
| | | } else if (option && typeof(option.value) !== typeof(value)) { |
| | | if (typeof(option.value) === 'number' && !isNaN(value)) { |
| | | this.setState({ |
| | |
| | | this.setState({ |
| | | value: nextProps.config.initval, |
| | | }) |
| | | if (config.linkFields && nextProps.config.initval) { |
| | | config.linkFields.forEach((m, i) => { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkFP', m.uuid, nextProps.config.initval, 0) |
| | | }, (i + 1) * 70) |
| | | }) |
| | | } |
| | | } else if (option && typeof(option.value) !== typeof(value)) { |
| | | if (typeof(option.value) === 'number' && !isNaN(value)) { |
| | | this.setState({ |
| | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | const { config, BID } = this.props |
| | | |
| | | if (config.checkBid && config.type !== 'search' && nextProps.BID !== BID) { |
| | | if (config.$checkBid && nextProps.BID !== BID) { |
| | | this.resetOptions(nextProps.BID) |
| | | } |
| | | } |
| | |
| | | |
| | | if (cell.OpenType === 'form' && cell.formType === 'count_line') return |
| | | |
| | | if (cell.intertype === 'system') { |
| | | // if (cell.Ot === 'notRequired' && cell.verify && cell.verify.voucher && cell.verify.voucher.enabled) { |
| | | // errors.push({ level: 0, detail: `按钮“${cell.label}”使用了创建凭证函数,需要选择行!`}) |
| | | // } |
| | | } else if (cell.intertype === 'custom' || cell.intertype === 'outer') { |
| | | if (cell.callbackType === 'script' && (!cell.verify || !cell.verify.cbScripts || cell.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) { |
| | | errors.push({ level: 0, detail: `按钮“${cell.label}”使用了自定义脚本回调,回调脚本不可为空!`}) |
| | | // } else if (cell.procMode === 'system' && cell.Ot === 'notRequired' && cell.verify && cell.verify.voucher && cell.verify.voucher.enabled) { |
| | | // errors.push({ level: 0, detail: `按钮“${cell.label}”使用了创建凭证函数,需要选择行!`}) |
| | | // if (cell.intertype === 'system') { |
| | | // // if (cell.Ot === 'notRequired' && cell.verify && cell.verify.voucher && cell.verify.voucher.enabled) { |
| | | // // errors.push({ level: 0, detail: `按钮“${cell.label}”使用了创建凭证函数,需要选择行!`}) |
| | | // // } |
| | | // } else if (cell.intertype === 'custom' || cell.intertype === 'outer') { |
| | | // if (cell.callbackType === 'script' && (!cell.verify || !cell.verify.cbScripts || cell.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) { |
| | | // errors.push({ level: 0, detail: `按钮“${cell.label}”使用了自定义脚本回调,回调脚本不可为空!`}) |
| | | // // } else if (cell.procMode === 'system' && cell.Ot === 'notRequired' && cell.verify && cell.verify.voucher && cell.verify.voucher.enabled) { |
| | | // // errors.push({ level: 0, detail: `按钮“${cell.label}”使用了创建凭证函数,需要选择行!`}) |
| | | // } |
| | | // } |
| | | if ((cell.intertype === 'custom' || cell.intertype === 'outer') && cell.callbackType === 'script') { |
| | | if (!cell.verify || !cell.verify.cbScripts) { |
| | | errors.push({ level: 0, detail: `按钮“${cell.label}”使用了自定义脚本回调,请设置验证信息!`}) |
| | | } |
| | | } |
| | | } else if (cell.OpenType === 'funcbutton') { |
| | |
| | | * @param {Array} searches 搜索条件 |
| | | */ |
| | | static initSearchVal (config) { |
| | | if (!config.search) { |
| | | if (!config.search || config.search.length === 0) { |
| | | config.search = [] |
| | | config.$s_keys = [] |
| | | config.$s_req = false |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | config.checkBid = true |
| | | item.checkShift = true |
| | | if (config.setting) { |
| | | config.setting.checkBid = true |
| | | } |
| | | } |
| | | |
| | | item.initval = '' |
| | |
| | | |
| | | config.checkBid = true |
| | | item.checkShift = true |
| | | if (config.setting) { |
| | | config.setting.checkBid = true |
| | | } |
| | | } |
| | | |
| | | item.initval = '' |
| | |
| | | if (/@BID@/ig.test(item.dataSource) && supModule) { |
| | | config.checkBid = true |
| | | item.checkBid = true |
| | | if (config.setting) { |
| | | config.setting.checkBid = true |
| | | } |
| | | } |
| | | if (item.initval === '$first') { |
| | | item.initval = '' |
| | |
| | | return item |
| | | }) |
| | | |
| | | if (config.checkBid) { |
| | | if (config.setting) { |
| | | config.setting.checkBid = true |
| | | } |
| | | if (config.type !== 'search') { |
| | | config.$checkBid = true |
| | | } |
| | | } |
| | | |
| | | config.$s_keys = keys |
| | | config.$s_req = required |
| | | } |
| | |
| | | } |
| | | |
| | | long_data = [] |
| | | // let oriIds = {} |
| | | // if (config.allSqls) { |
| | | // config.allSqls.forEach(item => { |
| | | // if (!item.md5) return |
| | | // oriIds[item.uuid + item.md5] = item.v_id |
| | | // }) |
| | | // } |
| | | |
| | | let perm = true |
| | | if (config.permission === 'false' || config.sqlperm === 'false') { |
| | | perm = false |
| | |
| | | config.allSqls = sqls.map(item => { |
| | | let v_id = _t + getguid() |
| | | |
| | | // if (oriIds[item.uuid + item.md5]) { |
| | | // v_id = oriIds[item.uuid + item.md5] |
| | | // } |
| | | |
| | | long_data.push(`${md5(window.GLOB.appkey + v_id)},${item.uuid},${v_id},${window.btoa(window.encodeURIComponent(item.LText))},${perm ? item.roleId || '' : ''}`) |
| | | |
| | | return { |
| | |
| | | v_id: v_id, |
| | | type: item.type, |
| | | reps: item.reps, |
| | | // md5: item.md5 || '', |
| | | luser: item.luser === true |
| | | } |
| | | }) |
| | |
| | | import { LoadingOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons' |
| | | // import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter' |
| | | // import { dark } from 'react-syntax-highlighter/dist/esm/styles/prism' |
| | | import { fetchEventSource } from '@microsoft/fetch-event-source' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | |
| | | message.success('复制成功。') |
| | | } |
| | | |
| | | // eslint-disable-next-line |
| | | // let html = marked(item.content, { |
| | | // highlight: (code, language) => { |
| | | // // 通过时间戳生成唯一标识 |
| | | // const codeIndex = parseInt(Date.now() + "") + Math.floor(Math.random() * 10000000) |
| | | // // 格式化第一行是右侧language和 “复制” 按钮; |
| | | // let html = ` |
| | | // <div class=${styles["code-block-header"]}> |
| | | // <span>${language}</span> |
| | | // <span id='copy-btn'data-clipboard-action="copy" data-clipboard-target="#copy${codeIndex}">复制代码</span> |
| | | // </div> |
| | | // ` |
| | | |
| | | // //代码部分 |
| | | // if (code) { |
| | | // try { |
| | | // // 使用 highlight.js 对代码进行高亮显示 |
| | | // const preCode = hljs.highlightAuto(code).value; |
| | | // // 将代码包裹在 textarea 中,由于防止textarea渲染出现问题,这里将 "<" 用 "<" 代替,不影响复制功能 |
| | | // return `<pre class='${styles["hljs-customer"]} hljs'> |
| | | // <code>${preCode}</code> |
| | | // </pre> |
| | | // <textarea style="position: absolute;top: -9999px;left: -9999px;z-index: -9999;" id="copy${codeIndex}">${code.replace(/<\/textarea>/g,"</textarea>")}</textarea>`; |
| | | // } catch (error) { |
| | | |
| | | // } |
| | | // } |
| | | // } |
| | | // }) |
| | | // <SyntaxHighlighter language="javascript" style={dark}> |
| | | // {item.content} |
| | | // </SyntaxHighlighter> |
| | | |
| | | return ( |
| | | <div className="assist-wrap" {...restProps}> |
| | | <DeepSeekLogo/> |
| | | {item.type === 'deepseek-reasoner' ? <div className="top-level"> |
| | | <div className="top-level"> |
| | | <DeepSeekIcon /> |
| | | {item.loading ? '思考中...' : '已深度思考'} |
| | | </div> : null} |
| | | </div> |
| | | {item.loading ? <LoadingOutlined /> : null} |
| | | <div dangerouslySetInnerHTML={{ __html: item.content }}></div> |
| | | {item.oriText ? <MkCopy onClick={copy}/> : null} |
| | |
| | | UserID: '', |
| | | LoginUID: '', |
| | | textInput: '', |
| | | type: 'deepseek-reasoner', // deepseek-chat deepseek-reasoner |
| | | type: 'DeepSeek-R1-Distill-Qwen-32B', // deepseek-chat deepseek-reasoner |
| | | currentChat: {id: '', list: [], title: ''}, |
| | | dpChat: null, |
| | | chats: [] |
| | | } |
| | | |
| | |
| | | id: cell.id, |
| | | content: _content, |
| | | oriText: content, |
| | | type: cell.typecharone || '', |
| | | type: 'deepseek-reasoner', |
| | | role |
| | | } |
| | | }) |
| | |
| | | }) |
| | | } |
| | | |
| | | changeType = () => { |
| | | const { type } = this.state |
| | | // changeType = () => { |
| | | // const { type } = this.state |
| | | |
| | | this.setState({type: type === 'deepseek-reasoner' ? 'deepseek-chat' : 'deepseek-reasoner'}) |
| | | } |
| | | // this.setState({type: type === 'deepseek-reasoner' ? 'deepseek-chat' : 'deepseek-reasoner'}) |
| | | // } |
| | | |
| | | submit = () => { |
| | | const { textInput, currentChat, UserID, LoginUID, loading, type } = this.state |
| | | const { textInput, currentChat, loading, type /*, UserID, LoginUID*/ } = this.state |
| | | |
| | | let val = textInput.replace(/\t+|\v+/g, '').replace(/^\s+|\s+$/g, '') |
| | | |
| | |
| | | let node = document.getElementById('mk-input') |
| | | node && node.blur() |
| | | |
| | | let isNew = false |
| | | // let isNew = false |
| | | const that = this |
| | | let chat = fromJS(currentChat).toJS() |
| | | |
| | | if (!chat.id) { |
| | | chat.id = Utils.getuuid() |
| | | isNew = true |
| | | } |
| | | |
| | | chat.list.push({ role: 'user', content: val, id: Utils.getuuid() }) |
| | | chat.list.push({ role: 'assistant', content: '', type: type, loading: true, id: Utils.getuuid() }) |
| | | |
| | | if (!chat.title) { |
| | | chat.title = val.substr(0, 32) |
| | | } |
| | | chat.loading = true |
| | | |
| | | this.setState({textInput: '', currentChat: chat}) |
| | | let reschat = { role: 'assistant', content: '', type: type, loading: true, id: Utils.getuuid() } |
| | | |
| | | let list = [] |
| | | chat.list.forEach(item => { |
| | | if (!item.loading) { |
| | | list.push({ |
| | | role: item.role, |
| | | content: item.oriText || item.content |
| | | }) |
| | | } |
| | | }) |
| | | this.setState({textInput: '', currentChat: fromJS(chat).toJS(), dpChat: reschat}) |
| | | |
| | | Api.directRequest({ |
| | | url: burl + '/chat/completions', |
| | | method: 'post', |
| | | headers: { 'Content-Type': 'application/json' }, |
| | | data: { |
| | | model: type, |
| | | messages: list, |
| | | stream: false |
| | | } |
| | | }).then(res => { |
| | | let _chat = fromJS(chat).toJS() |
| | | // let list = [] |
| | | // chat.list.forEach(item => { |
| | | // if (!item.loading) { |
| | | // list.push({ |
| | | // role: item.role, |
| | | // content: item.oriText || item.content |
| | | // }) |
| | | // } |
| | | // }) |
| | | |
| | | delete _chat.loading |
| | | _chat.list.pop() |
| | | // const ctrlAbout = new AbortController() |
| | | // const { signal } = ctrlAbout |
| | | let contents = [] |
| | | let timer = setInterval(() => { |
| | | if (contents.length) { |
| | | let _cont = contents.shift() |
| | | |
| | | let _val = '服务器繁忙,请稍后再试。' |
| | | let _html = _val |
| | | let tokens_count = 0 |
| | | if (res.success && res.choices && res.choices[0]) { |
| | | _val = res.choices[0].message.content |
| | | _html = this.getAssistVal(_val) |
| | | } else if (!res.success && res.rawStatusCode === 400 && res.message && /This\s*model's\s*maximum\s*context\s*length/.test(res.message)) { |
| | | _html = `当前对话已超出${type === 'deepseek-reasoner' ? '深度思考的' : ''}最大长度限制,开启一个新对话继续思考吧~` |
| | | _val = _html |
| | | } |
| | | |
| | | if (res.usage && res.usage.total_tokens) { |
| | | tokens_count = res.usage.total_tokens |
| | | } |
| | | |
| | | _chat.list = _chat.list.map(item => { |
| | | delete item.loading |
| | | delete item.step |
| | | return item |
| | | }) |
| | | |
| | | _chat.list.push({ role: 'assistant', content: _html, oriText: _val, type: type, step: true, id: Utils.getuuid() }) |
| | | |
| | | this.setState({currentChat: _chat}) |
| | | |
| | | Api.genericInterface({ |
| | | func: 's_deepseek_ai', |
| | | rduri: burl + '/webapi/dostars', |
| | | file_url: '', |
| | | userid: UserID, |
| | | LoginUID: LoginUID, |
| | | u_id: sessionStorage.getItem('UserID'), |
| | | content: window.btoa(window.encodeURIComponent(_val)), |
| | | title: window.btoa(window.encodeURIComponent(chat.title)), |
| | | data_type: 'reply', |
| | | tokens_count: tokens_count, |
| | | version: type, |
| | | ID: chat.id |
| | | }).then(r => { |
| | | if (!r.status) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: r.message, |
| | | duration: 10 |
| | | }) |
| | | } else if (isNew) { |
| | | this.getList() |
| | | if (_cont === '[CLOSE]') { |
| | | clearInterval(timer) |
| | | chat.list.push(reschat) |
| | | that.setState({dpChat: null, currentChat: chat, loading: false}) |
| | | } else { |
| | | reschat.content += _cont |
| | | |
| | | if (_cont === '</think>') { |
| | | delete reschat.loading |
| | | } |
| | | |
| | | that.setState({dpChat: reschat}) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }, 30) |
| | | |
| | | Api.genericInterface({ |
| | | func: 's_deepseek_ai', |
| | | rduri: burl + '/webapi/dostars', |
| | | file_url: '', |
| | | userid: UserID, |
| | | LoginUID: LoginUID, |
| | | u_id: sessionStorage.getItem('UserID'), |
| | | content: window.btoa(window.encodeURIComponent(val)), |
| | | title: window.btoa(window.encodeURIComponent(chat.title)), |
| | | data_type: 'request', |
| | | version: type, |
| | | tokens_count: 0, |
| | | ID: chat.id |
| | | }).then(result => { |
| | | if (!result.status) { |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | fetchEventSource(burl + '/chat', { |
| | | mode: 'cors', |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'Accept': 'text/event-stream' |
| | | }, |
| | | body: JSON.stringify({ |
| | | chat_session_id: chat.id || '', |
| | | model: type, |
| | | prompt: val, |
| | | stream: true |
| | | }), |
| | | onmessage(event) { |
| | | if (event.data) { |
| | | if (event.data === '[CLOSE]') { |
| | | contents.push(event.data) |
| | | } else { |
| | | let data = JSON.parse(event.data) |
| | | if (!chat.id && data.id) { |
| | | chat.id = data.id |
| | | } |
| | | contents.push(data.content) |
| | | } |
| | | } |
| | | }, |
| | | onclose() {}, |
| | | onerror(error) { |
| | | console.info(error) |
| | | } |
| | | }) |
| | | |
| | | // Api.directRequest({ |
| | | // url: burl + '/chat/completions', |
| | | // method: 'post', |
| | | // headers: { 'Content-Type': 'application/json' }, |
| | | // data: { |
| | | // model: type, |
| | | // messages: list, |
| | | // stream: false |
| | | // } |
| | | // }).then(res => { |
| | | // let _chat = fromJS(chat).toJS() |
| | | |
| | | // delete _chat.loading |
| | | // _chat.list.pop() |
| | | |
| | | // let _val = '服务器繁忙,请稍后再试。' |
| | | // let _html = _val |
| | | // let tokens_count = 0 |
| | | // if (res.success && res.choices && res.choices[0]) { |
| | | // _val = res.choices[0].message.content |
| | | // _html = this.getAssistVal(_val) |
| | | // } else if (!res.success && res.rawStatusCode === 400 && res.message && /This\s*model's\s*maximum\s*context\s*length/.test(res.message)) { |
| | | // _html = `当前对话已超出${type === 'deepseek-reasoner' ? '深度思考的' : ''}最大长度限制,开启一个新对话继续思考吧~` |
| | | // _val = _html |
| | | // } |
| | | |
| | | // if (res.usage && res.usage.total_tokens) { |
| | | // tokens_count = res.usage.total_tokens |
| | | // } |
| | | |
| | | // _chat.list = _chat.list.map(item => { |
| | | // delete item.loading |
| | | // delete item.step |
| | | // return item |
| | | // }) |
| | | |
| | | // _chat.list.push({ role: 'assistant', content: _html, oriText: _val, type: type, step: true, id: Utils.getuuid() }) |
| | | |
| | | // this.setState({currentChat: _chat}) |
| | | |
| | | // Api.genericInterface({ |
| | | // func: 's_deepseek_ai', |
| | | // rduri: burl + '/webapi/dostars', |
| | | // file_url: '', |
| | | // userid: UserID, |
| | | // LoginUID: LoginUID, |
| | | // u_id: sessionStorage.getItem('UserID'), |
| | | // content: window.btoa(window.encodeURIComponent(_val)), |
| | | // title: window.btoa(window.encodeURIComponent(chat.title)), |
| | | // data_type: 'reply', |
| | | // tokens_count: tokens_count, |
| | | // version: type, |
| | | // ID: chat.id |
| | | // }).then(r => { |
| | | // if (!r.status) { |
| | | // notification.error({ |
| | | // top: 92, |
| | | // message: r.message, |
| | | // duration: 10 |
| | | // }) |
| | | // } else if (isNew) { |
| | | // this.getList() |
| | | // } |
| | | // }) |
| | | // }) |
| | | |
| | | // Api.genericInterface({ |
| | | // func: 's_deepseek_ai', |
| | | // rduri: burl + '/webapi/dostars', |
| | | // file_url: '', |
| | | // userid: UserID, |
| | | // LoginUID: LoginUID, |
| | | // u_id: sessionStorage.getItem('UserID'), |
| | | // content: window.btoa(window.encodeURIComponent(val)), |
| | | // title: window.btoa(window.encodeURIComponent(chat.title)), |
| | | // data_type: 'request', |
| | | // version: type, |
| | | // tokens_count: 0, |
| | | // ID: chat.id |
| | | // }).then(result => { |
| | | // if (!result.status) { |
| | | // notification.error({ |
| | | // top: 92, |
| | | // message: result.message, |
| | | // duration: 10 |
| | | // }) |
| | | // } |
| | | // }) |
| | | } |
| | | |
| | | getAssistVal = (val) => { |
| | |
| | | } |
| | | |
| | | render () { |
| | | const { loading, textInput, type, currentChat, chats } = this.state |
| | | const { loading, textInput, currentChat, chats, dpChat } = this.state |
| | | |
| | | let able = textInput && !/^\s+$/.test(textInput) |
| | | let empty = !currentChat.id |
| | | let empty = currentChat.list.length === 0 |
| | | |
| | | return ( |
| | | <div className="mk-deepseek-wrap"> |
| | |
| | | return <UserChat key={item.id} item={item}/> |
| | | } |
| | | })} |
| | | {dpChat ? <DpChat key='chat' item={dpChat}/> : null} |
| | | </div> : null} |
| | | {!empty ? <div className="chat-reset"> |
| | | <div className="wrap" onClick={this.newContent}> |
| | |
| | | <TextArea id="mk-input" value={textInput} autoSize={{minRows: 2, maxRows: 12}} placeholder="给 DeepSeek 发送消息 " onChange={this.changeVal} onPressEnter={this.submit}/> |
| | | </div> |
| | | <div className="ec4f5d61"> |
| | | {type === 'deepseek-chat' ? <Tooltip placement="left" title="调用新模型 DeekSeek-R1,解决推理问题"> |
| | | {/* {type === 'deepseek-chat' ? <Tooltip placement="left" title="调用新模型 DeekSeek-R1,解决推理问题"> |
| | | <div className="ds-button" onClick={this.changeType}> |
| | | <DeepSeekIcon/> |
| | | <span className="text">深度思考 (R1)</span> |
| | |
| | | </Tooltip> : <div className="ds-button active" onClick={this.changeType}> |
| | | <DeepSeekIcon/> |
| | | <span className="text">深度思考 (R1)</span> |
| | | </div>} |
| | | </div>} */} |
| | | {/* <div className="ds-button"> |
| | | <span className="ds-icon"> |
| | | <svg width="20" height="20" viewBox="0 0 20 20" fill="none"><circle cx="10" cy="10" r="9" stroke="currentColor" strokeWidth="1.8"></circle><path d="M10 1c1.657 0 3 4.03 3 9s-1.343 9-3 9M10 19c-1.657 0-3-4.03-3-9s1.343-9 3-9M1 10h18" stroke="currentColor" strokeWidth="1.8"></path></svg> |