@topthink/chat 1.1.41 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/html-BSKTzJZQ.js +1 -0
- package/es/index.js +156 -81
- package/es/mp3-HhP1Gk4B.js +1 -0
- package/es/mp4-CWxSyjdn.js +1 -0
- package/es/py-D30pRTJN.js +1 -0
- package/es/unknown-DW8znerP.js +1 -0
- package/package.json +22 -17
- package/types/components/markdown.d.ts +1 -1
- package/types/components/message-box/chunk-provider.d.ts +4 -2
- package/types/components/message-box/context.d.ts +33 -2
- package/types/components/message-box/file-item.d.ts +5 -4
- package/types/components/message-box/index.d.ts +17 -3
- package/types/components/message-box/input-box/index.d.ts +2 -0
- package/types/components/message-box/reasoning.d.ts +2 -2
- package/types/components/message-box/suspend/confirm.d.ts +5 -0
- package/types/components/message-box/suspend/context.d.ts +1 -1
- package/types/index.d.ts +4 -0
- package/types/types.d.ts +32 -4
- package/types/utils/md2html.d.ts +1 -0
- package/types/utils/remark-cite.d.ts +2 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as h from"react";var l,t,e;function v(){return v=Object.assign?Object.assign.bind():function(h){for(var l=1;l<arguments.length;l++){var t=arguments[l];for(var e in t)({}).hasOwnProperty.call(t,e)&&(h[e]=t[e])}return h},v.apply(null,arguments)}const c=c=>h.createElement("svg",v({xmlns:"http://www.w3.org/2000/svg",width:200,height:200,className:"html_svg__icon",viewBox:"0 0 1024 1024"},c),l||(l=h.createElement("path",{fill:"#8C8C8C",d:"m590.222 73.956 268.8 268.299v533.834c0 37.7-30.566 68.267-68.266 68.267H233.244c-37.7 0-68.266-30.567-68.266-68.267V142.222c0-37.7 30.566-68.266 68.266-68.266zM578.458 102.4H233.244a39.82 39.82 0 0 0-39.799 38.457l-.023 1.365V876.09a39.82 39.82 0 0 0 38.457 39.8l1.365.022h557.512a39.82 39.82 0 0 0 39.799-38.457l.023-1.365V354.054z"})),t||(t=h.createElement("path",{fill:"#8C8C8C",d:"M854.756 370.648H639.613c-45.528 0-82.551-36.431-83.507-81.738l-.017-1.792V73.956h28.444v213.162c0 29.895 23.82 54.232 53.516 55.063l1.564.023h215.143zM85.333 489.244h853.334q28.444 0 28.444 28.445v284.444q0 28.445-28.444 28.445H85.333q-28.444 0-28.444-28.445V517.69q0-28.445 28.444-28.445"})),e||(e=h.createElement("path",{fill:"#FFF",d:"M207.2 756.622v-78.336h62.726v78.336h45.568v-190.72h-45.568v72.704h-62.731v-72.704h-45.818v190.72zm235.014 0V604.046h51.712v-38.144H344.934v38.144h51.45v152.576zm122.112 0v-65.28c0-18.944-3.584-47.36-5.888-66.048h1.024l15.36 45.568 25.85 69.632h25.089l25.6-69.632 15.872-45.568h1.28c-2.56 18.688-6.144 47.104-6.144 66.048v65.28h41.728v-190.72h-49.664l-29.184 82.432c-3.584 11.008-6.656 23.04-10.49 34.56h-1.28c-3.585-11.52-6.657-23.552-10.497-34.56l-30.208-82.432h-49.413v190.72h40.96zm303.61 0v-38.4h-74.24v-152.32h-45.818v190.72z"})));var a="data:image/svg+xml,%3csvg t='1767873452096' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='1778' width='200' height='200'%3e%3cpath d='M590.222222 73.955556L859.022222 342.254933V876.088889c0 37.700267-30.5664 68.266667-68.266666 68.266667H233.244444c-37.700267 0-68.266667-30.5664-68.266666-68.266667V142.222222c0-37.700267 30.5664-68.266667 68.266666-68.266666h356.977778z m-11.764622 28.444444H233.244444a39.822222 39.822222 0 0 0-39.799466 38.456889L193.422222 142.222222v733.866667a39.822222 39.822222 0 0 0 38.456889 39.799467L233.244444 915.911111h557.511112a39.822222 39.822222 0 0 0 39.799466-38.456889L830.577778 876.088889V354.053689L578.4576 102.4z' fill='%238C8C8C' p-id='1779'%3e%3c/path%3e%3cpath d='M854.755556 370.648178h-215.1424c-45.528178 0-82.551467-36.431644-83.5072-81.737956l-0.017067-1.792V73.955556h28.444444v213.162666c0 29.895111 23.819378 54.232178 53.515378 55.062756l1.564445 0.022755h215.1424v28.444445z' fill='%238C8C8C' p-id='1780'%3e%3c/path%3e%3cpath d='M56.888889 489.244444m28.444444 0l853.333334 0q28.444444 0 28.444444 28.444445l0 284.444444q0 28.444444-28.444444 28.444445l-853.333334 0q-28.444444 0-28.444444-28.444445l0-284.444444q0-28.444444 28.444444-28.444445Z' fill='%238C8C8C' p-id='1781'%3e%3c/path%3e%3cpath d='M207.200711 756.622222v-78.336h62.725689V756.622222h45.568V565.902222h-45.568v72.704H207.195022v-72.704h-45.818311V756.622222zM442.2144 756.622222v-152.576h51.712v-38.144h-148.992v38.144h51.450311V756.622222zM564.3264 756.622222v-65.28c0-18.944-3.584-47.36-5.888-66.048h1.024l15.36 45.568 25.850311 69.632h25.088l25.6-69.632 15.872-45.568h1.28c-2.56 18.688-6.144 47.104-6.144 66.048V756.622222h41.728V565.902222h-49.664l-29.184 82.432c-3.584 11.008-6.656 23.04-10.490311 34.56h-1.28c-3.584-11.52-6.656-23.552-10.496-34.56l-30.208-82.432h-49.413689V756.622222h40.96zM867.936711 756.622222v-38.4h-74.24V565.902222h-45.818311V756.622222z' fill='white' p-id='1782'%3e%3c/path%3e%3c/svg%3e";export{c as ReactComponent,a as default};
|
package/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{styled as n,css as i,formatSize as o,Tooltip as s,useAsync as a,isRequestError as l,Form as c,Toast as d,InfiniteScroller as m,Offcanvas as u,dayjs as h,RequestButton as p,useImmer as g,createGlobalStyle as f,getAbsoluteUrl as b,Lightbox as v,Clipboard as x,Button as y,isImageUrl as k,request as w}from"@topthink/components";import*as E from"react";import{createContext as N,useContext as j,useEffect as $,useState as C,useRef as M,useCallback as S,forwardRef as q,useMemo as R,useImperativeHandle as z,Fragment as F,memo as I}from"react";import*as A from"path";import D from"path";import{Spinner as L,Badge as T,CloseButton as P,OverlayTrigger as O,Popover as _}from"react-bootstrap";import B from"eventemitter3";import{Editor as U,Delta as H,SKILL_KEY as J,VARS_KEY as Q,SEL_VALUE_KEY as W,SEL_KEY as X,EditableInputPlugin as G,SelectorInputPlugin as K,SkillInputPlugin as V,BlockKit as Y,Editable as Z,VARS_VALUE_KEY as ee}from"@block-kit/variable";import"@block-kit/variable/dist/style/index.css";import te from"lodash/isEqual";import{toString as re}from"hast-util-to-string";import ne from"react-markdown";import"katex/dist/katex.min.css";import ie from"rehype-highlight";import oe from"rehype-katex";import se from"remark-breaks";import ae from"remark-gfm";import le from"remark-math";import{codes as ce,types as de}from"micromark-util-symbol";import{markdownLineEnding as me}from"micromark-util-character";import{createPortal as ue}from"react-dom";import he from"use-resize-observer";import{unified as pe}from"unified";import ge from"rehype-stringify";import fe from"remark-parse";import be from"remark-rehype";function ve(e,t){return e.name===t}const xe=N(null);function ye(e){const t=j(xe);if(!t)throw new Error("useContext must be used within a Provider");const{setHandles:r}=t;return $(()=>{if(e)return r(e),()=>{r({})}},[e]),t}function ke({children:t,...r}){const[n,i]=C({});return e(xe.Provider,{value:{...r,handles:n,setHandles:i},children:t})}const we=function({ext:t}){const{result:r}=a(async e=>{try{return(await function(e){switch(e){case"../../images/file/docx.svg":return import("./docx-2LwnwWwv.js");case"../../images/file/html.svg":return import("./html-BSKTzJZQ.js");case"../../images/file/jpg.svg":return import("./jpg-muicsKjX.js");case"../../images/file/md.svg":return import("./md-DRS7QmE8.js");case"../../images/file/mp3.svg":return import("./mp3-HhP1Gk4B.js");case"../../images/file/mp4.svg":return import("./mp4-CWxSyjdn.js");case"../../images/file/pdf.svg":return import("./pdf-CWBi2u4Z.js");case"../../images/file/png.svg":return import("./png-DNwbFeJk.js");case"../../images/file/pptx.svg":return import("./pptx-Bv4V_F_3.js");case"../../images/file/py.svg":return import("./py-D30pRTJN.js");case"../../images/file/txt.svg":return import("./txt-CsqmEKjF.js");case"../../images/file/unknown.svg":return import("./unknown-DW8znerP.js");case"../../images/file/xlsx.svg":return import("./xlsx-CmkshfKZ.js");default:return new Promise(function(t,r){("function"==typeof queueMicrotask?queueMicrotask:setTimeout)(r.bind(null,new Error("Unknown variable dynamic import: "+e)))})}}(`../../images/file/${e}.svg`)).default}catch{return(await import("./unknown-DW8znerP.js")).default}},[t]);return r?e("img",{width:30,height:30,src:r}):null},Ee=function({className:r,name:n,size:i=0,loading:a,error:l,onRemove:c,onClick:d}){const m=D.extname(n).substring(1),u=t(Me,{className:r,$error:!!l,onClick:d,children:[t(Ce,{children:[e(we,{ext:m}),a&&e(L,{variant:"primary"})]}),t($e,{children:[e("h4",{children:n}),i>0&&e("p",{children:o(i,1)})]}),c&&e(je,{onClick:e=>{e.preventDefault(),c()},children:e("i",{className:"bi bi-trash3"})})]});return l?e(s,{placement:"top",tooltip:l,children:u}):u};function Ne(t){const{renderFileItem:r}=ye();return r?r({Component:Ee,props:t}):e(Ee,{...t})}const je=n.div`
|
|
2
2
|
width: 1.75rem;
|
|
3
3
|
height: 1.75rem;
|
|
4
4
|
align-items: center;
|
|
@@ -13,7 +13,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
13
13
|
color: var(--bs-danger);
|
|
14
14
|
background-color: var(--bs-danger-bg-subtle);
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
`,$e=n.div`
|
|
17
17
|
flex: 1;
|
|
18
18
|
overflow: hidden;
|
|
19
19
|
|
|
@@ -34,7 +34,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
34
34
|
line-height: 20px;
|
|
35
35
|
margin-bottom: 0;
|
|
36
36
|
}
|
|
37
|
-
`,
|
|
37
|
+
`,Ce=n.div`
|
|
38
38
|
position: relative;
|
|
39
39
|
width: 3rem;
|
|
40
40
|
height: 3rem;
|
|
@@ -48,7 +48,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
48
48
|
position: absolute;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
`,
|
|
51
|
+
`,Me=n.div`
|
|
52
52
|
display: flex;
|
|
53
53
|
gap: .5rem;
|
|
54
54
|
padding: .5rem;
|
|
@@ -56,6 +56,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
56
56
|
border-radius: var(--bs-border-radius-lg);
|
|
57
57
|
align-items: center;
|
|
58
58
|
background: #FFF;
|
|
59
|
+
cursor: ${e=>e.onClick?"pointer":"default"};
|
|
59
60
|
|
|
60
61
|
&:hover {
|
|
61
62
|
border-color: var(--bs-primary);
|
|
@@ -64,7 +65,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
64
65
|
${e=>e.$error&&i`
|
|
65
66
|
border-color: var(--bs-danger) !important;
|
|
66
67
|
`}
|
|
67
|
-
`,
|
|
68
|
+
`,Se=[".txt",".md",".pdf",".docx",".xlsx",".pptx",".png",".jpg"];function qe(){const{setMessages:e,setSuggestions:t,setLoading:r,conversationId:n,setConversationId:i,request:o,handles:s,messages:a}=ye(),c=M(null),d=M(!1),m=M(n),{onSuccess:u,onComplete:h,onEvent:p}=s,g=S(t=>{if(t.data)if("[DONE]"!=t.data)try{const r=JSON.parse(t.data);r.conversation?(m.current=r.conversation,i(r.conversation)):r.suspend?d.current=!0:r.event?p?.(r.event):e(e=>{const t=e[e.length-1];if(r.chunks){if(t.chunks){const e=r.chunks.index;if(t.chunks[e]||(t.chunks[e]={content:"",reasoning:"",tools:[]}),r.chunks.error)t.chunks[e].error=r.chunks.error;else if(r.chunks.tools){t.chunks[e].tools||(t.chunks[e].tools=[]);const n=r.chunks.tools.index;delete r.chunks.tools.index,t.chunks[e].tools[n]&&"arguments"in r.chunks.tools?t.chunks[e].tools[n].arguments+=r.chunks.tools.arguments:t.chunks[e].tools[n]={...t.chunks[e].tools[n],...r.chunks.tools}}else if(r.chunks.reasoning)t.chunks[e].reasoning+=r.chunks.reasoning;else if(r.chunks.content)if("object"==typeof r.chunks.content){Array.isArray(t.chunks[e].content)||(t.chunks[e].content=[]);const n=r.chunks.content.index,i=r.chunks.content.value;"string"==typeof i?(t.chunks[e].content[n]||(t.chunks[e].content[n]=""),t.chunks[e].content[n]+=i):t.chunks[e].content[n]=i}else t.chunks[e].content+=r.chunks.content;else r.chunks.node&&(t.chunks[e].node={...t.chunks[e].node,...r.chunks.node})}}else r.stats?t.stats=r.stats:r.id&&(t.id=r.id)})}catch(e){console.error(e)}else e(e=>{e[e.length-1].loading=!1})},[s]),f=S(t=>{let r="未知错误";l(t)&&(r=401==t.response?.status?"未授权或授权已过期,请刷新页面后重试":"string"==typeof t.errors?t.errors:Object.values(t.errors).join("\n")),e(e=>{const t=e[e.length-1];t.chunks&&(0===t.chunks.length?t.chunks=[{error:r}]:t.chunks[t.chunks.length-1].error=r),t.loading=!1})},[]),b=S(async()=>{try{c.current&&c.current.abort(),d.current=!1,r(!0),e(e=>{e[e.length-1].loading=!0,delete e[e.length-1].stats});let t={url:"message",method:"get",params:{conversation:m.current},onMessage:g};await o(t),d.current||u?.()}catch(e){f(e)}r(!1),h?.()},[]);$(()=>{m.current=n;const e=a[a.length-1];e&&0==e.chunks?.length&&!e.loading&&b()},[n]);const v=S(async(n,...i)=>{"string"==typeof n&&(n={query:n,...i});const{query:s,files:a=[],variables:l={},quote:p}=n;if(s||a.length>0){c.current&&c.current.abort(),d.current=!1,r(!0),t([]),e(e=>{e.push({query:s,quote:p,files:a,variables:l,chunks:[],loading:!0})});try{let e={method:"post",data:{query:s,quote:p,files:a,variables:l,conversation:m.current},onMessage:g};await o(e),d.current||u?.()}catch(e){f(e)}r(!1),h?.()}},[o,s]),x=S(async t=>{try{c.current&&c.current.abort(),d.current=!1,r(!0),e(e=>{e[e.length-1].loading=!0});let n={url:"resume",method:"post",data:{conversation:m.current,chunk:t.chunk,tool:t.tool,payload:t.payload},onMessage:g};await o(n),d.current||u?.()}catch(e){f(e)}r(!1),h?.()},[o,s]);return{send:v,resume:x,suggest:S(async()=>{c.current=new AbortController;try{let e={method:"post",url:"/suggestion",data:{conversation:m.current},signal:c.current.signal};const r=await o(e);t(r)}catch{}finally{c.current=null}},[o])}}function Re({variables:t,values:r,onSubmit:n,onChange:i,children:o}){const s={},a=[],l={};return t.forEach(e=>{s[e.key]={type:"string",title:e.label},"textarea"===e.type?l[e.key]={"ui:widget":"textarea"}:"select"===e.type&&e.options&&(s[e.key].enum=e.options,s[e.key].enumNames=e.options,e.options.length>0&&(s[e.key].default=e.options[0])),e.required&&a.push(e.key)}),e(c,{schema:{type:"object",properties:s,required:a},formData:r,omitExtraData:!0,uiSchema:l,submitText:"开始对话",onSubmit:n,onChange:i,children:o})}const ze=n.button`
|
|
68
69
|
color: var(--bs-secondary);
|
|
69
70
|
cursor: pointer;
|
|
70
71
|
display: flex;
|
|
@@ -87,12 +88,12 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
87
88
|
background-color: var(--bs-gray-200);
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
`;let
|
|
91
|
+
`;let Fe=class{#e;#t;constructor(){this.#t=new B}onResult(e){this.#t.on("result",e)}onRecording(e){this.#t.on("recording",e)}onTranscribing(e){this.#t.on("transcribing",e)}start(){if(!this.#e){const e=window.SpeechRecognition||window.webkitSpeechRecognition;if(!e)return void d.error("浏览器不支持语音识别");const t=new e;t.continuous=!0,t.lang=navigator.language,t.onresult=e=>{const t=Array.from(e.results).at(-1)?.item(0).transcript;t&&this.#t.emit("result",t)},t.onspeechend=()=>{this.#t.emit("recording",!1)},t.onerror=e=>{this.#t.emit("recording",!1),d.error(e.error)},this.#e=t}this.#t.emit("recording",!0),this.#e.start()}stop(){this.#e?.stop(),this.#t.emit("recording",!1)}},Ie=class{#t;#r;#n;#i;constructor(e){this.#r=e,this.#t=new B}async start(){try{this.#n=await navigator.mediaDevices.getUserMedia({audio:!0}),this.#i=new AudioContext;const e=this.#i.createScriptProcessor(0,1,1);this.#i.createMediaStreamSource(this.#n).connect(e),e.connect(this.#i.destination);let t=[],r=0;const n=.01,i=1;e.onaudioprocess=e=>{const o=e.playbackTime,s=e.inputBuffer.getChannelData(0);let a=!0;for(let e=0;e<s.length;e++)if(Math.abs(s[e])>n){a=!1;break}if(a){const e=o-r;e>i&&(t.length>1&&(this.save(t),t=[]),e>10&&this.stop())}else t.push(new Float32Array(s)),r=o},this.#t.emit("recording",!0)}catch(e){d.error(e.message)}}convertBuffer(e){const t=new Float32Array(e),r=new Int16Array(e.length);for(let e=0;e<t.length;e++){const n=Math.max(-1,Math.min(1,t[e]));r[e]=n<0?32768*n:32767*n}return r}async encodeMP3(e){const{Mp3Encoder:t}=await import("@breezystack/lamejs"),r=new t(1,44100,128),n=[];for(const t of e){const e=this.convertBuffer(t),i=1152;let o=e.length;for(let t=0;o>=0;t+=i){const s=e.subarray(t,t+i),a=r.encodeBuffer(s);n.push(new Int8Array(a)),o-=i}}return n.push(r.flush()),new Blob(n,{type:"audio/mp3"})}async save(e){const t=await this.encodeMP3(e);try{this.#t.emit("transcribing",!0);const e=await this.#r(t);e&&this.#t.emit("result",e)}catch(e){}finally{this.#t.emit("transcribing",!1)}}stop(){this.#n&&(this.#n.getTracks().forEach(e=>e.stop()),this.#n=void 0),this.#i&&(this.#i.close(),this.#i=void 0),this.#t.emit("recording",!1)}onResult(e){this.#t.on("result",e)}onRecording(e){this.#t.on("recording",e)}onTranscribing(e){this.#t.on("transcribing",e)}};const Ae=q(({onResult:r,model:n="builtin"},i)=>{const{request:o}=ye(),a=R(()=>{if("builtin"!==n)return async e=>{const t=new FormData;t.append("file",e,"audio.mp3"),t.append("model",n);return(await o({url:"/transcriptions",method:"post",data:t})).text}},[n]),{start:l,stop:c,recording:d,transcribing:m}=function({onResult:e,loader:t}){const r=M(),[n,i]=C(!1),[o,s]=C(!1);return $(()=>()=>{r.current&&(r.current.stop(),r.current=void 0)},[]),{recording:n,transcribing:o,start:async()=>{r.current||(r.current=t?new Ie(t):new Fe,r.current.onRecording(i),r.current.onTranscribing(s),r.current.onResult(e)),r.current.start()},stop:()=>{r.current&&r.current.stop()}}}({onResult:r,loader:a});return z(i,()=>({start:l,stop:c}),[l,c]),e(s,{tooltip:d?"停止":"语音输入",placement:"top",children:t(ze,{onMouseDown:e=>{e.preventDefault(),d?c():l()},children:[m&&e(De,{animation:"border",variant:"primary",size:"sm"}),e("i",d?{className:"bi bi-mic-fill text-danger"}:{className:"bi bi-mic"})]})})}),De=n(L)`
|
|
91
92
|
position: absolute;
|
|
92
93
|
--bs-spinner-width: .75rem;
|
|
93
94
|
--bs-spinner-height: .75rem;
|
|
94
95
|
--bs-spinner-border-width: 0.1em;
|
|
95
|
-
`,
|
|
96
|
+
`,Le=q(({className:t,children:r,size:n,tooltip:i,placement:o,onClick:a,onMouseDown:l},c)=>{const d=e(Te,{ref:c,className:t,onClick:a,onMouseDown:l,$size:n,children:r});return i?e(s,{tooltip:i,placement:o,children:d}):d}),Te=n.div`
|
|
96
97
|
width: 2rem;
|
|
97
98
|
height: 2rem;
|
|
98
99
|
align-items: center;
|
|
@@ -116,10 +117,10 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
116
117
|
&:hover {
|
|
117
118
|
background-color: var(--bs-secondary-bg-subtle);
|
|
118
119
|
}
|
|
119
|
-
`;function
|
|
120
|
+
`;function Pe(){const{request:n,reset:i,conversationId:o}=ye(),[a,l]=C(!1);return t(r,{children:[e(Le,{tooltip:"历史记录",placement:"top",onClick:()=>l(!0),children:e("i",{className:"bi bi-clock-history"})}),e(u,{show:a,onHide:()=>{l(!1)},placement:"end",header:"聊天历史记录",bodyAs:Oe,children:a&&e(Je,{children:e(He,{useWindow:!1,source:e=>n({url:"/conversation",params:e}),render:({data:r,loading:a,setData:c})=>r.length||a?r.map((r,a)=>{const d=r.messages?.reduce((e,t)=>e+t.chunks.reduce((e,t)=>e+(t.content||""),""),"");return t(F,{children:[a>0&&e("hr",{className:"mx-2 my-2"}),t(Ue,{onClick:()=>{i(r),l(!1)},children:[t(Be,{children:[o===r.id&&e(T,{bg:"secondary",children:"当前"}),e("span",{className:"fw-bold overflow-hidden text-truncate me-auto",children:r.title||"未命名对话"}),e("span",{className:"text-body text-opacity-50 flex-shrink-0 ms-5",children:h(r.update_time).fromNow()})]}),t(_e,{children:[e("span",{className:"overflow-hidden text-truncate me-auto",children:d||" "}),e("span",{className:"ms-3",children:o!==r.id&&e(s,{tooltip:"删除",children:e(p,{as:"a",confirm:"确定要删除吗?",onRequest:()=>n({url:`/conversation/${r.id}`,method:"DELETE"}),onSuccess:()=>{c(e=>{const t=e.findIndex(e=>e.id===r.id);-1!==t&&e.splice(t,1)})},children:e("i",{className:"bi bi-trash3"})})})})]})]})]},r.id)}):e("div",{className:"text-muted text-center py-5",children:"暂无对话记录"})})})})]})}const Oe=n.div`
|
|
120
121
|
padding: 0;
|
|
121
122
|
overflow: hidden;
|
|
122
|
-
`,
|
|
123
|
+
`,_e=n.div`
|
|
123
124
|
color: var(--bs-gray-600);
|
|
124
125
|
font-weight: 400;
|
|
125
126
|
line-height: 22px;
|
|
@@ -129,11 +130,11 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
129
130
|
& :last-child {
|
|
130
131
|
display: none;
|
|
131
132
|
}
|
|
132
|
-
`,
|
|
133
|
+
`,Be=n.div`
|
|
133
134
|
display: flex;
|
|
134
135
|
align-items: center;
|
|
135
136
|
gap: .25rem;
|
|
136
|
-
`,
|
|
137
|
+
`,Ue=n.div`
|
|
137
138
|
gap: .5rem;
|
|
138
139
|
display: flex;
|
|
139
140
|
flex-direction: column;
|
|
@@ -146,70 +147,102 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
146
147
|
|
|
147
148
|
|
|
148
149
|
&:hover {
|
|
149
|
-
${
|
|
150
|
+
${_e} :last-child {
|
|
150
151
|
display: initial;
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
|
-
`,
|
|
155
|
+
`,He=n(m)`
|
|
155
156
|
display: flex;
|
|
156
157
|
flex-direction: column;
|
|
157
158
|
padding: .5rem;
|
|
158
|
-
|
|
159
|
+
`,Je=n.div`
|
|
159
160
|
height: 100%;
|
|
160
161
|
overflow-y: auto;
|
|
161
|
-
`;var
|
|
162
|
+
`;var Qe;function We(){return We=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},We.apply(null,arguments)}const Xe=e=>E.createElement("svg",We({width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 256 256"},e),Qe||(Qe=E.createElement("path",{fillRule:"evenodd",d:"M128 22C69.458 22 22 69.458 22 128v96c0 5.523 4.477 10 10 10h96c58.542 0 106-47.458 106-106S186.542 22 128 22m0 56c5.523 0 10 4.477 10 10v30h30c5.523 0 10 4.477 10 10s-4.477 10-10 10h-30v30c0 5.523-4.477 10-10 10s-10-4.477-10-10v-30H88c-5.523 0-10-4.477-10-10s4.477-10 10-10h30V88c0-5.523 4.477-10 10-10",clipRule:"evenodd","data-follow-fill":"#000"})));function Ge(){const{reset:t}=ye();return e(Le,{className:"text-primary",tooltip:"新会话",placement:"top",onClick:t,children:e(Xe,{})})}function Ke({children:r}){return t(Ye,{children:[r,t(Ve,{children:[e(Pe,{}),e(Ge,{})]})]})}const Ve=n.div`
|
|
162
163
|
display: flex;
|
|
163
164
|
gap: .25rem;
|
|
164
165
|
margin-left: auto;
|
|
165
|
-
`,
|
|
166
|
+
`,Ye=n.div`
|
|
166
167
|
margin-bottom: .5rem;
|
|
167
168
|
display: flex;
|
|
168
169
|
padding: 0 .125rem;
|
|
169
|
-
|
|
170
|
+
`,Ze=function(e){return e.ops.map(e=>e.attributes?.[ee]||e.attributes?.[W]||e.insert||"").join("")};var et=q(function({suggestion:r,fileTypes:n,speech:i,scrollRef:o,variables:a,minRows:c=1,maxRows:m=5,toolbar:u,disabled:h,autoFocus:p,placeholder:f="请输入你的问题, Enter+Shift换行, Enter发送",onEvent:b},v){const x=M(null),y=M(null),k=M(),[w,E]=C(""),[N,j]=C(""),[q,F]=g([]),[I,D]=C(!1),L=n&&n.length>0?n:Se,{send:T,resume:O,suggest:_}=qe(),B=R(()=>{const e=new U({schema:{[Q]:{void:!0,inline:!0},[X]:{void:!0,inline:!0},[J]:{void:!0,inline:!0}}});return e.event.on("focus_capture",()=>D(!0)),e.event.on("blur_capture",()=>D(!1)),e.event.on("keydown_capture",t=>{if("Escape"===t.key){const{ops:t}=e.state.toBlock();t.some(e=>"skill-key"in(e.attributes||{}))&&e.state.setContent(new H)}else"Enter"!==t.key||t.shiftKey||(t.preventDefault(),t.stopPropagation(),k.current?.())}),e.event.on("CONTENT_CHANGE",e=>{E(Ze(e.current).trim())}),e},[]),Z=R(()=>({onSuccess(){r&&_()},onComplete(){requestAnimationFrame(()=>{B.selection.focus()})},onEvent:b}),[r,b]),{messages:ee,loading:te,request:re,setInput:ne}=ye(Z),[ie,oe]=C();$(()=>{const e=ee.filter(e=>!!e.query);oe(e.at(-1)?.variables)},[ee]),$(()=>{!n&&q.length>0&&F([])},[n]),$(()=>{const e=o.current;if(e&&T){const t=e=>{if(e.target instanceof HTMLAnchorElement&&"#!question"===e.target.hash){e.preventDefault();const t={query:e.target.text};a&&(t.variables={...ie,...a.values}),T(t)}};return e.addEventListener("click",t),()=>{e.removeEventListener("click",t)}}},[a,ie]);const se=S(({target:e})=>{if(e.files){const t=Array.from(e.files).filter(e=>!!L.includes(A.extname(e.name))&&(!(e.size>20971520)&&e)).slice(0,6-q.length);F(e=>{e.push(...t.map(e=>({file:e})))}),t.forEach(async e=>{try{const t=new FormData;t.set("file",e);const r=await re({method:"POST",url:"/upload",data:t});F(t=>{const n=t.find(t=>t.file===e);n&&(n.path=r.path)})}catch(t){const r=l(t)?t.message:"unknown error";F(t=>{const n=t.find(t=>t.file===e);n&&(n.error=r)})}})}e.value=""},[q,L]),ae=q.flatMap(({file:e,path:t})=>t?[{name:e.name,size:e.size,path:t}]:[]),le=S(()=>{if(w||ae.length>0){const e={query:w,files:ae};a&&(e.variables={...ie,...a.values}),N&&(e.quote=N),T(e),de(""),j(""),F([]),y.current?.stop(!0)}},[w,ae,a,ie,N]);$(()=>{k.current=le},[le]);const ce=S(e=>{const t={},r={},n=new H;let i=1,o=1,s=0;const a=/\(([^)]+)\)|\[([^\]]+)\]|\{([^}]+)\}/g;let l;for(;null!==(l=a.exec(e));){if(l.index>s){const t=e.substring(s,l.index);t&&n.insert(t)}if(l[1])n.insert(" ",{[J]:l[1].trim()});else if(l[2]){const e=`var-${i}`;t[e]=l[0],n.insert(" ",{[Q]:e}),i++}else if(l[3]){const e=l[3].split("|").map(e=>e.trim()),t=`sel-${o}`;r[t]=e,n.insert(" ",{[X]:t,[W]:e[0]}),o++}s=a.lastIndex}if(s<e.length){const t=e.substring(s);t&&n.insert(t)}return{delta:n,placeholders:t,selector:r}},[]),de=S(e=>{let t;t="string"==typeof e?e:e(Ze(B.state.block.toDelta()));const{delta:r,placeholders:n,selector:i}=ce(t);B.plugin.register([new G({placeholders:n}),new K({selector:i}),new V]),B.state.setContent(r),requestAnimationFrame(()=>{B.selection.focus()})},[B,ce]),me=R(()=>({setQuery:de,setQuote:j,send:T,resume:O,editor:B,focus(){B.selection.focus()}}),[de,j,T,O,B]);if($(()=>{ne(me)},[me]),z(v,()=>me,[me]),a){const t=a.config.filter(e=>!(e.key in(a.values||{}))),r=(e,r=!1)=>!!e&&t.every(t=>{const n=!t.required||e?.[t.key];return!n&&r&&d.error("请完善必填信息"),n});if(t.length>0&&!r(ie))return e(rt,{children:e(tt,{children:e(Re,{values:ie,variables:t,onSubmit:({formData:e})=>{if(r(e,!0))return oe(e),!0}})})})}return t(dt,{children:[e(it,{}),u&&e(Ke,{children:u}),t(ct,{$focused:I&&!te,children:[q.length>0&&e(st,{children:q.map(({file:t,error:r,path:n},i)=>{const o=void 0===r&&void 0===n;return e(nt,{name:t.name,size:t.size,error:r,loading:o,onRemove:()=>{F(e=>{const r=e.findIndex(e=>e.file===t);-1!==r&&e.splice(r,1)})}},i)})}),!!N&&t(lt,{children:[e("i",{className:"bi bi-quote"}),e("p",{children:N}),e(P,{onClick:()=>j("")})]}),t(at,{children:[e(Y,{editor:B,readonly:te||h,children:e(ot,{className:"block-kit-editable",autoFocus:p,placeholder:f,$minRows:c,$maxRows:m})}),n&&e(s,{tooltip:"可上传不超过6个小于20MB的文件",placement:"top",children:t(ze,{disabled:q.length>=6,onClick:()=>x.current?.click(),children:[e("input",{onChange:se,multiple:!0,accept:L.join(","),ref:x,type:"file",hidden:!0}),e("i",{className:"bi bi-file-earmark-arrow-up"})]})}),i&&e(Ae,{ref:y,model:i.model,onResult:e=>{de(t=>t+e+" ")}}),e(ze,{className:"text-primary",disabled:!w&&0===ae.length,onClick:e=>{e.preventDefault(),le()},children:e("i",{className:"bi bi-send-fill"})})]})]})]})});const tt=n.div`
|
|
170
171
|
border-radius: var(--bs-border-radius-lg);
|
|
171
172
|
box-shadow: var(--bs-box-shadow-sm);
|
|
172
173
|
margin: 1rem;
|
|
173
174
|
padding: 1rem;
|
|
174
175
|
width: 100%;
|
|
175
176
|
max-width: 500px;
|
|
176
|
-
`,
|
|
177
|
+
`,rt=n.div`
|
|
177
178
|
position: absolute;
|
|
178
179
|
left: 0;
|
|
179
180
|
right: 0;
|
|
180
181
|
top: 0;
|
|
181
182
|
bottom: 0;
|
|
182
|
-
background: #
|
|
183
|
+
background: #fff;
|
|
183
184
|
display: flex;
|
|
184
185
|
justify-content: center;
|
|
185
186
|
align-items: center;
|
|
186
|
-
`,
|
|
187
|
-
width: calc((100% - .75rem) / 2);
|
|
188
|
-
`,
|
|
187
|
+
`,nt=n(Ne)`
|
|
188
|
+
width: calc((100% - 0.75rem) / 2);
|
|
189
|
+
`,it=f`
|
|
190
|
+
.editable-selector-options {
|
|
191
|
+
border-radius: var(--bs-border-radius) !important;
|
|
192
|
+
border: none !important;
|
|
193
|
+
box-shadow: var(--bs-box-shadow-sm) !important;
|
|
194
|
+
padding: 0.25rem 0 !important;
|
|
195
|
+
|
|
196
|
+
& > div {
|
|
197
|
+
padding: 0.4rem 1rem !important;
|
|
198
|
+
|
|
199
|
+
&:hover {
|
|
200
|
+
background-color: var(--bs-tertiary-bg) !important;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
&.editable-selector-option-selected {
|
|
204
|
+
color: var(--bs-primary) !important;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
`,ot=n(Z)`
|
|
209
|
+
min-height: calc(${e=>1.5*e.$minRows}em + 1rem);
|
|
210
|
+
max-height: calc(${e=>1.5*e.$maxRows}em + 1rem);
|
|
211
|
+
overflow-y: auto;
|
|
212
|
+
margin: -0.5rem;
|
|
213
|
+
padding: 0.5rem;
|
|
214
|
+
flex: 1;
|
|
215
|
+
|
|
216
|
+
.editable-skill-container {
|
|
217
|
+
color: var(--bs-primary);
|
|
218
|
+
background: rgba(0, 102, 255, 0.06);
|
|
219
|
+
|
|
220
|
+
&:first-child {
|
|
221
|
+
margin-left: 0;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.editable-selector {
|
|
226
|
+
display: inline-flex;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.editable-vars > .block-kit-editable-text,
|
|
230
|
+
.editable-selector {
|
|
231
|
+
color: var(--bs-primary);
|
|
232
|
+
}
|
|
233
|
+
`,st=n.div`
|
|
189
234
|
display: flex;
|
|
190
235
|
flex-wrap: wrap;
|
|
191
|
-
padding: .75rem;
|
|
192
|
-
gap: .75rem;
|
|
236
|
+
padding: 0.75rem;
|
|
237
|
+
gap: 0.75rem;
|
|
193
238
|
border-bottom: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
|
|
194
|
-
`,
|
|
239
|
+
`,at=n.div`
|
|
195
240
|
display: flex;
|
|
196
|
-
padding: .5rem .5rem .5rem
|
|
197
|
-
gap: .25rem;
|
|
241
|
+
padding: 0.5rem 0.5rem 0.5rem 0.75rem;
|
|
242
|
+
gap: 0.25rem;
|
|
198
243
|
align-items: end;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
border: none;
|
|
202
|
-
outline: none;
|
|
203
|
-
flex: 1;
|
|
204
|
-
resize: none;
|
|
205
|
-
background: transparent;
|
|
206
|
-
|
|
207
|
-
&::placeholder {
|
|
208
|
-
color: rgba(54, 54, 54, .3);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
`,Oe=n.div`
|
|
212
|
-
margin: .75rem .75rem 0 .75rem;
|
|
244
|
+
`,lt=n.div`
|
|
245
|
+
margin: 0.75rem 0.75rem 0 0.75rem;
|
|
213
246
|
padding: 4px 8px;
|
|
214
247
|
display: flex;
|
|
215
248
|
align-items: center;
|
|
@@ -229,14 +262,14 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
229
262
|
-webkit-box-orient: vertical;
|
|
230
263
|
display: -webkit-box;
|
|
231
264
|
}
|
|
232
|
-
`,
|
|
233
|
-
background: #
|
|
265
|
+
`,ct=n.div`
|
|
266
|
+
background: #fff;
|
|
234
267
|
border: var(--bs-border-width) var(--bs-border-style) ${e=>e.$focused?"var(--bs-primary)":"var(--bs-border-color)"};
|
|
235
268
|
border-radius: var(--bs-border-radius-lg);
|
|
236
269
|
box-shadow: 0.125rem 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
|
|
237
|
-
`,
|
|
270
|
+
`,dt=n.div`
|
|
238
271
|
margin: 0 1rem 1rem;
|
|
239
|
-
`;function
|
|
272
|
+
`;function mt(e){return e.map(e=>({id:e.id,query:e.query,quote:e.quote||void 0,files:e.files||void 0,variables:e.variables,chunks:e.chunks.map(({content:e="",node:t,error:r,tools:n=[],reasoning:i})=>({content:e,reasoning:i,error:r,tools:n,node:t})),annotation:e.annotation,stats:{usage:e.usage,latency:e.latency}}))}function ut(e){if((e=e.filter(e=>!!e.trim())).length>3){const t=[...e];let r=e.length-3;for(;r--;){let e=Math.floor(Math.random()*t.length);t.splice(e,1)}e=t}return e}var ht,pt,gt;function ft(){return ft=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ft.apply(null,arguments)}const bt=e=>E.createElement("svg",ft({xmlns:"http://www.w3.org/2000/svg",width:20,height:10,fill:"#fff",viewBox:"0 0 120 30"},e),ht||(ht=E.createElement("circle",{cx:15,cy:15,r:15,fill:"#3c60ff"},E.createElement("animate",{attributeName:"r",begin:"0s",calcMode:"linear",dur:"0.8s",from:15,repeatCount:"indefinite",to:15,values:"15;9;15"}),E.createElement("animate",{attributeName:"fill-opacity",begin:"0s",calcMode:"linear",dur:"0.8s",from:1,repeatCount:"indefinite",to:1,values:"1;.5;1"}))),pt||(pt=E.createElement("circle",{cx:60,cy:15,r:9,fill:"#3c60ff",fillOpacity:.3},E.createElement("animate",{attributeName:"r",begin:"0s",calcMode:"linear",dur:"0.8s",from:9,repeatCount:"indefinite",to:9,values:"9;15;9"}),E.createElement("animate",{attributeName:"fill-opacity",begin:"0s",calcMode:"linear",dur:"0.8s",from:.5,repeatCount:"indefinite",to:.5,values:".5;1;.5"}))),gt||(gt=E.createElement("circle",{cx:105,cy:15,r:15,fill:"#3c60ff"},E.createElement("animate",{attributeName:"r",begin:"0s",calcMode:"linear",dur:"0.8s",from:15,repeatCount:"indefinite",to:15,values:"15;9;15"}),E.createElement("animate",{attributeName:"fill-opacity",begin:"0s",calcMode:"linear",dur:"0.8s",from:1,repeatCount:"indefinite",to:1,values:"1;.5;1"}))));function vt(e){if(!e)return"";if("string"==typeof e)return e;if("image"===e.type){return`})`}return""}const xt=function(e,t,r){function n(t){return t!==ce.leftSquareBracket?(e.exit("citeMarker"),e.enter("citeData"),e.enter(de.chunkString,{contentType:"string"}),i(t)):(e.consume(t),n)}function i(n){return n===ce.rightSquareBracket?(e.exit(de.chunkString),e.exit("citeData"),e.enter("citeMarker"),function(n){if(n!==ce.rightSquareBracket)return r(n);return e.consume(n),e.exit("citeMarker"),e.exit("cite"),t(n)}(n)):me(n)||n===ce.eof||n>57||n<48?r(n):(e.consume(n),i)}return function(t){return t!==ce.leftSquareBracket?r(t):(e.enter("cite"),e.enter("citeMarker"),n(t))}},yt=function(){const e=this.data();e.micromarkExtensions.push({text:{[ce.leftSquareBracket]:{tokenize:xt}}}),e.fromMarkdownExtensions.push({enter:{cite:function(e){this.enter({type:"cite",data:{hName:"cite",hChildren:[{type:"text",value:""}]}},e)},citeData:function(){this.buffer()}},exit:{cite:function(e){this.exit(e)},citeData:function(){const e=this.resume();this.stack[this.stack.length-1].data.hChildren[0].value=e}}})},kt=v.Image,wt={pre:({children:r,node:n})=>{if(!n)return null;const[i,o]=C(!1),s=R(()=>{const e=n.children[0];return"element"===(t=e).type&&"code"===t.tagName&&!!e.properties?.className?.includes("language-svg");var t},[n]);$(()=>{s&&o(s)},[s]);const a=R(()=>re(n),[n]);return t(Mt,{children:[t(Ct,{children:[!i&&e(x,{tooltip:!1,as:$t,content:a}),s&&i&&e($t,{onClick:()=>{const e=new Blob([a],{type:"image/svg+xml"}),t=URL.createObjectURL(e),r=document.createElement("a");r.href=t,r.download="image.svg",r.click(),URL.revokeObjectURL(t)},children:"下载"}),s&&e($t,{onClick:()=>o(!i),children:i?"源码":"预览"})]}),s&&i?e("div",{dangerouslySetInnerHTML:{__html:a}}):e("pre",{children:r})]})},a:({node:t,href:r,...n})=>{const i=r?.startsWith("http")?"_blank":"_self";return e("a",{...n,href:r,target:i})},img:({node:t,...r})=>e(kt,{...r})},Et=[[le,{singleDollarTextMath:!1}],ae,se],Nt=[oe,[ie,{detect:!1,ignoreMissing:!0}]],jt=I(q(({content:t,components:r,cite:n},i)=>{t=t.replace(/\\\(\s(.+?)\s\\\)/g,"$$$$ $1 $$$$");const o=R(()=>{const e={...wt,...r};return n&&(e.cite=n),e},[r,n]),s=R(()=>n?[...Et,yt]:Et,[n]);return e(St,{ref:i,children:e(ne,{remarkPlugins:s,rehypePlugins:Nt,components:o,children:t})})}),te),$t=n.div`
|
|
240
273
|
cursor: pointer;
|
|
241
274
|
padding: 2px 10px;
|
|
242
275
|
background-color: #303030;
|
|
@@ -246,7 +279,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
246
279
|
font-size: 12px;
|
|
247
280
|
font-family: initial;
|
|
248
281
|
user-select: none;
|
|
249
|
-
`,
|
|
282
|
+
`,Ct=n.div`
|
|
250
283
|
position: absolute;
|
|
251
284
|
right: 10px;
|
|
252
285
|
top: 1em;
|
|
@@ -260,17 +293,17 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
260
293
|
&:hover {
|
|
261
294
|
opacity: 1;
|
|
262
295
|
}
|
|
263
|
-
`,
|
|
296
|
+
`,Mt=n.div`
|
|
264
297
|
position: relative;
|
|
265
298
|
|
|
266
299
|
&:hover {
|
|
267
|
-
${
|
|
300
|
+
${Ct} {
|
|
268
301
|
pointer-events: all;
|
|
269
302
|
transform: translateX(0px);
|
|
270
303
|
opacity: 0.7;
|
|
271
304
|
}
|
|
272
305
|
}
|
|
273
|
-
`,
|
|
306
|
+
`,St=n.div`
|
|
274
307
|
-ms-text-size-adjust: 100%;
|
|
275
308
|
-webkit-text-size-adjust: 100%;
|
|
276
309
|
line-height: 1.8;
|
|
@@ -540,7 +573,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
540
573
|
.hljs-strong {
|
|
541
574
|
font-weight: 700;
|
|
542
575
|
}
|
|
543
|
-
`;var
|
|
576
|
+
`;var qt=q(function({children:t,tooltip:r,onClick:n,disabled:i,...o},a){i&&(n=void 0);const l=e(Rt,{ref:a,onClick:n,$disabled:i,...o,children:t});return r?e(s,{tooltip:r,placement:"top",children:l}):l});const Rt=n.div`
|
|
544
577
|
align-items: center;
|
|
545
578
|
justify-content: center;
|
|
546
579
|
border-radius: .375rem;
|
|
@@ -573,7 +606,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
573
606
|
`}
|
|
574
607
|
|
|
575
608
|
}
|
|
576
|
-
`,
|
|
609
|
+
`,zt=N(null);var Ft=zt.Provider;const It=v.Image;function At({src:t,...r}){const{imageResolver:n}=ye();return n&&t&&(t=n(t)),e(Dt,{children:e(It,{src:t,...r})})}const Dt=n.div`
|
|
577
610
|
margin-bottom: .5rem;
|
|
578
611
|
margin-top: .5rem;
|
|
579
612
|
border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
|
|
@@ -598,7 +631,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
598
631
|
max-height: 100%;
|
|
599
632
|
max-width: 100%;
|
|
600
633
|
}
|
|
601
|
-
`,
|
|
634
|
+
`,Lt=N(null);function Tt(){const e=j(Lt);if(!e)throw new Error("useContext must be used within a Provider");return e}function Pt({children:t,...r}){return e(Lt.Provider,{value:r,children:t})}function Ot({description:r,options:n}){const{resume:i,disabled:o,response:s}=Tt(),[a,l]=C(s?.result),c=o||void 0!==a;return t(_t,{children:[r&&e(Bt,{children:r}),n.map((t,r)=>e(Ut,{$selected:a===t,$disabled:c,onClick:()=>(e=>{c||(l(e),i(e))})(t),children:t},r))]})}const _t=n.div`
|
|
602
635
|
display: flex;
|
|
603
636
|
flex-direction: column;
|
|
604
637
|
gap: 0.5rem;
|
|
@@ -611,10 +644,10 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
611
644
|
&:last-child {
|
|
612
645
|
margin-bottom: 0;
|
|
613
646
|
}
|
|
614
|
-
`,
|
|
647
|
+
`,Bt=n.div`
|
|
615
648
|
color: var(--bs-secondary);
|
|
616
649
|
line-height: 1.5;
|
|
617
|
-
`,
|
|
650
|
+
`,Ut=n.div`
|
|
618
651
|
padding: 0.375rem 0.75rem;
|
|
619
652
|
background-color: ${e=>e.$selected?"rgba(var(--bs-primary-rgb), 0.1)":"#FFFFFF"};
|
|
620
653
|
border: 1px solid ${e=>e.$selected?"rgba(var(--bs-primary-rgb), 0.3)":"var(--bs-border-color)"};
|
|
@@ -633,11 +666,20 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
633
666
|
&:active {
|
|
634
667
|
transform: ${e=>e.$disabled?"none":"scale(0.98)"};
|
|
635
668
|
}
|
|
636
|
-
`;function
|
|
669
|
+
`;function Ht({description:r,fields:n}){const{resume:i,disabled:o,response:s}=Tt(),[a,l]=C(void 0!==s),d=o||a,{schema:m,uiSchema:u}=R(()=>{const e={},t=[],r={};for(const i of n)e[i.name]={type:"number"===i.type?"number":"string",title:i.label},i.placeholder&&(r[i.name]={"ui:placeholder":i.placeholder}),"textarea"===i.type?r[i.name]={...r[i.name],"ui:widget":"textarea"}:"select"!==i.type&&"radio"!==i.type||!i.options?"checkbox"===i.type&&i.options?(e[i.name].type="array",e[i.name].uniqueItems=!0,e[i.name].items={type:"string",enum:i.options},r[i.name]={...r[i.name],"ui:widget":"checkboxes","ui:enumNames":i.options,"ui:inline":!0}):"email"===i.type?e[i.name].format="email":"date"===i.type?e[i.name].format="date":"tel"===i.type&&(r[i.name]={...r[i.name],"ui:options":{inputType:"tel"}}):(r[i.name]={...r[i.name],"ui:widget":i.type},e[i.name].enum=i.options,e[i.name].enumNames=i.options),i.required&&t.push(i.name);return{schema:{type:"object",properties:e,required:t},uiSchema:r}},[n]);return t(Qt,{className:"rounded bg-white shadow-sm",children:[r&&e(Wt,{children:r}),e(c,{schema:m,uiSchema:u,formData:s,onSubmit:({formData:e})=>{d||(l(!0),i(e))},disabled:d,validate:!0,showErrorList:!1,submitText:a?"已提交":"提交",omitExtraData:!0,children:({submit:t})=>e(Jt,{children:t})})]})}const Jt=n.div`
|
|
670
|
+
display: flex;
|
|
671
|
+
justify-content: flex-end;
|
|
672
|
+
border-top: 1px solid var(--bs-border-color);
|
|
673
|
+
padding-top: .5rem;
|
|
674
|
+
button {
|
|
675
|
+
padding: .25rem;
|
|
676
|
+
}
|
|
677
|
+
`,Qt=n.div`
|
|
637
678
|
display: flex;
|
|
638
679
|
flex-direction: column;
|
|
639
680
|
gap: 0.5rem;
|
|
640
|
-
margin:
|
|
681
|
+
margin: .5rem 0;
|
|
682
|
+
padding: .5rem;
|
|
641
683
|
|
|
642
684
|
.g-3 {
|
|
643
685
|
--bs-gutter-y: .5rem !important;
|
|
@@ -650,10 +692,36 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
650
692
|
&:last-child {
|
|
651
693
|
margin-bottom: 0;
|
|
652
694
|
}
|
|
653
|
-
`,
|
|
695
|
+
`,Wt=n.div`
|
|
654
696
|
color: var(--bs-secondary);
|
|
655
697
|
line-height: 1.5;
|
|
656
|
-
`;function
|
|
698
|
+
`;function Xt({content:r}){const{resume:n,disabled:i,response:o}=Tt(),[s,a]=C(void 0!==o),l=i||s;return t(Gt,{className:"rounded bg-white shadow-sm",children:[r&&e(Kt,{children:e(jt,{content:r})}),e(Vt,{children:e(y,{disabled:l,onClick:()=>{l||(a(!0),n("已确认"))},children:s?"已确认":"确认"})})]})}const Gt=n.div`
|
|
699
|
+
display: flex;
|
|
700
|
+
flex-direction: column;
|
|
701
|
+
gap: .5rem;
|
|
702
|
+
margin: .5rem 0;
|
|
703
|
+
padding: 1rem;
|
|
704
|
+
|
|
705
|
+
&:first-child {
|
|
706
|
+
margin-top: 0;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
&:last-child {
|
|
710
|
+
margin-bottom: 0;
|
|
711
|
+
}
|
|
712
|
+
`,Kt=n.div`
|
|
713
|
+
line-height: 1.6;
|
|
714
|
+
color: var(--bs-body-color);
|
|
715
|
+
`,Vt=n.div`
|
|
716
|
+
display: flex;
|
|
717
|
+
justify-content: flex-end;
|
|
718
|
+
border-top: 1px solid var(--bs-border-color);
|
|
719
|
+
margin: 0 -1rem -.5rem -1rem;
|
|
720
|
+
padding: .5rem .5rem 0 .5rem;
|
|
721
|
+
button {
|
|
722
|
+
padding: .25rem 1.5rem;
|
|
723
|
+
}
|
|
724
|
+
`;function Yt({suspend:t}){const{readonly:r}=ye(),{chunkIndex:n,chunk:i,toolIndex:o,tool:s,isLastMessage:a}=function(){const e=j(zt);if(!e)throw new Error("useContext must be used within a Provider");return e}(),{resume:l}=qe(),c=S(e=>{l({chunk:n,tool:o,payload:e})},[]);let d=null;switch(t.type){case"select":d=e(Ot,{...t.select});break;case"form":d=e(Ht,{...t.form});break;case"confirm":d=e(Xt,{...t.confirm})}const m=s?.response||i.node?.output;return e(Pt,{resume:c,disabled:r||!!i.error||!a,response:"(Empty)"===m?void 0:m,children:d})}function Zt({value:t,cite:n}){const i=t=>"string"==typeof t?e(jt,{content:t,cite:n}):"image"===t.type?e(At,{src:t.image}):"suspend"===t.type?e(Yt,{suspend:t.suspend}):null;return Array.isArray(t)?e(r,{children:t.map((t,r)=>e(F,{children:i(t)},r))}):i(t)}const er=({reasoning:r,loading:n})=>{const[i,o]=C(!1);return $(()=>{n||o(!1)},[n]),e(F,{children:e("div",{className:"mb-2",children:t("div",i?{className:"shadow-sm rounded bg-white fs-7",children:[t("div",{onClick:()=>o(!1),role:"button",className:"d-flex align-items-center p-1 px-2 gap-2",children:[n?e(L,{animation:"border",variant:"primary",size:"sm"}):e("i",{className:"bi bi-check-circle-fill text-success"}),e("span",{className:"text-muted",children:n?"思考中":"已思考"}),e("i",{className:"bi bi-caret-up-fill text-muted"})]}),e("div",{className:"border-top p-2 d-flex flex-column gap-2",children:e("div",{className:"border rounded bg-light p-2",children:e(jt,{content:r})})})]}:{onClick:()=>o(!0),role:"button",className:"d-inline-flex align-items-center shadow-sm rounded bg-white p-1 px-2 fs-7 gap-2",children:[n?e(L,{animation:"border",variant:"primary",size:"sm"}):e("i",{className:"bi bi-check-circle-fill text-success"}),e("span",{className:"text-muted",children:n?"思考中":"已思考"}),e("i",{className:"bi bi-caret-down-fill text-muted"})]})})})},tr=I(t=>{const{renderReasoning:r}=ye();return r?r({Component:er,props:t}):e(er,{...t})});class rr{#t;#o=[];#s=0;constructor(){this.#t=new B}speak(){for(this.#t.emit("playing",!0);this.#s<this.#o.length;){const e=this.#o[this.#s],t=new SpeechSynthesisUtterance(e),r=++this.#s;t.onend=()=>{r>=this.#o.length&&this.clear()},t.onerror=()=>{this.clear()},window.speechSynthesis.speak(t)}}clear(){this.#t.emit("playing",!1)}start(e,t=!1){this.#o=Array.isArray(e)?e:[e],t||(window.speechSynthesis.cancel(),this.#s=0),this.speak()}stop(){window.speechSynthesis.cancel(),this.clear()}onPlaying(e){this.#t.on("playing",e)}onSpeaking(e){this.#t.on("speaking",e)}}const nr=new Map;class ir{#r;#t;#o=[];#a=new Map;#l=!1;#s=0;#c=!1;constructor(e){this.#r=e,this.#t=new B}createLoader(e){const t=new Promise(async t=>{try{const{type:r,data:n}=await this.#r(e),i=new Audio(`data:${r};base64,${n}`);this.#a.set(e,i),t(i)}catch{this.#a.delete(e),t(void 0)}});return this.#a.set(e,t),t}async loadAudioData(){this.#c=!0,this.#t.emit("speaking",!0);let e=0;for(;e<this.#o.length;){const t=this.#o[e];!this.#a.has(t)&&this.#c&&await this.createLoader(t),e++}this.#t.emit("speaking",!1),this.#c=!1}waitForAudioLoaded(e){const t=this.#a.get(e);return t instanceof Promise?t:Promise.resolve(t)}async playAudio(e=0){this.#l=!0;const t=await this.waitForAudioLoaded(this.#o[e]);this.#t.emit("playing",!0),t?(nr.set(this,t),t.onpause=async()=>{t.ended?(this.#s++,this.#s<this.#o.length?await this.playAudio(this.#s):this.clear()):this.clear()},await t.play()):this.clear()}clear(){this.#l=!1,this.#c=!1,this.#t.emit("playing",!1),this.#t.emit("speaking",!1),nr.delete(this)}start(e,t=!1){nr.forEach((e,t)=>{t!==this&&(e.pause(),e.currentTime=0)}),this.#o=Array.isArray(e)?e:[e],t||(this.#s=0),this.#c||this.loadAudioData(),this.#l||this.playAudio()}update(e){this.#o=Array.isArray(e)?e:[e]}stop(){const e=nr.get(this);e&&(e.pause(),e.currentTime=0)}onPlaying(e){this.#t.on("playing",e)}onSpeaking(e){this.#t.on("speaking",e)}}function or({text:e,loading:t,loader:r}){const n=M(),[i,o]=C(!1),[s,a]=C(!1),l=M(t),c=async(i=!1)=>{n.current||(n.current=r?new ir(r):new rr,n.current.onSpeaking(o),n.current.onPlaying(a));let s="";"string"==typeof e?s=e:e.current&&(s=function(e){const t=e.querySelectorAll("p, h1, h2, h3, h4, h5, h6, li:not(:has(p,h1, h2, h3, h4, h5, h6))");return Array.from(t).flatMap(e=>e.textContent?[e.textContent]:[])}(e.current),t&&s.pop()),s&&0!==s.length&&n.current.start(s,i)};return $(()=>{if(l.current&&"string"!=typeof e&&e.current){if(t){const t={childList:!0,subtree:!0},r=new MutationObserver(function(){c(!0)});return r.observe(e.current,t),c(),()=>{r.disconnect()}}c(!0)}},[t]),$(()=>()=>{n.current&&(n.current.stop(),n.current=void 0)},[]),{playing:s,speaking:i,start:c,stop:()=>{n.current&&n.current.stop()}}}function sr({model:r="builtin",voice:n,loading:i,autoplay:o,contentRef:s,avatarRef:a}){const{request:l}=ye(),c=R(()=>{if("builtin"!==r)return async e=>(await l({url:"/speech",method:"post",data:{model:r,voice:n,input:e}})).audio},[r,n]),{playing:d,speaking:m,start:u,stop:h}=or({loader:c,text:s,loading:o&&i});let p=null;return a.current&&(m&&(p=ue(e(ar,{children:e(L,{size:"sm",variant:"light"})}),a.current)),d&&(p=ue(e(ar,{children:e(lr,{className:"bi bi-volume-down-fill text-light"})}),a.current))),t(qt,{disabled:i&&!d,onClick:()=>{d?h():u()},children:[d?e(lr,{className:"bi bi-volume-down-fill"}):m?e(L,{size:"sm",variant:"primary"}):e(lr,{className:"bi bi-volume-down"}),p]})}const ar=n.div`
|
|
657
725
|
position: absolute;
|
|
658
726
|
top: 0;
|
|
659
727
|
left: 0;
|
|
@@ -663,20 +731,27 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
663
731
|
align-items: center;
|
|
664
732
|
justify-content: center;
|
|
665
733
|
background-color: rgba(0, 0, 0, .3);
|
|
666
|
-
`,
|
|
734
|
+
`,lr=n.i`
|
|
667
735
|
|
|
668
736
|
&::before {
|
|
669
737
|
transform: scale(1.4)
|
|
670
738
|
}
|
|
671
|
-
`;function
|
|
739
|
+
`;function cr({tool:r,loading:n}){const{logLevel:i="none",renderToolContent:o}=ye(),s="response"in r,a=!s&&!n,{response:l,title:c,content:d,showStatus:m,defaultExpanded:u}=R(()=>{const n=(e=>{try{return JSON.parse(e.arguments)}catch(e){return null}})(r),i=e("span",{className:"text-truncate",children:r.title}),a=t("div",{className:"border-top p-2 d-flex flex-column gap-2",children:[t("div",{className:"border rounded bg-light",children:[e("div",{className:"d-flex align-items-center p-1 px-2 fs-7 gap-2",children:e("span",{className:"text-muted",children:"参数"})}),e(mr,{className:"border-top p-2",children:r.arguments})]}),s&&t("div",{className:"border rounded bg-light",children:[e("div",{className:"d-flex align-items-center p-1 px-2 fs-7 gap-2",children:e("span",{className:"text-muted",children:"响应"})}),e(mr,{className:"border-top p-2",children:r.response||"None"})]})]}),l=r.content&&e(Zt,{value:r.content});if(o){const e=o({tool:r,args:n});if(e)return{title:null===e.title?null:e.title??i,response:null===e.response?null:e.response??a,content:null===e.content?null:e.content??l,showStatus:e.showStatus??!0,defaultExpanded:e.defaultExpanded??!1}}return{title:i,response:a,content:l,showStatus:!0,defaultExpanded:!1}},[r,o]),[h,p]=C(u),g="all"==i&&null!==l;return t(F,{children:[c&&e("div",{className:"mb-2",children:t(dr,{className:"shadow-sm rounded bg-white fs-7",$open:h,children:[t("div",{onClick:()=>p(g&&!h),role:"button",className:"d-flex align-items-center flex-nowrap p-1 px-2 gap-2",children:[a?e("i",{className:"bi bi-dash-circle-fill text-muted"}):s?r.error?e("i",{className:"bi bi-x-circle-fill text-danger"}):e("i",{className:"bi bi-check-circle-fill text-success"}):e(L,{animation:"border",variant:"primary",size:"sm"}),m&&e("span",{className:"text-muted",children:a?"已取消":s?"已使用":"正在使用"}),c,g&&e("i",h?{className:"bi bi-caret-up-fill text-muted"}:{className:"bi bi-caret-down-fill text-muted"})]}),h&&l]})}),d]})}const dr=n.div`
|
|
740
|
+
width: ${e=>e.$open?"auto":"fit-content"};
|
|
741
|
+
max-width: 100%;
|
|
742
|
+
overflow:hidden;
|
|
743
|
+
`,mr=n.div`
|
|
672
744
|
white-space: pre-wrap;
|
|
673
|
-
|
|
745
|
+
overflow-y: auto;
|
|
746
|
+
overflow-x: hidden;
|
|
747
|
+
max-height: 150px;
|
|
748
|
+
`;function ur({node:r}){const[n,i]=C(!1),{nodeIconResolver:o}=ye(),s=!("latency"in r),a=s?e(L,{animation:"border",variant:"primary",size:"sm"}):r.error?e("i",{className:"bi bi-x-circle-fill text-danger"}):e("i",{className:"bi bi-check-circle-fill text-success"});return t("div",{className:"shadow-sm rounded bg-white fs-7",children:[t(pr,{onClick:()=>i(e=>!e),role:"button",className:"d-flex align-items-center p-1 px-2 gap-1",children:[e("i",{className:"bi bi-chevron-down text-muted"}),o?.(r.type),e(gr,{className:"me-2 text-truncate",children:r.title}),e("span",{className:"me-auto"}),!s&&e("span",{className:"text-nowrap text-muted",children:hr(r.latency)}),e("span",{children:a})]}),n&&t("div",{className:"border-top p-2 d-flex flex-column gap-2",children:[t("div",{className:"border rounded bg-light",children:[e("div",{className:"d-flex align-items-center p-1 px-2 fs-7 gap-2",children:e("span",{className:"text-muted",children:"输入"})}),e("div",{className:"border-top p-2 overflow-hidden text-pre-wrap",children:r.input?JSON.stringify(r.input,null,4):"None"})]}),t("div",{className:"border rounded bg-light",children:[e("div",{className:"d-flex align-items-center p-1 px-2 fs-7 gap-2",children:e("span",{className:"text-muted",children:"输出"})}),e("div",{className:"border-top p-2 overflow-hidden text-pre-wrap",children:r.output?JSON.stringify(r.output,null,4):"None"})]})]})]})}const hr=e=>e<1?`${(1e3*e).toFixed(3)} ms`:e>60?`${parseInt(Math.round(e/60).toString())} m ${(e%60).toFixed(3)} s`:`${e.toFixed(3)} s`,pr=n.div`
|
|
674
749
|
svg {
|
|
675
750
|
flex-shrink: 0;
|
|
676
751
|
}
|
|
677
|
-
`,
|
|
752
|
+
`,gr=n.span`
|
|
678
753
|
display: inline-block;
|
|
679
|
-
`;function
|
|
754
|
+
`;function fr({nodes:r,loading:n}){const[i,o]=C(!1),s=r.some(e=>"error"in e),a=n?e(L,{animation:"border",variant:"primary",size:"sm"}):e("i",s?{className:"bi bi-x-circle-fill text-danger"}:{className:"bi bi-check-circle-fill text-success"});return e("div",{className:"mb-2",children:t("div",i?{className:"shadow-sm rounded bg-white fs-7",children:[t("div",{onClick:()=>o(!1),role:"button",className:"d-flex align-items-center p-1 px-2 gap-2",children:[a,e("span",{children:"工作流"}),e("i",{className:"bi bi-caret-up-fill text-muted"})]}),e("div",{className:"border-top p-2 d-flex flex-column gap-1 bg-light bg-opacity-50",children:r.map((t,r)=>e(ur,{node:t},r))})]}:{onClick:()=>o(!0),role:"button",className:"d-inline-flex align-items-center shadow-sm rounded bg-white p-1 px-2 fs-7 gap-2",children:[a,e("span",{children:"工作流"}),e("i",{className:"bi bi-caret-down-fill text-muted"})]})})}const br=I(({message:n,actions:i,setMessage:o,cite:s,speech:a,isLast:l})=>{const{query:c,quote:d,files:m=[],chunks:u,annotation:h,loading:p}=n,{user:g,bot:f,logLevel:b="none",messages:v}=ye(),y=R(()=>u?u.reduce(function(e,t){const r=Array.isArray(t.content)?t.content.reduce((e,t)=>{const r=vt(t);return r?e+r+"\n":e},""):vt(t.content);return e+r+"\n"+(t.tools||[]).reduce((e,t)=>{if(t.content){const r=vt(t.content);if(r)return e+r+"\n"}return e},"")},""):"",[u]),w=M(null),E=M(null),N=M(null),j=R(()=>u?.flatMap(e=>e.node?[e.node]:[])||[],[u]),$=c||m.length>0;return t(r,{children:[$&&t(Mr,{$reverse:!0,children:[g&&e(jr,{children:e("img",{src:g.avatar})}),e($r,{}),t(Cr,{ref:w,children:[c&&e(jt,{content:c}),d&&e(O,{trigger:"click",container:w,rootClose:!0,placement:"bottom",overlay:e(vr,{body:!0,children:d}),children:e(yr,{children:e(xr,{children:d})})}),m.length>0&&m.map(({name:t,size:r,path:n},i)=>k(n)?e(At,{src:`/uploads/${n}`},i):e(wr,{children:e(Ne,{name:t,url:`/uploads/${n}`,size:r})},i))]})]}),u&&t(Mr,{children:[f&&e(jr,{ref:E,children:e("img",{src:f.avatar})}),e($r,{}),t(Cr,{children:[$&&!1!==i&&t(Er,{children:[e(x,{placement:"top",content:y,as:qt,tooltip:!0}),a&&e(sr,{loading:n.loading,avatarRef:E,contentRef:N,...a}),i?.({Component:qt,message:n,content:y,setMessage:o,messages:v})]}),e(Nr,{children:["stats","all"].includes(b)&&n.stats&&t(r,{children:[t("span",{children:["耗时 ",n.stats.latency/1e3," 秒"]}),t("span",{children:["花费 Token ",n.stats.usage]})]})}),t(kr,{ref:N,$deleted:!!h,children:["all"===b&&j.length>0&&e(fr,{loading:p,nodes:j}),u.map((r,n)=>t(F,{children:[r.reasoning&&["stats","all"].includes(b)&&e(tr,{reasoning:r.reasoning,loading:!r.content&&0===(r.tools||[]).length}),r.content&&e(Ft,{value:{chunkIndex:n,chunk:r,isLastMessage:l},children:e(Zt,{cite:s,value:r.content})}),(r.tools||[]).map((t,i)=>e(Ft,{value:{chunkIndex:n,chunk:r,toolIndex:i,tool:t,isLastMessage:l},children:e(cr,{tool:t,loading:p})},i)),r.error&&e(jt,{content:`[${r.error}]`})]},n))]}),h&&t("div",{children:[t("div",{className:"d-flex align-items-center",children:[e("span",{className:"fs-7 text-secondary me-2",children:"标注的答案"}),e("hr",{className:"flex-fill"})]}),e(jt,{content:h.answer})]}),n.loading&&e(bt,{})]})]})]})}),vr=n(_)`
|
|
680
755
|
max-width: calc(100% - .875rem * 2);
|
|
681
756
|
width: calc(100% - .875rem * 2);
|
|
682
757
|
font-size: 1rem;
|
|
@@ -685,25 +760,25 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
685
760
|
.popover-body {
|
|
686
761
|
padding: .5rem .75rem;
|
|
687
762
|
}
|
|
688
|
-
`,
|
|
763
|
+
`,xr=n.div`
|
|
689
764
|
overflow: hidden;
|
|
690
765
|
text-overflow: ellipsis;
|
|
691
766
|
word-break: break-all;
|
|
692
767
|
-webkit-line-clamp: 2;
|
|
693
768
|
-webkit-box-orient: vertical;
|
|
694
769
|
display: -webkit-box;
|
|
695
|
-
`,
|
|
770
|
+
`,yr=n.div`
|
|
696
771
|
padding: .5rem .75rem;
|
|
697
772
|
color: var(--bs-secondary);
|
|
698
773
|
border-radius: var(--bs-border-radius-lg);
|
|
699
774
|
background: #FFFFFF;
|
|
700
775
|
cursor: pointer;
|
|
701
|
-
`,
|
|
776
|
+
`,kr=n.div`
|
|
702
777
|
${e=>e.$deleted&&i`
|
|
703
778
|
text-decoration-line: line-through;
|
|
704
779
|
color: var(--bs-secondary);
|
|
705
780
|
`}
|
|
706
|
-
`,
|
|
781
|
+
`,wr=n.div`
|
|
707
782
|
width: 100%;
|
|
708
783
|
margin-bottom: .5rem;
|
|
709
784
|
margin-top: .5rem;
|
|
@@ -715,7 +790,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
715
790
|
&:last-child {
|
|
716
791
|
margin-bottom: 0;
|
|
717
792
|
}
|
|
718
|
-
`,
|
|
793
|
+
`,Er=n.div`
|
|
719
794
|
position: absolute;
|
|
720
795
|
top: -1.1rem;
|
|
721
796
|
right: 0;
|
|
@@ -723,7 +798,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
723
798
|
gap: .5rem;
|
|
724
799
|
opacity: 0;
|
|
725
800
|
z-index: 1;
|
|
726
|
-
`,
|
|
801
|
+
`,Nr=n.div`
|
|
727
802
|
position: absolute;
|
|
728
803
|
bottom: -1.4rem;
|
|
729
804
|
left: 0;
|
|
@@ -736,7 +811,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
736
811
|
display: flex;
|
|
737
812
|
opacity: 0;
|
|
738
813
|
z-index: 1;
|
|
739
|
-
`,
|
|
814
|
+
`,jr=n.div`
|
|
740
815
|
width: 35px;
|
|
741
816
|
height: 35px;
|
|
742
817
|
border-radius: 50%;
|
|
@@ -747,14 +822,14 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
747
822
|
width: 100%;
|
|
748
823
|
height: 100%;
|
|
749
824
|
}
|
|
750
|
-
|
|
825
|
+
`,$r=n.div`
|
|
751
826
|
width: 0;
|
|
752
827
|
height: 0;
|
|
753
828
|
content: "";
|
|
754
829
|
border: 5px solid transparent;
|
|
755
830
|
border-right-color: #f3f3f3;
|
|
756
831
|
transform: translateY(10px);
|
|
757
|
-
`,
|
|
832
|
+
`,Cr=n.div`
|
|
758
833
|
padding: .875rem;
|
|
759
834
|
background-color: rgb(243, 243, 243);
|
|
760
835
|
border-radius: var(--bs-border-radius-lg);
|
|
@@ -762,31 +837,31 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
762
837
|
position: relative;
|
|
763
838
|
|
|
764
839
|
&:hover {
|
|
765
|
-
${
|
|
840
|
+
${Nr}, ${Er} {
|
|
766
841
|
opacity: 1;
|
|
767
842
|
}
|
|
768
843
|
}
|
|
769
|
-
`,
|
|
844
|
+
`,Mr=n.div`
|
|
770
845
|
display: flex;
|
|
771
846
|
justify-content: flex-start;
|
|
772
847
|
padding: 1rem 0 1rem 0;
|
|
773
848
|
${e=>e.$reverse&&i`
|
|
774
849
|
flex-direction: row-reverse;
|
|
775
850
|
|
|
776
|
-
${
|
|
851
|
+
${$r} {
|
|
777
852
|
border-left-color: rgba(var(--bs-primary-rgb), 0.1);
|
|
778
853
|
border-right-color: transparent;
|
|
779
854
|
}
|
|
780
855
|
|
|
781
|
-
${
|
|
856
|
+
${Cr} {
|
|
782
857
|
background: rgba(var(--bs-primary-rgb), 0.1);
|
|
783
858
|
}
|
|
784
859
|
`};
|
|
785
|
-
`;function
|
|
860
|
+
`;function Sr(r){const{placeholder:n,actions:i,cite:o,speech:s,renderItem:a,scrollRef:l}=r,{messages:c,setMessages:d,loading:m,suggestions:u,conversationId:h}=ye(),p=M(r.loaded),g=S(()=>{const e=l.current;e&&requestAnimationFrame(()=>{e.scrollTo({top:e.scrollHeight})})},[]),f=M(null),{height:b}=he({ref:f});$(()=>{(m||!p.current)&&c.length>0&&(m&&(p.current=!0),g())},[b,m,p,c]),$(()=>{u.length>0&&g()},[u]),$(()=>{p.current=r.loaded},[h]),$(()=>{const e=f.current;if(e){const t=()=>{p.current=!0};return e.addEventListener("click",t),()=>{e.removeEventListener("click",t)}}},[f]);const v=c.slice(-30);return t(qr,{ref:f,children:[0===v.length&&n,v.map((t,r)=>{const n={actions:i,cite:o,speech:s,message:t,setMessage:e=>{d(r=>{const n=r.findIndex(e=>e.id===t.id);-1!==n&&e(r[n])})},isLast:r===v.length-1};return a?a({Component:br,props:n},r):e(br,{...n},r)}),u.length>0&&e(Rr,{children:u.map((t,r)=>e("a",{href:"#!question",children:t},r))})]})}const qr=n.div`
|
|
786
861
|
display: flex;
|
|
787
862
|
flex-direction: column;
|
|
788
863
|
flex: 1;
|
|
789
|
-
`,
|
|
864
|
+
`,Rr=n.div`
|
|
790
865
|
display: flex;
|
|
791
866
|
flex-direction: column;
|
|
792
867
|
align-items: flex-start;
|
|
@@ -803,16 +878,16 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
803
878
|
background: var(--bs-secondary-bg-subtle);
|
|
804
879
|
}
|
|
805
880
|
}
|
|
806
|
-
`,
|
|
881
|
+
`,zr=I(q(({className:r,bot:n,user:i,input:o,logLevel:s,imageResolver:a,nodeIconResolver:l,placeholder:c,actions:d,onboarding:m,conversation:u,cite:h,speech:p,renderItem:f,renderFileItem:b,renderToolContent:x,renderReasoning:y,messages:k,request:E,onReset:N,transformMessages:j=mt},q)=>{const F=S(e=>{const t=[];if(m&&!1!==m.enable){const e=ut(m.questions||[]);t.push({chunks:[{content:[m.prologue,...e.map(e=>`[${e}](#!question)`)].join("\n"),tools:[]}],loading:m.loading})}return e?t.concat(j(e.messages||[])):k?t.concat(j(k)):t},[m]),[I,A]=C(u?.id),[D,L]=C(),[T,P]=g([]);$(()=>{P(F(u))},[m]);const[O,_]=C(!1),B=M(null),[U,H]=C([]),J=S(e=>{A(e?.id),P(F(e)),H([]),_(!1),N?.(e)},[O,F,N]);return z(q,()=>({reset:J}),[J]),e(ke,{request:R(()=>E?"string"==typeof E?w.create({baseURL:E}):E:w,[E]),bot:n,user:i,logLevel:s,imageResolver:a,nodeIconResolver:l,conversationId:I,setConversationId:A,input:D,setInput:L,messages:T,setMessages:P,suggestions:U,setSuggestions:H,loading:O,setLoading:_,renderFileItem:b,reset:J,readonly:!o,renderToolContent:x,renderReasoning:y,children:e(Ir,{className:r,children:t(v,{children:[e(Fr,{ref:B,children:e(Sr,{placeholder:c,cite:h,actions:d,loaded:!o,speech:p,renderItem:f,scrollRef:B})}),o&&e(et,{...o,scrollRef:B})]})})})}),te),Fr=n.div`
|
|
807
882
|
display: flex;
|
|
808
883
|
flex-direction: column;
|
|
809
884
|
flex: 1;
|
|
810
885
|
overflow-y: auto;
|
|
811
886
|
padding: 0 1rem;
|
|
812
887
|
margin-bottom: .5rem;
|
|
813
|
-
`,
|
|
888
|
+
`,Ir=n.div`
|
|
814
889
|
display: flex;
|
|
815
890
|
flex-direction: column;
|
|
816
891
|
height: 100%;
|
|
817
892
|
position: relative;
|
|
818
|
-
`;export{
|
|
893
|
+
`;async function Ar(e){const t=await pe().use(fe).use(se).use(ae).use(le).use(be).use(ge).process(e);return String(t)}export{Le as ActionButton,Ne as FileItem,jt as Markdown,zr as MessageBox,Re as VariableForm,ve as isToolMessage,Ar as md2html,ut as pickQuestions,ye as useMessageContext,or as useSynthesis};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as c from"react";var h,l,e;function t(){return t=Object.assign?Object.assign.bind():function(c){for(var h=1;h<arguments.length;h++){var l=arguments[h];for(var e in l)({}).hasOwnProperty.call(l,e)&&(c[e]=l[e])}return c},t.apply(null,arguments)}const a=a=>c.createElement("svg",t({xmlns:"http://www.w3.org/2000/svg",width:200,height:200,className:"mp3_svg__icon",viewBox:"0 0 1024 1024"},a),h||(h=c.createElement("path",{fill:"#B37FEB",d:"m590.222 73.956 268.8 268.299v533.834c0 37.7-30.566 68.267-68.266 68.267H233.244c-37.7 0-68.266-30.567-68.266-68.267V142.222c0-37.7 30.566-68.266 68.266-68.266zM578.458 102.4H233.244a39.82 39.82 0 0 0-39.799 38.457l-.023 1.365V876.09a39.82 39.82 0 0 0 38.457 39.8l1.365.022h557.512a39.82 39.82 0 0 0 39.799-38.457l.023-1.365V354.054z"})),l||(l=c.createElement("path",{fill:"#B37FEB",d:"M854.756 370.648H639.613c-45.528 0-82.551-36.431-83.507-81.738l-.017-1.792V73.956h28.444v213.162c0 29.895 23.82 54.232 53.516 55.063l1.564.023h215.143zM85.333 489.244h853.334q28.444 0 28.444 28.445v284.444q0 28.445-28.444 28.445H85.333q-28.444 0-28.444-28.445V517.69q0-28.445 28.444-28.445"})),e||(e=c.createElement("path",{fill:"#FFF",d:"M291.146 750.933v-65.28c0-18.944-3.584-47.36-5.888-66.048h1.024l15.36 45.568 25.85 69.632h25.088l25.6-69.632 15.872-45.568h1.286c-2.56 18.688-6.144 47.104-6.144 66.048v65.28h41.728v-190.72h-49.664l-29.184 82.432c-3.584 11.008-6.656 23.04-10.502 34.56h-1.274c-3.584-11.52-6.656-23.552-10.502-34.56l-30.208-82.432h-49.402v190.72zm250.624-190.72c41.722 0 76.288 15.104 76.288 62.208 0 45.312-34.816 65.28-75.264 65.28h-22.272v63.232h-45.83v-190.72zm-2.56 36.352h-18.688v55.04h19.968c22.272 0 33.024-10.496 33.024-29.184 0-19.2-12.288-25.856-34.304-25.856m160.768 157.952c37.888 0 70.394-19.456 70.394-54.272 0-23.808-15.61-38.912-36.608-45.056v-1.28c19.968-8.448 30.47-22.272 30.47-40.96 0-32.768-25.862-51.456-65.28-51.456-22.528 0-41.472 9.216-59.136 23.808l23.04 27.904c11.52-10.24 21.242-16.128 34.042-16.128 14.086 0 21.766 6.912 21.766 19.456 0 13.824-10.24 23.552-42.758 23.552v32.256c39.936 0 48.64 9.216 48.64 24.832 0 13.312-11.514 20.48-29.184 20.48-14.848 0-28.16-7.68-39.68-18.432l-20.992 28.672c13.824 16.128 35.078 26.624 65.286 26.624"})));var v="data:image/svg+xml,%3csvg t='1767873372939' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='1312' width='200' height='200'%3e%3cpath d='M590.222222 73.955556L859.022222 342.254933V876.088889c0 37.700267-30.5664 68.266667-68.266666 68.266667H233.244444c-37.700267 0-68.266667-30.5664-68.266666-68.266667V142.222222c0-37.700267 30.5664-68.266667 68.266666-68.266666h356.977778z m-11.764622 28.444444H233.244444a39.822222 39.822222 0 0 0-39.799466 38.456889L193.422222 142.222222v733.866667a39.822222 39.822222 0 0 0 38.456889 39.799467L233.244444 915.911111h557.511112a39.822222 39.822222 0 0 0 39.799466-38.456889L830.577778 876.088889V354.053689L578.4576 102.4z' fill='%23B37FEB' p-id='1313'%3e%3c/path%3e%3cpath d='M854.755556 370.648178h-215.1424c-45.528178 0-82.551467-36.431644-83.5072-81.737956l-0.017067-1.792V73.955556h28.444444v213.162666c0 29.895111 23.819378 54.232178 53.515378 55.062756l1.564445 0.022755h215.1424v28.444445z' fill='%23B37FEB' p-id='1314'%3e%3c/path%3e%3cpath d='M56.888889 489.244444m28.444444 0l853.333334 0q28.444444 0 28.444444 28.444445l0 284.444444q0 28.444444-28.444444 28.444445l-853.333334 0q-28.444444 0-28.444444-28.444445l0-284.444444q0-28.444444 28.444444-28.444445Z' fill='%23B37FEB' p-id='1315'%3e%3c/path%3e%3cpath d='M291.145956 750.933333v-65.28c0-18.944-3.584-47.36-5.888-66.048h1.024l15.36 45.568 25.850311 69.632h25.088l25.6-69.632 15.872-45.568h1.285689c-2.56 18.688-6.144 47.104-6.144 66.048V750.933333h41.728V560.213333h-49.664l-29.184 82.432c-3.584 11.008-6.656 23.04-10.501689 34.56h-1.274311c-3.584-11.52-6.656-23.552-10.501689-34.56l-30.208-82.432h-49.402311V750.933333h40.96zM541.769956 560.213333c41.722311 0 76.288 15.104 76.288 62.208 0 45.312-34.816 65.28-75.264 65.28h-22.272V750.933333h-45.829689V560.213333z m-2.56 36.352h-18.688v55.04h19.968c22.272 0 33.024-10.496 33.024-29.184 0-19.2-12.288-25.856-34.304-25.856zM699.977956 754.517333c37.888 0 70.394311-19.456 70.394311-54.272 0-23.808-15.610311-38.912-36.608-45.056v-1.28c19.968-8.448 30.469689-22.272 30.469689-40.96 0-32.768-25.861689-51.456-65.28-51.456-22.528 0-41.472 9.216-59.136 23.808l23.04 27.904c11.52-10.24 21.242311-16.128 34.042311-16.128 14.085689 0 21.765689 6.912 21.765689 19.456 0 13.824-10.24 23.552-42.757689 23.552v32.256c39.936 0 48.64 9.216 48.64 24.832 0 13.312-11.514311 20.48-29.184 20.48-14.848 0-28.16-7.68-39.68-18.432l-20.992 28.672c13.824 16.128 35.077689 26.624 65.285689 26.624z' fill='white' p-id='1316'%3e%3c/path%3e%3c/svg%3e";export{a as ReactComponent,v as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as h from"react";var l,c,e,t;function a(){return a=Object.assign?Object.assign.bind():function(h){for(var l=1;l<arguments.length;l++){var c=arguments[l];for(var e in c)({}).hasOwnProperty.call(c,e)&&(h[e]=c[e])}return h},a.apply(null,arguments)}const v=v=>h.createElement("svg",a({xmlns:"http://www.w3.org/2000/svg",width:200,height:200,className:"mp4_svg__icon",viewBox:"0 0 1024 1024"},v),l||(l=h.createElement("path",{fill:"#597EF7",d:"m590.222 73.956 268.8 268.299v533.834c0 37.7-30.566 68.267-68.266 68.267H233.244c-37.7 0-68.266-30.567-68.266-68.267V142.222c0-37.7 30.566-68.266 68.266-68.266zM578.458 102.4H233.244a39.82 39.82 0 0 0-39.799 38.457l-.023 1.365V876.09a39.82 39.82 0 0 0 38.457 39.8l1.365.022h557.512a39.82 39.82 0 0 0 39.799-38.457l.023-1.365V354.054z"})),c||(c=h.createElement("path",{fill:"#597EF7",d:"M854.756 370.648H639.613c-45.528 0-82.551-36.431-83.507-81.738l-.017-1.792V73.956h28.444v213.162c0 29.895 23.82 54.232 53.516 55.063l1.564.023h215.143zM85.333 489.244h853.334q28.444 0 28.444 28.445v284.444q0 28.445-28.444 28.445H85.333q-28.444 0-28.444-28.445V517.69q0-28.445 28.444-28.445"})),e||(e=h.createElement("path",{fill:"#FFF",d:"M291.146 756.622v-65.28c0-18.944-3.584-47.36-5.888-66.048h1.024l15.36 45.568 25.85 69.632h25.088l25.6-69.632 15.872-45.568h1.286c-2.56 18.688-6.144 47.104-6.144 66.048v65.28h41.728v-190.72h-49.664l-29.184 82.432c-3.584 11.008-6.656 23.04-10.502 34.56h-1.274c-3.584-11.52-6.656-23.552-10.502-34.56l-30.208-82.432h-49.402v190.72zm250.624-190.72c41.722 0 76.288 15.104 76.288 62.208 0 45.312-34.816 65.28-75.264 65.28h-22.272v63.232h-45.83v-190.72zm-2.56 36.352h-18.688v55.04h19.968c22.272 0 33.024-10.496 33.024-29.184 0-19.2-12.288-25.856-34.304-25.856m217.594 154.368v-43.264h20.992v-34.816h-20.992V570.766h-56.32l-66.298 110.848v31.744h80.128v43.264z"})),t||(t=h.createElement("path",{fill:"#FFF",d:"M714.314 678.542H677.7l21.766-37.376c5.37-11.008 10.49-21.504 15.36-32.256h1.024c-.512 12.032-1.536 30.464-1.536 42.496z"})));var i="data:image/svg+xml,%3csvg t='1767873401047' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='1465' width='200' height='200'%3e%3cpath d='M590.222222 73.955556L859.022222 342.254933V876.088889c0 37.700267-30.5664 68.266667-68.266666 68.266667H233.244444c-37.700267 0-68.266667-30.5664-68.266666-68.266667V142.222222c0-37.700267 30.5664-68.266667 68.266666-68.266666h356.977778z m-11.764622 28.444444H233.244444a39.822222 39.822222 0 0 0-39.799466 38.456889L193.422222 142.222222v733.866667a39.822222 39.822222 0 0 0 38.456889 39.799467L233.244444 915.911111h557.511112a39.822222 39.822222 0 0 0 39.799466-38.456889L830.577778 876.088889V354.053689L578.4576 102.4z' fill='%23597EF7' p-id='1466'%3e%3c/path%3e%3cpath d='M854.755556 370.648178h-215.1424c-45.528178 0-82.551467-36.431644-83.5072-81.737956l-0.017067-1.792V73.955556h28.444444v213.162666c0 29.895111 23.819378 54.232178 53.515378 55.062756l1.564445 0.022755h215.1424v28.444445z' fill='%23597EF7' p-id='1467'%3e%3c/path%3e%3cpath d='M56.888889 489.244444m28.444444 0l853.333334 0q28.444444 0 28.444444 28.444445l0 284.444444q0 28.444444-28.444444 28.444445l-853.333334 0q-28.444444 0-28.444444-28.444445l0-284.444444q0-28.444444 28.444444-28.444445Z' fill='%23597EF7' p-id='1468'%3e%3c/path%3e%3cpath d='M291.145956 756.622222v-65.28c0-18.944-3.584-47.36-5.888-66.048h1.024l15.36 45.568 25.850311 69.632h25.088l25.6-69.632 15.872-45.568h1.285689c-2.56 18.688-6.144 47.104-6.144 66.048V756.622222h41.728V565.902222h-49.664l-29.184 82.432c-3.584 11.008-6.656 23.04-10.501689 34.56h-1.274311c-3.584-11.52-6.656-23.552-10.501689-34.56l-30.208-82.432h-49.402311V756.622222h40.96zM541.769956 565.902222c41.722311 0 76.288 15.104 76.288 62.208 0 45.312-34.816 65.28-75.264 65.28h-22.272V756.622222h-45.829689V565.902222z m-2.56 36.352h-18.688v55.04h19.968c22.272 0 33.024-10.496 33.024-29.184 0-19.2-12.288-25.856-34.304-25.856zM756.804267 756.622222v-43.264h20.992v-34.816h-20.992V570.766222h-56.32l-66.298311 110.848v31.744h80.128V756.622222z' fill='white' p-id='1469'%3e%3c/path%3e%3cpath d='M714.313956 678.542222h-36.613689l21.765689-37.376c5.370311-11.008 10.490311-21.504 15.36-32.256h1.024c-0.512 12.032-1.536 30.464-1.536 42.496v27.136z' fill='white' p-id='1470'%3e%3c/path%3e%3c/svg%3e";export{v as ReactComponent,i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as l from"react";var h,e,t;function c(){return c=Object.assign?Object.assign.bind():function(l){for(var h=1;h<arguments.length;h++){var e=arguments[h];for(var t in e)({}).hasOwnProperty.call(e,t)&&(l[t]=e[t])}return l},c.apply(null,arguments)}const a=a=>l.createElement("svg",c({xmlns:"http://www.w3.org/2000/svg",width:200,height:200,className:"py_svg__icon",viewBox:"0 0 1024 1024"},a),h||(h=l.createElement("path",{fill:"#FFA940",d:"m590.222 73.956 268.8 268.299v533.834c0 37.7-30.566 68.267-68.266 68.267H233.244c-37.7 0-68.266-30.567-68.266-68.267V142.222c0-37.7 30.566-68.266 68.266-68.266zM578.458 102.4H233.244a39.82 39.82 0 0 0-39.799 38.457l-.023 1.365V876.09a39.82 39.82 0 0 0 38.457 39.8l1.365.022h557.512a39.82 39.82 0 0 0 39.799-38.457l.023-1.365V354.054z"})),e||(e=l.createElement("path",{fill:"#FFA940",d:"M854.756 370.648H639.613c-45.528 0-82.551-36.431-83.507-81.738l-.017-1.792V73.956h28.444v213.162c0 29.895 23.82 54.232 53.516 55.063l1.564.023h215.143zM85.333 489.244h853.334q28.444 0 28.444 28.445v284.444q0 28.445-28.444 28.445H85.333q-28.444 0-28.444-28.445V517.69q0-28.445 28.444-28.445"})),t||(t=l.createElement("path",{fill:"#FFF",d:"M399.855 756.622V693.39h22.272c40.448 0 75.264-19.968 75.264-65.28 0-47.104-34.56-62.208-76.288-62.208H354.03v190.72zm19.968-99.328h-19.968v-55.04h18.688c22.016 0 34.304 6.656 34.304 25.856 0 18.688-10.752 29.184-33.024 29.184M608.5 756.622v-67.328l57.6-123.392h-47.872l-15.872 42.496c-5.376 14.336-10.502 27.648-15.872 42.496h-1.024c-5.376-14.848-10.24-28.16-15.36-42.496l-15.872-42.496h-48.64l57.344 123.392v67.328z"})));var i="data:image/svg+xml,%3csvg t='1767873272414' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='1469' width='200' height='200'%3e%3cpath d='M590.222222 73.955556L859.022222 342.254933V876.088889c0 37.700267-30.5664 68.266667-68.266666 68.266667H233.244444c-37.700267 0-68.266667-30.5664-68.266666-68.266667V142.222222c0-37.700267 30.5664-68.266667 68.266666-68.266666h356.977778z m-11.764622 28.444444H233.244444a39.822222 39.822222 0 0 0-39.799466 38.456889L193.422222 142.222222v733.866667a39.822222 39.822222 0 0 0 38.456889 39.799467L233.244444 915.911111h557.511112a39.822222 39.822222 0 0 0 39.799466-38.456889L830.577778 876.088889V354.053689L578.4576 102.4z' fill='%23FFA940' p-id='1470'%3e%3c/path%3e%3cpath d='M854.755556 370.648178h-215.1424c-45.528178 0-82.551467-36.431644-83.5072-81.737956l-0.017067-1.792V73.955556h28.444444v213.162666c0 29.895111 23.819378 54.232178 53.515378 55.062756l1.564445 0.022755h215.1424v28.444445z' fill='%23FFA940' p-id='1471'%3e%3c/path%3e%3cpath d='M56.888889 489.244444m28.444444 0l853.333334 0q28.444444 0 28.444444 28.444445l0 284.444444q0 28.444444-28.444444 28.444445l-853.333334 0q-28.444444 0-28.444444-28.444445l0-284.444444q0-28.444444 28.444444-28.444445Z' fill='%23FFA940' p-id='1472'%3e%3c/path%3e%3cpath d='M399.854933 756.622222v-63.232h22.272c40.448 0 75.264-19.968 75.264-65.28 0-47.104-34.56-62.208-76.288-62.208h-67.072V756.622222h45.824z m19.968-99.328h-19.968v-55.04h18.688c22.016 0 34.304 6.656 34.304 25.856 0 18.688-10.752 29.184-33.024 29.184zM608.500622 756.622222v-67.328l57.6-123.392h-47.872l-15.872 42.496c-5.376 14.336-10.501689 27.648-15.872 42.496h-1.024c-5.376-14.848-10.24-28.16-15.36-42.496l-15.872-42.496h-48.64l57.344 123.392V756.622222h45.568z' fill='white' p-id='1473'%3e%3c/path%3e%3c/svg%3e";export{a as ReactComponent,i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as h from"react";var v,e,t;function a(){return a=Object.assign?Object.assign.bind():function(h){for(var v=1;v<arguments.length;v++){var e=arguments[v];for(var t in e)({}).hasOwnProperty.call(e,t)&&(h[t]=e[t])}return h},a.apply(null,arguments)}const l=l=>h.createElement("svg",a({xmlns:"http://www.w3.org/2000/svg",width:200,height:200,className:"unknown_svg__icon",viewBox:"0 0 1024 1024"},l),v||(v=h.createElement("path",{fill:"#FFCA28",d:"m590.222 73.956 268.8 268.299v533.834c0 37.7-30.566 68.267-68.266 68.267H233.244c-37.7 0-68.266-30.567-68.266-68.267V142.222c0-37.7 30.566-68.266 68.266-68.266zM578.458 102.4H233.244a39.82 39.82 0 0 0-39.799 38.457l-.023 1.365V876.09a39.82 39.82 0 0 0 38.457 39.8l1.365.022h557.512a39.82 39.82 0 0 0 39.799-38.457l.023-1.365V354.054z"})),e||(e=h.createElement("path",{fill:"#FFCA28",d:"M854.756 370.648H639.613c-45.528 0-82.551-36.431-83.507-81.738l-.017-1.792V73.956h28.444v213.162c0 29.895 23.82 54.232 53.516 55.063l1.564.023h215.143zM85.333 489.244h853.334q28.444 0 28.444 28.445v284.444q0 28.445-28.444 28.445H85.333q-28.444 0-28.444-28.445V517.69q0-28.445 28.444-28.445"})),t||(t=h.createElement("path",{fill:"#FFF",d:"M294.855 756.622v-72.704h65.024v-38.144h-65.024v-41.728h75.776v-38.144h-121.6v190.72zm154.624 0v-190.72h-45.824v190.72zm163.84 0v-38.4h-74.24v-152.32h-45.824v190.72zm156.672 0v-38.4h-77.824v-40.448h63.744v-38.4h-63.744v-35.328h75.008v-38.144H646.343v190.72z"})));var c="data:image/svg+xml,%3csvg t='1767873419093' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='1621' width='200' height='200'%3e%3cpath d='M590.222222 73.955556L859.022222 342.254933V876.088889c0 37.700267-30.5664 68.266667-68.266666 68.266667H233.244444c-37.700267 0-68.266667-30.5664-68.266666-68.266667V142.222222c0-37.700267 30.5664-68.266667 68.266666-68.266666h356.977778z m-11.764622 28.444444H233.244444a39.822222 39.822222 0 0 0-39.799466 38.456889L193.422222 142.222222v733.866667a39.822222 39.822222 0 0 0 38.456889 39.799467L233.244444 915.911111h557.511112a39.822222 39.822222 0 0 0 39.799466-38.456889L830.577778 876.088889V354.053689L578.4576 102.4z' fill='%23FFCA28' p-id='1622'%3e%3c/path%3e%3cpath d='M854.755556 370.648178h-215.1424c-45.528178 0-82.551467-36.431644-83.5072-81.737956l-0.017067-1.792V73.955556h28.444444v213.162666c0 29.895111 23.819378 54.232178 53.515378 55.062756l1.564445 0.022755h215.1424v28.444445z' fill='%23FFCA28' p-id='1623'%3e%3c/path%3e%3cpath d='M56.888889 489.244444m28.444444 0l853.333334 0q28.444444 0 28.444444 28.444445l0 284.444444q0 28.444444-28.444444 28.444445l-853.333334 0q-28.444444 0-28.444444-28.444445l0-284.444444q0-28.444444 28.444444-28.444445Z' fill='%23FFCA28' p-id='1624'%3e%3c/path%3e%3cpath d='M294.855111 756.622222v-72.704h65.024v-38.144H294.855111v-41.728h75.776v-38.144H249.031111V756.622222zM449.479111 756.622222V565.902222h-45.824V756.622222zM613.319111 756.622222v-38.4H539.079111V565.902222h-45.824V756.622222zM769.991111 756.622222v-38.4h-77.824v-40.448h63.744v-38.4H692.167111v-35.328h75.008v-38.144h-120.832V756.622222z' fill='white' p-id='1625'%3e%3c/path%3e%3c/svg%3e";export{l as ReactComponent,c as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topthink/chat",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"module": "es/index.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -10,25 +10,29 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@babel/runtime": "^7.11.2",
|
|
13
|
+
"@block-kit/core": "^1.0.22",
|
|
14
|
+
"@block-kit/variable": "^1.0.21",
|
|
13
15
|
"@breezystack/lamejs": "^1.2.7",
|
|
14
|
-
"@topthink/components": "
|
|
15
|
-
"@types/hast": "^
|
|
16
|
+
"@topthink/components": "1.2.0",
|
|
17
|
+
"@types/hast": "^3.0.4",
|
|
16
18
|
"@types/mdast": "^4.0.4",
|
|
17
19
|
"eventemitter3": "^5.0.1",
|
|
18
|
-
"hast-util-to-string": "^
|
|
19
|
-
"katex": "^0.16.
|
|
20
|
-
"mdast-util-from-markdown": "^2.0.
|
|
21
|
-
"micromark-util-character": "^2.1.
|
|
22
|
-
"micromark-util-symbol": "^2.0.
|
|
23
|
-
"micromark-util-types": "^2.0.
|
|
24
|
-
"react-markdown": "^
|
|
25
|
-
"
|
|
26
|
-
"rehype-
|
|
27
|
-
"rehype-
|
|
28
|
-
"remark-breaks": "^
|
|
29
|
-
"remark-gfm": "^
|
|
30
|
-
"remark-math": "^
|
|
31
|
-
"
|
|
20
|
+
"hast-util-to-string": "^3.0.1",
|
|
21
|
+
"katex": "^0.16.28",
|
|
22
|
+
"mdast-util-from-markdown": "^2.0.2",
|
|
23
|
+
"micromark-util-character": "^2.1.1",
|
|
24
|
+
"micromark-util-symbol": "^2.0.1",
|
|
25
|
+
"micromark-util-types": "^2.0.2",
|
|
26
|
+
"react-markdown": "^10.1.0",
|
|
27
|
+
"rehype-highlight": "^7.0.2",
|
|
28
|
+
"rehype-katex": "^7.0.1",
|
|
29
|
+
"rehype-stringify": "^10.0.1",
|
|
30
|
+
"remark-breaks": "^4.0.0",
|
|
31
|
+
"remark-gfm": "^4.0.1",
|
|
32
|
+
"remark-math": "^6.0.0",
|
|
33
|
+
"remark-parse": "^11.0.0",
|
|
34
|
+
"remark-rehype": "^11.1.2",
|
|
35
|
+
"unified": "^11.0.5",
|
|
32
36
|
"use-resize-observer": "^9.1.0"
|
|
33
37
|
},
|
|
34
38
|
"peerDependencies": {
|
|
@@ -60,6 +64,7 @@
|
|
|
60
64
|
},
|
|
61
65
|
"author": "yunwuxin <tzzhangyajun@qq.com> (https://github.com/yunwuxin)",
|
|
62
66
|
"license": "MIT",
|
|
67
|
+
"gitHead": "4253c979c79485d87650d73049657e2889f36fe1",
|
|
63
68
|
"scripts": {
|
|
64
69
|
"prebuild": "rimraf es types",
|
|
65
70
|
"build": "rollup -c --environment NODE_ENV:production",
|
|
@@ -5,5 +5,5 @@ interface Props {
|
|
|
5
5
|
components?: Components;
|
|
6
6
|
cite?: Components['cite'];
|
|
7
7
|
}
|
|
8
|
-
declare const Markdown: import("react").MemoExoticComponent<(
|
|
8
|
+
declare const Markdown: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLDivElement>>>;
|
|
9
9
|
export default Markdown;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Chunk } from '../../types';
|
|
1
|
+
import { Chunk, ToolMessage } from '../../types';
|
|
2
2
|
interface ContextType {
|
|
3
|
-
|
|
3
|
+
chunkIndex: number;
|
|
4
4
|
chunk: Chunk;
|
|
5
|
+
toolIndex?: number;
|
|
6
|
+
tool?: ToolMessage;
|
|
5
7
|
isLastMessage: boolean;
|
|
6
8
|
}
|
|
7
9
|
declare const _default: import("react").Provider<ContextType | null>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Dispatch, PropsWithChildren, ReactNode, SetStateAction } from 'react';
|
|
2
|
-
import { Conversation, LogLevel, Message } from '../../types';
|
|
1
|
+
import { ComponentType, Dispatch, PropsWithChildren, ReactElement, ReactNode, SetStateAction } from 'react';
|
|
2
|
+
import { Conversation, Input, LogLevel, Message, ToolMessage } from '../../types';
|
|
3
3
|
import { Updater } from '@topthink/components/types/hooks/use-immer';
|
|
4
4
|
import { RequestInstance } from '@topthink/components';
|
|
5
|
+
import { FileItemProps } from './file-item';
|
|
6
|
+
import { ReasoningProps } from './reasoning';
|
|
5
7
|
interface Handles {
|
|
6
8
|
onSuccess?: () => void;
|
|
7
9
|
onComplete?: () => void;
|
|
@@ -10,6 +12,23 @@ interface Handles {
|
|
|
10
12
|
data?: any;
|
|
11
13
|
}) => void;
|
|
12
14
|
}
|
|
15
|
+
export interface ToolRenderOptions {
|
|
16
|
+
/** 工具消息原始数据 */
|
|
17
|
+
tool: ToolMessage;
|
|
18
|
+
/** 解析后的参数对象 */
|
|
19
|
+
args: any;
|
|
20
|
+
}
|
|
21
|
+
export interface ToolRenderResult {
|
|
22
|
+
/** 工具的完整描述文本(包含标题和详细信息) */
|
|
23
|
+
title?: ReactNode;
|
|
24
|
+
/** 自定义的响应内容 UI,返回 null 则不显示内容区域 */
|
|
25
|
+
content?: ReactNode;
|
|
26
|
+
response?: ReactNode;
|
|
27
|
+
/** 是否显示状态文本(如"已使用"、"正在使用"等),默认为 true */
|
|
28
|
+
showStatus?: boolean;
|
|
29
|
+
/** 是否默认展开详情 */
|
|
30
|
+
defaultExpanded?: boolean;
|
|
31
|
+
}
|
|
13
32
|
interface ContextType {
|
|
14
33
|
bot?: {
|
|
15
34
|
name: string;
|
|
@@ -25,6 +44,8 @@ interface ContextType {
|
|
|
25
44
|
nodeIconResolver?: (type: string) => ReactNode;
|
|
26
45
|
conversationId?: string;
|
|
27
46
|
setConversationId: Dispatch<SetStateAction<string | undefined>>;
|
|
47
|
+
input?: Input;
|
|
48
|
+
setInput: Dispatch<SetStateAction<Input | undefined>>;
|
|
28
49
|
messages: Message[];
|
|
29
50
|
setMessages: Updater<Message[]>;
|
|
30
51
|
suggestions: string[];
|
|
@@ -35,6 +56,16 @@ interface ContextType {
|
|
|
35
56
|
readonly: boolean;
|
|
36
57
|
handles: Handles;
|
|
37
58
|
setHandles: Dispatch<SetStateAction<Handles>>;
|
|
59
|
+
renderFileItem?: (props: {
|
|
60
|
+
Component: ComponentType<FileItemProps>;
|
|
61
|
+
props: FileItemProps;
|
|
62
|
+
}) => ReactElement;
|
|
63
|
+
renderReasoning?: (props: {
|
|
64
|
+
Component: ComponentType<ReasoningProps>;
|
|
65
|
+
props: ReasoningProps;
|
|
66
|
+
}) => ReactElement;
|
|
67
|
+
/** 自定义工具渲染函数 */
|
|
68
|
+
renderToolContent?: (options: ToolRenderOptions) => ToolRenderResult | undefined;
|
|
38
69
|
}
|
|
39
70
|
export declare function useContext(handles?: Handles): ContextType;
|
|
40
71
|
export declare function Provider({ children, ...props }: PropsWithChildren<Omit<ContextType, 'handles' | 'setHandles'>>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
interface
|
|
1
|
+
export interface FileItemProps {
|
|
2
2
|
className?: string;
|
|
3
3
|
name: string;
|
|
4
|
-
size
|
|
4
|
+
size?: number;
|
|
5
|
+
url?: string;
|
|
5
6
|
loading?: boolean;
|
|
6
7
|
error?: string;
|
|
7
8
|
onRemove?: () => void;
|
|
9
|
+
onClick?: () => void;
|
|
8
10
|
}
|
|
9
|
-
export default function FileItem(
|
|
10
|
-
export {};
|
|
11
|
+
export default function FileItem(props: FileItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { RequestInstance } from '@topthink/components';
|
|
2
|
-
import { MutableRefObject, ReactNode } from 'react';
|
|
2
|
+
import { ComponentType, MutableRefObject, ReactElement, ReactNode } from 'react';
|
|
3
3
|
import { Conversation, ConversationMessage, Input, LogLevel, Message, MessageBoxType, Variable } from '../../types';
|
|
4
|
-
import
|
|
4
|
+
import { MessageActions, MessageItemProps } from './message-item';
|
|
5
|
+
import { ToolRenderOptions, ToolRenderResult } from './context';
|
|
5
6
|
import { Components } from 'react-markdown';
|
|
7
|
+
import { FileItemProps } from './file-item';
|
|
8
|
+
import { ReasoningProps } from './reasoning';
|
|
6
9
|
export interface MessageBoxProps {
|
|
7
10
|
className?: string;
|
|
8
11
|
bot?: {
|
|
@@ -55,10 +58,21 @@ export interface MessageBoxProps {
|
|
|
55
58
|
actions?: MessageActions;
|
|
56
59
|
cite?: Components['cite'];
|
|
57
60
|
renderItem?: (props: {
|
|
58
|
-
Component:
|
|
61
|
+
Component: ComponentType<MessageItemProps>;
|
|
59
62
|
props: MessageItemProps;
|
|
60
63
|
}, index: number) => ReactNode;
|
|
64
|
+
renderFileItem?: (props: {
|
|
65
|
+
Component: ComponentType<FileItemProps>;
|
|
66
|
+
props: FileItemProps;
|
|
67
|
+
}) => ReactElement;
|
|
68
|
+
renderReasoning?: (props: {
|
|
69
|
+
Component: ComponentType<ReasoningProps>;
|
|
70
|
+
props: ReasoningProps;
|
|
71
|
+
}) => ReactElement;
|
|
72
|
+
/** 自定义工具渲染函数,用于定制工具调用的显示样式 */
|
|
73
|
+
renderToolContent?: (options: ToolRenderOptions) => ToolRenderResult | undefined;
|
|
61
74
|
transformMessages?: (messages: any[]) => Message[];
|
|
75
|
+
onReset?: (conversation?: Conversation) => void;
|
|
62
76
|
}
|
|
63
77
|
declare const MessageBox: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<MessageBoxProps & import("react").RefAttributes<MessageBoxType>>>;
|
|
64
78
|
export default MessageBox;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MutableRefObject, ReactNode } from 'react';
|
|
2
2
|
import { Input, Variable } from '../../../types';
|
|
3
|
+
import '@block-kit/variable/dist/style/index.css';
|
|
3
4
|
interface Props {
|
|
4
5
|
suggestion?: boolean;
|
|
5
6
|
variables?: {
|
|
@@ -11,6 +12,7 @@ interface Props {
|
|
|
11
12
|
model?: string;
|
|
12
13
|
};
|
|
13
14
|
minRows?: number;
|
|
15
|
+
maxRows?: number;
|
|
14
16
|
scrollRef: MutableRefObject<HTMLDivElement | null>;
|
|
15
17
|
toolbar?: ReactNode | true;
|
|
16
18
|
disabled?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
interface
|
|
1
|
+
export interface ReasoningProps {
|
|
2
2
|
reasoning: string;
|
|
3
3
|
loading?: boolean;
|
|
4
4
|
}
|
|
5
|
-
declare const Reasoning: import("react").MemoExoticComponent<(
|
|
5
|
+
declare const Reasoning: import("react").MemoExoticComponent<(props: ReasoningProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
6
|
export default Reasoning;
|
|
@@ -2,7 +2,7 @@ import { PropsWithChildren } from 'react';
|
|
|
2
2
|
interface ContextType {
|
|
3
3
|
resume: (payload: any) => void;
|
|
4
4
|
disabled: boolean;
|
|
5
|
-
|
|
5
|
+
response: any;
|
|
6
6
|
}
|
|
7
7
|
export declare function useSuspend(): ContextType;
|
|
8
8
|
export declare function Provider({ children, ...props }: PropsWithChildren<ContextType>): import("react/jsx-runtime").JSX.Element;
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export * from './types';
|
|
2
2
|
export { default as MessageBox, MessageBoxProps } from './components/message-box';
|
|
3
|
+
export { useContext as useMessageContext, ToolRenderOptions, ToolRenderResult } from './components/message-box/context';
|
|
3
4
|
export { default as ActionButton } from './components/action-button';
|
|
4
5
|
export { default as Markdown } from './components/markdown';
|
|
5
6
|
export { default as VariableForm } from './components/variable-form';
|
|
7
|
+
export { default as FileItem } from './components/message-box/file-item';
|
|
6
8
|
export { default as pickQuestions } from './utils/pick-questions';
|
|
7
9
|
export { default as useSynthesis } from './speech/use-synthesis';
|
|
10
|
+
export { ContentChangeEvent } from '@block-kit/core';
|
|
11
|
+
export { default as md2html } from './utils/md2html';
|
package/types/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Editor } from '@block-kit/variable';
|
|
1
2
|
export interface FormField {
|
|
2
3
|
name: string;
|
|
3
4
|
label: string;
|
|
4
|
-
type: 'text' | 'textarea' | 'number' | 'email' | 'tel' | 'date' | 'select';
|
|
5
|
+
type: 'text' | 'textarea' | 'number' | 'email' | 'tel' | 'date' | 'select' | 'radio' | 'checkbox';
|
|
5
6
|
required: boolean;
|
|
6
7
|
placeholder?: string;
|
|
7
8
|
options?: string[];
|
|
@@ -18,6 +19,11 @@ export type SuspendType = {
|
|
|
18
19
|
description: string;
|
|
19
20
|
fields: FormField[];
|
|
20
21
|
};
|
|
22
|
+
} | {
|
|
23
|
+
type: 'confirm';
|
|
24
|
+
confirm: {
|
|
25
|
+
content: string;
|
|
26
|
+
};
|
|
21
27
|
};
|
|
22
28
|
export type ContentType = string | {
|
|
23
29
|
type: 'image';
|
|
@@ -28,15 +34,34 @@ export type ContentType = string | {
|
|
|
28
34
|
} | {
|
|
29
35
|
type: 'suspend';
|
|
30
36
|
suspend: SuspendType;
|
|
37
|
+
} | {
|
|
38
|
+
type: string;
|
|
39
|
+
[key: string]: any;
|
|
31
40
|
};
|
|
32
|
-
export interface
|
|
33
|
-
|
|
41
|
+
export interface ToolMessageConfig {
|
|
42
|
+
}
|
|
43
|
+
export interface BaseToolMessage<N extends string = string, C = ContentType> {
|
|
44
|
+
name: N;
|
|
45
|
+
title: string;
|
|
46
|
+
arguments: string;
|
|
47
|
+
response?: string;
|
|
48
|
+
error?: boolean;
|
|
49
|
+
content?: C;
|
|
50
|
+
}
|
|
51
|
+
export interface ConfiguredToolMessage<N extends string = string, C = ContentType> {
|
|
52
|
+
name: N;
|
|
34
53
|
title: string;
|
|
35
54
|
arguments: string;
|
|
36
55
|
response?: string;
|
|
37
56
|
error?: boolean;
|
|
38
|
-
content
|
|
57
|
+
content: C;
|
|
39
58
|
}
|
|
59
|
+
type ConfiguredToolMessages = {
|
|
60
|
+
[K in keyof ToolMessageConfig]: ConfiguredToolMessage<K & string, ToolMessageConfig[K]>;
|
|
61
|
+
}[keyof ToolMessageConfig];
|
|
62
|
+
export type ToolMessage = [keyof ToolMessageConfig] extends [never] ? BaseToolMessage : ConfiguredToolMessages | BaseToolMessage;
|
|
63
|
+
export declare function isToolMessage<K extends keyof ToolMessageConfig>(tool: ToolMessage, name: K): tool is ConfiguredToolMessage<K & string, ToolMessageConfig[K]> & ToolMessage;
|
|
64
|
+
export declare function isToolMessage<N extends string>(tool: ToolMessage, name: N): tool is BaseToolMessage<N>;
|
|
40
65
|
export type LogLevel = 'stats' | 'all' | 'none';
|
|
41
66
|
export interface Node {
|
|
42
67
|
title: string;
|
|
@@ -117,6 +142,7 @@ export interface SendParams {
|
|
|
117
142
|
}
|
|
118
143
|
export interface ResumeParams {
|
|
119
144
|
chunk: number;
|
|
145
|
+
tool?: number;
|
|
120
146
|
payload: any;
|
|
121
147
|
}
|
|
122
148
|
export interface Chat {
|
|
@@ -127,6 +153,7 @@ export interface MessageBoxType {
|
|
|
127
153
|
reset(conversation?: Conversation): void;
|
|
128
154
|
}
|
|
129
155
|
export interface Input extends Chat {
|
|
156
|
+
editor: Editor;
|
|
130
157
|
setQuery(query: string): void;
|
|
131
158
|
setQuote(quote: string): void;
|
|
132
159
|
focus(): void;
|
|
@@ -144,3 +171,4 @@ export interface Synthesis {
|
|
|
144
171
|
onPlaying(onPlaying: (playing: boolean) => void): void;
|
|
145
172
|
onSpeaking(onSpeaking: (speaking: boolean) => void): void;
|
|
146
173
|
}
|
|
174
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function md2html(markdown: string): Promise<string>;
|
|
@@ -10,9 +10,8 @@ declare module 'micromark-util-types' {
|
|
|
10
10
|
}
|
|
11
11
|
declare module 'unified' {
|
|
12
12
|
interface Data {
|
|
13
|
-
micromarkExtensions
|
|
14
|
-
fromMarkdownExtensions
|
|
15
|
-
[key: string]: unknown;
|
|
13
|
+
micromarkExtensions?: NonNullable<FromMarkdownOptions['extensions']>;
|
|
14
|
+
fromMarkdownExtensions?: NonNullable<FromMarkdownOptions['mdastExtensions']>;
|
|
16
15
|
}
|
|
17
16
|
interface FrozenProcessor {
|
|
18
17
|
data(): Data;
|