fix: 对话增量判断条件变更
parent
16a39a87cb
commit
b365eac8bd
|
|
@ -1,2 +1,2 @@
|
|||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CR5a_mms.js","assets/.pnpm-CAIuqsZ0.js","assets/use-toast-DO4tfD4I.js","assets/index-PFueeGmc.css"])))=>i.map(i=>d[i]);
|
||||
import{_ as t}from"./index-DOYUXUr3.js";import{j as r,r as a}from"./.pnpm-CAIuqsZ0.js";const o=a.lazy(()=>t(()=>import("./index-CR5a_mms.js"),__vite__mapDeps([0,1,2,3])));function i(){return r.jsx("div",{className:"h-full bg-[#F4F6FA]",children:r.jsx(o,{})})}export{i as default};
|
||||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DCCuNddn.js","assets/.pnpm-CAIuqsZ0.js","assets/use-toast-DO4tfD4I.js","assets/index-PFueeGmc.css"])))=>i.map(i=>d[i]);
|
||||
import{_ as t}from"./index-CN-hwWKH.js";import{j as r,r as a}from"./.pnpm-CAIuqsZ0.js";const o=a.lazy(()=>t(()=>import("./index-DCCuNddn.js"),__vite__mapDeps([0,1,2,3])));function i(){return r.jsx("div",{className:"h-full bg-[#F4F6FA]",children:r.jsx(o,{})})}export{i as default};
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/App-BkgWMpGx.js","assets/.pnpm-CAIuqsZ0.js","assets/MainLayout-BMCWJnk-.js","assets/use-toast-DO4tfD4I.js"])))=>i.map(i=>d[i]);
|
||||
var v=Object.defineProperty;var x=(s,t,n)=>t in s?v(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var m=(s,t,n)=>x(s,typeof t!="symbol"?t+"":t,n);import{r as d,c as P,j as a,a as _,R as L}from"./.pnpm-CAIuqsZ0.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))f(e);new MutationObserver(e=>{for(const o of e)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&f(r)}).observe(document,{childList:!0,subtree:!0});function n(e){const o={};return e.integrity&&(o.integrity=e.integrity),e.referrerPolicy&&(o.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?o.credentials="include":e.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function f(e){if(e.ep)return;e.ep=!0;const o=n(e);fetch(e.href,o)}})();const j="modulepreload",O=function(s){return"/"+s},h={},p=function(t,n,f){let e=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),i=(r==null?void 0:r.nonce)||(r==null?void 0:r.getAttribute("nonce"));e=Promise.allSettled(n.map(c=>{if(c=O(c),c in h)return;h[c]=!0;const u=c.endsWith(".css"),E=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${E}`))return;const l=document.createElement("link");if(l.rel=u?"stylesheet":j,u||(l.as="script"),l.crossOrigin="",l.href=c,i&&l.setAttribute("nonce",i),document.head.appendChild(l),u)return new Promise((y,g)=>{l.addEventListener("load",y),l.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(r){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=r,window.dispatchEvent(i),!i.defaultPrevented)throw r}return e.then(r=>{for(const i of r||[])i.status==="rejected"&&o(i.reason);return t().catch(o)})},R=d.lazy(()=>p(()=>import("./App-BkgWMpGx.js"),__vite__mapDeps([0,1]))),S=d.lazy(()=>p(()=>import("./MainLayout-BMCWJnk-.js"),__vite__mapDeps([2,1,3])));class w extends d.Component{constructor(){super(...arguments);m(this,"state",{hasError:!1})}static getDerivedStateFromError(n){return{hasError:!0}}render(){return this.state.hasError?a.jsx("h1",{children:"出错了,请稍后再试。"}):this.props.children}}const b=P([{path:"/",element:a.jsx(S,{}),errorElement:a.jsx(w,{children:a.jsx("div",{className:"flex-auto flex flex-col p-6",children:"出错了,请稍后再试。"})}),children:[{path:"/",element:a.jsx(R,{})}]}]);_(document.getElementById("root")).render(a.jsx(d.StrictMode,{children:a.jsx(L,{router:b})}));export{p as _};
|
||||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/App-D4RUlINY.js","assets/.pnpm-CAIuqsZ0.js","assets/MainLayout-BMCWJnk-.js","assets/use-toast-DO4tfD4I.js"])))=>i.map(i=>d[i]);
|
||||
var v=Object.defineProperty;var x=(s,t,n)=>t in s?v(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var m=(s,t,n)=>x(s,typeof t!="symbol"?t+"":t,n);import{r as d,c as P,j as a,a as _,R as L}from"./.pnpm-CAIuqsZ0.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))f(e);new MutationObserver(e=>{for(const o of e)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&f(r)}).observe(document,{childList:!0,subtree:!0});function n(e){const o={};return e.integrity&&(o.integrity=e.integrity),e.referrerPolicy&&(o.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?o.credentials="include":e.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function f(e){if(e.ep)return;e.ep=!0;const o=n(e);fetch(e.href,o)}})();const j="modulepreload",O=function(s){return"/"+s},h={},p=function(t,n,f){let e=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),i=(r==null?void 0:r.nonce)||(r==null?void 0:r.getAttribute("nonce"));e=Promise.allSettled(n.map(c=>{if(c=O(c),c in h)return;h[c]=!0;const u=c.endsWith(".css"),E=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${E}`))return;const l=document.createElement("link");if(l.rel=u?"stylesheet":j,u||(l.as="script"),l.crossOrigin="",l.href=c,i&&l.setAttribute("nonce",i),document.head.appendChild(l),u)return new Promise((y,g)=>{l.addEventListener("load",y),l.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(r){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=r,window.dispatchEvent(i),!i.defaultPrevented)throw r}return e.then(r=>{for(const i of r||[])i.status==="rejected"&&o(i.reason);return t().catch(o)})},R=d.lazy(()=>p(()=>import("./App-D4RUlINY.js"),__vite__mapDeps([0,1]))),S=d.lazy(()=>p(()=>import("./MainLayout-BMCWJnk-.js"),__vite__mapDeps([2,1,3])));class w extends d.Component{constructor(){super(...arguments);m(this,"state",{hasError:!1})}static getDerivedStateFromError(n){return{hasError:!0}}render(){return this.state.hasError?a.jsx("h1",{children:"出错了,请稍后再试。"}):this.props.children}}const b=P([{path:"/",element:a.jsx(S,{}),errorElement:a.jsx(w,{children:a.jsx("div",{className:"flex-auto flex flex-col p-6",children:"出错了,请稍后再试。"})}),children:[{path:"/",element:a.jsx(R,{})}]}]);_(document.getElementById("root")).render(a.jsx(d.StrictMode,{children:a.jsx(L,{router:b})}));export{p as _};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -18,12 +18,12 @@
|
|||
|
||||
<link rel="icon" href="https://api.static.ycymedu.com/src/images/home/app-logo.svg" />
|
||||
<meta name="author" content="HideInMatrix" />
|
||||
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
|
||||
<!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
|
||||
<script>
|
||||
// VConsole will be exported to `window.VConsole` by default.
|
||||
var vConsole = new window.VConsole();
|
||||
</script>
|
||||
<script type="module" crossorigin src="/assets/index-DOYUXUr3.js"></script>
|
||||
</script> -->
|
||||
<script type="module" crossorigin src="/assets/index-CN-hwWKH.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/assets/.pnpm-CAIuqsZ0.js">
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DPqYJA2j.css">
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ export const RealtimeClientProvider = ({
|
|||
voiceId: voiceId,
|
||||
connectorId: connectorId,
|
||||
allowPersonalAccessTokenInBrowser: true, // 可选:允许在浏览器中使用个人访问令牌
|
||||
debug: true,
|
||||
});
|
||||
|
||||
clientRef.current = client;
|
||||
|
|
@ -244,7 +245,7 @@ export const RealtimeClientProvider = ({
|
|||
// 如果上一个事件是增量更新,则附加到最后一条消息
|
||||
if (
|
||||
lastEvent?.event_type === ChatEventType.CONVERSATION_MESSAGE_DELTA &&
|
||||
(event.data.type === "answer" || event.data.type === "question")
|
||||
(event.data.type === "answer")
|
||||
) {
|
||||
return [
|
||||
...prev.slice(0, -1),
|
||||
|
|
@ -253,6 +254,14 @@ export const RealtimeClientProvider = ({
|
|||
role: prev[prev.length - 1].role,
|
||||
},
|
||||
];
|
||||
}else if ( // 否则添加新消息
|
||||
(content !== "" &&
|
||||
event.event_type === ChatEventType.CONVERSATION_MESSAGE_DELTA) ||
|
||||
(event.event_type === ChatEventType.CONVERSATION_MESSAGE_COMPLETED &&
|
||||
(event.data.type === "answer" || event.data.type === "question") &&
|
||||
event.data.role !== RoleType.Assistant)
|
||||
) {
|
||||
return [...prev, { content: content, role: event.data.role }];
|
||||
}
|
||||
|
||||
// 添加AI的欢迎语
|
||||
|
|
@ -263,16 +272,7 @@ export const RealtimeClientProvider = ({
|
|||
];
|
||||
}
|
||||
|
||||
// 否则添加新消息
|
||||
if (
|
||||
(content !== "" &&
|
||||
event.event_type === ChatEventType.CONVERSATION_MESSAGE_DELTA) ||
|
||||
(event.event_type === ChatEventType.CONVERSATION_MESSAGE_COMPLETED &&
|
||||
(event.data.type === "answer" || event.data.type === "question") &&
|
||||
event.data.role !== RoleType.Assistant)
|
||||
) {
|
||||
return [...prev, { content: content, role: event.data.role }];
|
||||
}
|
||||
|
||||
return prev;
|
||||
});
|
||||
lastEvent = event;
|
||||
|
|
|
|||
Loading…
Reference in New Issue