@topthink/chat 1.3.4 → 1.3.6
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/index.js +1 -1
- package/package.json +3 -3
- package/types/types.d.ts +2 -0
package/es/index.js
CHANGED
|
@@ -247,7 +247,7 @@ import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
247
247
|
border: var(--bs-border-width) var(--bs-border-style) ${e=>e.$focused?"var(--bs-primary)":"var(--bs-border-color)"};
|
|
248
248
|
border-radius: var(--bs-border-radius-lg);
|
|
249
249
|
box-shadow: 0.125rem 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
|
|
250
|
-
`;function at(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},status:e.status??1}))}function lt(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 ct,dt,ut;function mt(){return mt=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},mt.apply(null,arguments)}const ht=e=>j.createElement("svg",mt({xmlns:"http://www.w3.org/2000/svg",width:20,height:10,fill:"#fff",viewBox:"0 0 120 30"},e),ct||(ct=j.createElement("circle",{cx:15,cy:15,r:15,fill:"#3c60ff"},j.createElement("animate",{attributeName:"r",begin:"0s",calcMode:"linear",dur:"0.8s",from:15,repeatCount:"indefinite",to:15,values:"15;9;15"}),j.createElement("animate",{attributeName:"fill-opacity",begin:"0s",calcMode:"linear",dur:"0.8s",from:1,repeatCount:"indefinite",to:1,values:"1;.5;1"}))),dt||(dt=j.createElement("circle",{cx:60,cy:15,r:9,fill:"#3c60ff",fillOpacity:.3},j.createElement("animate",{attributeName:"r",begin:"0s",calcMode:"linear",dur:"0.8s",from:9,repeatCount:"indefinite",to:9,values:"9;15;9"}),j.createElement("animate",{attributeName:"fill-opacity",begin:"0s",calcMode:"linear",dur:"0.8s",from:.5,repeatCount:"indefinite",to:.5,values:".5;1;.5"}))),ut||(ut=j.createElement("circle",{cx:105,cy:15,r:15,fill:"#3c60ff"},j.createElement("animate",{attributeName:"r",begin:"0s",calcMode:"linear",dur:"0.8s",from:15,repeatCount:"indefinite",to:15,values:"15;9;15"}),j.createElement("animate",{attributeName:"fill-opacity",begin:"0s",calcMode:"linear",dur:"0.8s",from:1,repeatCount:"indefinite",to:1,values:"1;.5;1"}))));function pt(e){if(!e)return"";if("string"==typeof e)return e;if("image"===e.type){return`})`}return""}const gt=function(e,t,r){function n(t){return t!==ne.leftSquareBracket?(e.exit("citeMarker"),e.enter("citeData"),e.enter(ie.chunkString,{contentType:"string"}),i(t)):(e.consume(t),n)}function i(n){return n===ne.rightSquareBracket?(e.exit(ie.chunkString),e.exit("citeData"),e.enter("citeMarker"),function(n){if(n!==ne.rightSquareBracket)return r(n);return e.consume(n),e.exit("citeMarker"),e.exit("cite"),t(n)}(n)):oe(n)||n===ne.eof||n>57||n<48?r(n):(e.consume(n),i)}return function(t){return t!==ne.leftSquareBracket?r(t):(e.enter("cite"),e.enter("citeMarker"),n(t))}},ft=function(){const e=this.data();e.micromarkExtensions.push({text:{[ne.leftSquareBracket]:{tokenize:gt}}}),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}}})},bt=x.Image,vt={pre:({children:r,node:n})=>{if(!n)return null;const[i,o]=q(!1),s=A(()=>{const e=n.children[0];return"element"===(t=e).type&&"code"===t.tagName&&!!e.properties?.className?.includes("language-svg");var t},[n]);M(()=>{s&&o(s)},[s]);const a=A(()=>V(n),[n]);return t(Nt,{children:[t(Et,{children:[!i&&e(w,{tooltip:!1,as:kt,content:a}),s&&i&&e(kt,{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(kt,{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(bt,{...r})},yt=[[re,{singleDollarTextMath:!1}],te,ee],xt=[Z,[G,{detect:!1,ignoreMissing:!0}]],wt=L(F(({content:t,components:r,cite:n},i)=>{t=t.replace(/\\\(\s(.+?)\s\\\)/g,"$$$$ $1 $$$$");const o=A(()=>{const e={...vt,...r};return n&&(e.cite=n),e},[r,n]),s=A(()=>n?[...yt,ft]:yt,[n]);return e(jt,{ref:i,children:e(Y,{remarkPlugins:s,rehypePlugins:xt,components:o,children:t})})}),X),kt=n.div`
|
|
250
|
+
`;function at(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,context:e.context,latency:e.latency},status:e.status??1}))}function lt(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 ct,dt,ut;function mt(){return mt=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},mt.apply(null,arguments)}const ht=e=>j.createElement("svg",mt({xmlns:"http://www.w3.org/2000/svg",width:20,height:10,fill:"#fff",viewBox:"0 0 120 30"},e),ct||(ct=j.createElement("circle",{cx:15,cy:15,r:15,fill:"#3c60ff"},j.createElement("animate",{attributeName:"r",begin:"0s",calcMode:"linear",dur:"0.8s",from:15,repeatCount:"indefinite",to:15,values:"15;9;15"}),j.createElement("animate",{attributeName:"fill-opacity",begin:"0s",calcMode:"linear",dur:"0.8s",from:1,repeatCount:"indefinite",to:1,values:"1;.5;1"}))),dt||(dt=j.createElement("circle",{cx:60,cy:15,r:9,fill:"#3c60ff",fillOpacity:.3},j.createElement("animate",{attributeName:"r",begin:"0s",calcMode:"linear",dur:"0.8s",from:9,repeatCount:"indefinite",to:9,values:"9;15;9"}),j.createElement("animate",{attributeName:"fill-opacity",begin:"0s",calcMode:"linear",dur:"0.8s",from:.5,repeatCount:"indefinite",to:.5,values:".5;1;.5"}))),ut||(ut=j.createElement("circle",{cx:105,cy:15,r:15,fill:"#3c60ff"},j.createElement("animate",{attributeName:"r",begin:"0s",calcMode:"linear",dur:"0.8s",from:15,repeatCount:"indefinite",to:15,values:"15;9;15"}),j.createElement("animate",{attributeName:"fill-opacity",begin:"0s",calcMode:"linear",dur:"0.8s",from:1,repeatCount:"indefinite",to:1,values:"1;.5;1"}))));function pt(e){if(!e)return"";if("string"==typeof e)return e;if("image"===e.type){return`})`}return""}const gt=function(e,t,r){function n(t){return t!==ne.leftSquareBracket?(e.exit("citeMarker"),e.enter("citeData"),e.enter(ie.chunkString,{contentType:"string"}),i(t)):(e.consume(t),n)}function i(n){return n===ne.rightSquareBracket?(e.exit(ie.chunkString),e.exit("citeData"),e.enter("citeMarker"),function(n){if(n!==ne.rightSquareBracket)return r(n);return e.consume(n),e.exit("citeMarker"),e.exit("cite"),t(n)}(n)):oe(n)||n===ne.eof||n>57||n<48?r(n):(e.consume(n),i)}return function(t){return t!==ne.leftSquareBracket?r(t):(e.enter("cite"),e.enter("citeMarker"),n(t))}},ft=function(){const e=this.data();e.micromarkExtensions.push({text:{[ne.leftSquareBracket]:{tokenize:gt}}}),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}}})},bt=x.Image,vt={pre:({children:r,node:n})=>{if(!n)return null;const[i,o]=q(!1),s=A(()=>{const e=n.children[0];return"element"===(t=e).type&&"code"===t.tagName&&!!e.properties?.className?.includes("language-svg");var t},[n]);M(()=>{s&&o(s)},[s]);const a=A(()=>V(n),[n]);return t(Nt,{children:[t(Et,{children:[!i&&e(w,{tooltip:!1,as:kt,content:a}),s&&i&&e(kt,{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(kt,{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(bt,{...r})},yt=[[re,{singleDollarTextMath:!1}],te,ee],xt=[Z,[G,{detect:!1,ignoreMissing:!0}]],wt=L(F(({content:t,components:r,cite:n},i)=>{t=t.replace(/\\\(\s(.+?)\s\\\)/g,"$$$$ $1 $$$$");const o=A(()=>{const e={...vt,...r};return n&&(e.cite=n),e},[r,n]),s=A(()=>n?[...yt,ft]:yt,[n]);return e(jt,{ref:i,children:e(Y,{remarkPlugins:s,rehypePlugins:xt,components:o,children:t})})}),X),kt=n.div`
|
|
251
251
|
cursor: pointer;
|
|
252
252
|
padding: 2px 10px;
|
|
253
253
|
background-color: #303030;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topthink/chat",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"module": "es/index.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@babel/runtime": "^7.11.2",
|
|
13
13
|
"@breezystack/lamejs": "^1.2.7",
|
|
14
|
-
"@topthink/components": "1.2.
|
|
14
|
+
"@topthink/components": "1.2.8",
|
|
15
15
|
"@types/hast": "^3.0.4",
|
|
16
16
|
"@types/mdast": "^4.0.4",
|
|
17
17
|
"eventemitter3": "^5.0.1",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"author": "yunwuxin <tzzhangyajun@qq.com> (https://github.com/yunwuxin)",
|
|
65
65
|
"license": "MIT",
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "1f662407e8f61b15b03bdc38e81b84f0c4c38495",
|
|
67
67
|
"scripts": {
|
|
68
68
|
"prebuild": "rimraf es types",
|
|
69
69
|
"build": "rollup -c --environment NODE_ENV:production",
|
package/types/types.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ export interface Message {
|
|
|
94
94
|
stats?: {
|
|
95
95
|
usage: number;
|
|
96
96
|
latency: number;
|
|
97
|
+
context: number;
|
|
97
98
|
};
|
|
98
99
|
loading?: boolean;
|
|
99
100
|
annotation?: {
|
|
@@ -130,6 +131,7 @@ export interface ConversationMessage {
|
|
|
130
131
|
}[];
|
|
131
132
|
usage: number;
|
|
132
133
|
latency: number;
|
|
134
|
+
context: number;
|
|
133
135
|
annotation?: {
|
|
134
136
|
id: string;
|
|
135
137
|
question: string;
|