@topthink/chat 1.1.30 → 1.1.31
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
CHANGED
|
@@ -613,7 +613,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
613
613
|
&::before {
|
|
614
614
|
transform: scale(1.4)
|
|
615
615
|
}
|
|
616
|
-
`;function yt(r){let{tool:n}=r;const[
|
|
616
|
+
`;function yt(r){let{tool:n,loading:i}=r;const[o,s]=M(!1),{logLevel:a="none"}=ce(),l="response"in n,c=!l&&!i;return e(S,{children:["stats"==a&&t("div",{className:"mb-2",children:e("div",{role:"button",className:"d-inline-flex align-items-center shadow-sm rounded bg-white p-1 px-2 fs-7 gap-2",children:[c?t("i",{className:"bi bi-dash-circle-fill text-muted"}):l?n.error?t("i",{className:"bi bi-x-circle-fill text-danger"}):t("i",{className:"bi bi-check-circle-fill text-success"}):t(D,{animation:"border",variant:"primary",size:"sm"}),t("span",{className:"text-muted",children:c?"已取消":l?"已使用":"正在使用"}),t("span",{children:n.title})]})}),"all"==a&&t("div",{className:"mb-2",children:e("div",o&&l?{className:"shadow-sm rounded bg-white fs-7",children:[e("div",{onClick:()=>s(!1),role:"button",className:"d-flex align-items-center p-1 px-2 gap-2",children:[n.error?t("i",{className:"bi bi-x-circle-fill text-danger"}):t("i",{className:"bi bi-check-circle-fill text-success"}),t("span",{className:"text-muted",children:"已使用"}),t("span",{children:n.title}),t("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",children:[t("div",{className:"d-flex align-items-center p-1 px-2 fs-7 gap-2",children:t("span",{className:"text-muted",children:"参数"})}),t("div",{className:"border-top p-2 overflow-hidden",children:n.arguments})]}),e("div",{className:"border rounded bg-light",children:[t("div",{className:"d-flex align-items-center p-1 px-2 fs-7 gap-2",children:t("span",{className:"text-muted",children:"响应"})}),t(kt,{className:"border-top p-2 overflow-hidden",children:n.response||"None"})]})]})]}:{onClick:()=>s(l),role:"button",className:"d-inline-flex align-items-center shadow-sm rounded bg-white p-1 px-2 fs-7 gap-2",children:[c?t("i",{className:"bi bi-dash-circle-fill text-muted"}):l?n.error?t("i",{className:"bi bi-x-circle-fill text-danger"}):t("i",{className:"bi bi-check-circle-fill text-success"}):t(D,{animation:"border",variant:"primary",size:"sm"}),t("span",{className:"text-muted",children:c?"已取消":l?"已使用":"正在使用"}),t("span",{children:n.title}),l&&t("i",{className:"bi bi-caret-down-fill text-muted"})]})}),n.content&&t(ht,{value:n.content})]})}const kt=n.div`
|
|
617
617
|
white-space: pre-wrap;
|
|
618
618
|
`;function wt(r){let{node:n}=r;const[i,o]=M(!1),{nodeIconResolver:s}=ce(),a=!("latency"in n),l=a?t(D,{animation:"border",variant:"primary",size:"sm"}):n.error?t("i",{className:"bi bi-x-circle-fill text-danger"}):t("i",{className:"bi bi-check-circle-fill text-success"});return e("div",{className:"shadow-sm rounded bg-white fs-7",children:[e(Et,{onClick:()=>o((e=>!e)),role:"button",className:"d-flex align-items-center p-1 px-2 gap-1",children:[t("i",{className:"bi bi-chevron-down text-muted"}),s?.(n.type),t(jt,{className:"me-2 text-truncate",children:n.title}),t("span",{className:"me-auto"}),!a&&t("span",{className:"text-nowrap text-muted",children:Nt(n.latency)}),t("span",{children:l})]}),i&&e("div",{className:"border-top p-2 d-flex flex-column gap-2",children:[e("div",{className:"border rounded bg-light",children:[t("div",{className:"d-flex align-items-center p-1 px-2 fs-7 gap-2",children:t("span",{className:"text-muted",children:"输入"})}),t("div",{className:"border-top p-2 overflow-hidden text-pre-wrap",children:n.input?JSON.stringify(n.input,null,4):"None"})]}),e("div",{className:"border rounded bg-light",children:[t("div",{className:"d-flex align-items-center p-1 px-2 fs-7 gap-2",children:t("span",{className:"text-muted",children:"输出"})}),t("div",{className:"border-top p-2 overflow-hidden text-pre-wrap",children:n.output?JSON.stringify(n.output,null,4):"None"})]})]})]})}const Nt=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`,Et=n.div`
|
|
619
619
|
svg {
|
|
@@ -621,7 +621,7 @@ import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{styled as
|
|
|
621
621
|
}
|
|
622
622
|
`,jt=n.span`
|
|
623
623
|
display: inline-block;
|
|
624
|
-
`;function Ct(r){let{nodes:n,loading:i}=r;const[o,s]=M(!1),a=n.some((e=>"error"in e)),l=i?t(D,{animation:"border",variant:"primary",size:"sm"}):t("i",a?{className:"bi bi-x-circle-fill text-danger"}:{className:"bi bi-check-circle-fill text-success"});return t("div",{className:"mb-2",children:e("div",o?{className:"shadow-sm rounded bg-white fs-7",children:[e("div",{onClick:()=>s(!1),role:"button",className:"d-flex align-items-center p-1 px-2 gap-2",children:[l,t("span",{children:"工作流"}),t("i",{className:"bi bi-caret-up-fill text-muted"})]}),t("div",{className:"border-top p-2 d-flex flex-column gap-1 bg-light bg-opacity-50",children:n.map(((e,r)=>t(wt,{node:e},r)))})]}:{onClick:()=>s(!0),role:"button",className:"d-inline-flex align-items-center shadow-sm rounded bg-white p-1 px-2 fs-7 gap-2",children:[l,t("span",{children:"工作流"}),t("i",{className:"bi bi-caret-down-fill text-muted"})]})})}const Mt=R((n=>{let{message:i,actions:o,setMessage:s,cite:a,speech:l}=n;const{query:c,quote:d,files:h=[],chunks:m,annotation:u,loading:p}=i,{user:g,bot:f,logLevel:y="none",messages:k}=ce(),w=q((()=>m?m.reduce((function(e,t){return e+t.content+"\n"+t.tools.reduce(((e,t)=>{if(t.content){if("string"==typeof t.content)return e+t.content+"\n";if("image"===t.content.type){return e+`})\n`}}return e}),"")}),""):""),[m]),N=E(null),j=E(null),C=E(null),M=q((()=>m?.flatMap((e=>e.node?[e.node]:[]))||[]),[m]);return e(r,{children:[(c||h.length>0)&&e(Ot,{$reverse:!0,children:[g&&t(It,{children:t("img",{src:g.avatar})}),t(Dt,{}),e(Lt,{ref:N,children:[c&&t(tt,{content:c}),d&&t(T,{trigger:"click",container:N,rootClose:!0,placement:"bottom",overlay:t($t,{body:!0,children:d}),children:t(zt,{children:t(qt,{children:d})})}),h.length>0&&h.map(((e,r)=>{let{name:n,size:i,path:o}=e;return x(o)?t(ct,{src:`/uploads/${o}`},r):t(Rt,{children:t(re,{name:n,size:i})},r)}))]})]}),m&&e(Ot,{children:[t(It,{ref:j,children:t("img",{src:f.avatar})}),t(Dt,{}),e(Lt,{children:[(c||h.length>0)&&!1!==o&&e(At,{children:[t(b,{placement:"top",content:w,as:st,tooltip:!0}),l&&t(bt,{loading:i.loading,avatarRef:j,contentRef:C,...l}),o?.({Component:st,message:i,content:w,setMessage:s,messages:k})]}),t(Ft,{children:["stats","all"].includes(y)&&i.stats&&e(r,{children:[e("span",{children:["耗时 ",i.stats.latency/1e3," 秒"]}),e("span",{children:["花费 Token ",i.stats.usage]})]})}),e(St,{ref:C,$deleted:!!u,children:["all"===y&&M.length>0&&t(Ct,{loading:p,nodes:M}),m.length>0&&m.map(((r,n)=>e(S,{children:[r.reasoning&&["stats","all"].includes(y)&&t(mt,{reasoning:r.reasoning,loading:!r.content&&0===r.tools.length}),r.content&&t(ht,{cite:a,value:r.content}),r.tools.map(((e,r)=>t(yt,{tool:e},r))),r.error&&t(tt,{content:`[${r.error}]`})]},n)))]}),u&&e("div",{children:[e("div",{className:"d-flex align-items-center",children:[t("span",{className:"fs-7 text-secondary me-2",children:"标注的答案"}),t("hr",{className:"flex-fill"})]}),t(tt,{content:u.answer})]}),i.loading&&t(We,{})]})]})]})})),$t=n(P)`
|
|
624
|
+
`;function Ct(r){let{nodes:n,loading:i}=r;const[o,s]=M(!1),a=n.some((e=>"error"in e)),l=i?t(D,{animation:"border",variant:"primary",size:"sm"}):t("i",a?{className:"bi bi-x-circle-fill text-danger"}:{className:"bi bi-check-circle-fill text-success"});return t("div",{className:"mb-2",children:e("div",o?{className:"shadow-sm rounded bg-white fs-7",children:[e("div",{onClick:()=>s(!1),role:"button",className:"d-flex align-items-center p-1 px-2 gap-2",children:[l,t("span",{children:"工作流"}),t("i",{className:"bi bi-caret-up-fill text-muted"})]}),t("div",{className:"border-top p-2 d-flex flex-column gap-1 bg-light bg-opacity-50",children:n.map(((e,r)=>t(wt,{node:e},r)))})]}:{onClick:()=>s(!0),role:"button",className:"d-inline-flex align-items-center shadow-sm rounded bg-white p-1 px-2 fs-7 gap-2",children:[l,t("span",{children:"工作流"}),t("i",{className:"bi bi-caret-down-fill text-muted"})]})})}const Mt=R((n=>{let{message:i,actions:o,setMessage:s,cite:a,speech:l}=n;const{query:c,quote:d,files:h=[],chunks:m,annotation:u,loading:p}=i,{user:g,bot:f,logLevel:y="none",messages:k}=ce(),w=q((()=>m?m.reduce((function(e,t){return e+t.content+"\n"+t.tools.reduce(((e,t)=>{if(t.content){if("string"==typeof t.content)return e+t.content+"\n";if("image"===t.content.type){return e+`})\n`}}return e}),"")}),""):""),[m]),N=E(null),j=E(null),C=E(null),M=q((()=>m?.flatMap((e=>e.node?[e.node]:[]))||[]),[m]);return e(r,{children:[(c||h.length>0)&&e(Ot,{$reverse:!0,children:[g&&t(It,{children:t("img",{src:g.avatar})}),t(Dt,{}),e(Lt,{ref:N,children:[c&&t(tt,{content:c}),d&&t(T,{trigger:"click",container:N,rootClose:!0,placement:"bottom",overlay:t($t,{body:!0,children:d}),children:t(zt,{children:t(qt,{children:d})})}),h.length>0&&h.map(((e,r)=>{let{name:n,size:i,path:o}=e;return x(o)?t(ct,{src:`/uploads/${o}`},r):t(Rt,{children:t(re,{name:n,size:i})},r)}))]})]}),m&&e(Ot,{children:[f&&t(It,{ref:j,children:t("img",{src:f.avatar})}),t(Dt,{}),e(Lt,{children:[(c||h.length>0)&&!1!==o&&e(At,{children:[t(b,{placement:"top",content:w,as:st,tooltip:!0}),l&&t(bt,{loading:i.loading,avatarRef:j,contentRef:C,...l}),o?.({Component:st,message:i,content:w,setMessage:s,messages:k})]}),t(Ft,{children:["stats","all"].includes(y)&&i.stats&&e(r,{children:[e("span",{children:["耗时 ",i.stats.latency/1e3," 秒"]}),e("span",{children:["花费 Token ",i.stats.usage]})]})}),e(St,{ref:C,$deleted:!!u,children:["all"===y&&M.length>0&&t(Ct,{loading:p,nodes:M}),m.length>0&&m.map(((r,n)=>e(S,{children:[r.reasoning&&["stats","all"].includes(y)&&t(mt,{reasoning:r.reasoning,loading:!r.content&&0===r.tools.length}),r.content&&t(ht,{cite:a,value:r.content}),r.tools.map(((e,r)=>t(yt,{tool:e,loading:p},r))),r.error&&t(tt,{content:`[${r.error}]`})]},n)))]}),u&&e("div",{children:[e("div",{className:"d-flex align-items-center",children:[t("span",{className:"fs-7 text-secondary me-2",children:"标注的答案"}),t("hr",{className:"flex-fill"})]}),t(tt,{content:u.answer})]}),i.loading&&t(We,{})]})]})]})})),$t=n(P)`
|
|
625
625
|
max-width: calc(100% - .875rem * 2);
|
|
626
626
|
width: calc(100% - .875rem * 2);
|
|
627
627
|
font-size: 1rem;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topthink/chat",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.31",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prebuild": "rimraf es types",
|
|
6
6
|
"build": "rollup -c --environment NODE_ENV:production",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
},
|
|
68
68
|
"author": "yunwuxin <tzzhangyajun@qq.com> (https://github.com/yunwuxin)",
|
|
69
69
|
"license": "MIT",
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "b77f45210035b69ad360f769ab5a00abf431137a"
|
|
71
71
|
}
|
|
@@ -3,7 +3,7 @@ import { Conversation, LogLevel, Message } from '../../types';
|
|
|
3
3
|
import { Updater } from '@topthink/components/types/hooks/use-immer';
|
|
4
4
|
import { RequestInstance } from '@topthink/components';
|
|
5
5
|
interface ContextType {
|
|
6
|
-
bot
|
|
6
|
+
bot?: {
|
|
7
7
|
name: string;
|
|
8
8
|
avatar: string;
|
|
9
9
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ToolMessage } from '../../types';
|
|
2
2
|
interface Props {
|
|
3
3
|
tool: ToolMessage;
|
|
4
|
+
loading?: boolean;
|
|
4
5
|
}
|
|
5
|
-
export default function Tool({ tool }: Props): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default function Tool({ tool, loading }: Props): import("react/jsx-runtime").JSX.Element;
|
|
6
7
|
export {};
|