Merge remote-tracking branch 'upstream/main' into feat/rag-2

This commit is contained in:
QuantumGhost
2025-09-16 14:59:35 +08:00
791 changed files with 24372 additions and 7085 deletions

View File

@ -33,7 +33,7 @@ const ToolCallItem: FC<Props> = ({ toolCall, isLLM = false, isFinal, tokens, obs
if (time < 1)
return `${(time * 1000).toFixed(3)} ms`
if (time > 60)
return `${Number.parseInt(Math.round(time / 60).toString())} m ${(time % 60).toFixed(3)} s`
return `${Math.floor(time / 60)} m ${(time % 60).toFixed(3)} s`
return `${time.toFixed(3)} s`
}

View File

@ -682,7 +682,7 @@ export const useChat = (
updateChatTreeNode(targetAnswerId, {
content: chatList[index].content,
annotation: {
...(chatList[index].annotation || {}),
...chatList[index].annotation,
id: '',
} as Annotation,
})

View File

@ -42,7 +42,14 @@ const DatePicker = ({
const [view, setView] = useState(ViewType.date)
const containerRef = useRef<HTMLDivElement>(null)
const isInitial = useRef(true)
const inputValue = useRef(value ? value.tz(timezone) : undefined).current
// Normalize the value to ensure that all subsequent uses are Day.js objects.
const normalizedValue = useMemo(() => {
if (!value) return undefined
return dayjs.isDayjs(value) ? value.tz(timezone) : dayjs(value).tz(timezone)
}, [value, timezone])
const inputValue = useRef(normalizedValue).current
const defaultValue = useRef(getDateWithTimezone({ timezone })).current
const [currentDate, setCurrentDate] = useState(inputValue || defaultValue)
@ -68,8 +75,8 @@ const DatePicker = ({
return
}
clearMonthMapCache()
if (value) {
const newValue = getDateWithTimezone({ date: value, timezone })
if (normalizedValue) {
const newValue = getDateWithTimezone({ date: normalizedValue, timezone })
setCurrentDate(newValue)
setSelectedDate(newValue)
onChange(newValue)
@ -88,9 +95,9 @@ const DatePicker = ({
}
setView(ViewType.date)
setIsOpen(true)
if (value) {
setCurrentDate(value)
setSelectedDate(value)
if (normalizedValue) {
setCurrentDate(normalizedValue)
setSelectedDate(normalizedValue)
}
}
@ -192,7 +199,7 @@ const DatePicker = ({
}
const timeFormat = needTimePicker ? t('time.dateFormats.displayWithTime') : t('time.dateFormats.display')
const displayValue = value?.format(timeFormat) || ''
const displayValue = normalizedValue?.format(timeFormat) || ''
const displayTime = selectedDate?.format('hh:mm A') || '--:-- --'
const placeholderDate = isOpen && selectedDate ? selectedDate.format(timeFormat) : (placeholder || t('time.defaultPlaceholder'))
@ -204,7 +211,7 @@ const DatePicker = ({
>
<PortalToFollowElemTrigger className={triggerWrapClassName}>
{renderTrigger ? (renderTrigger({
value,
value: normalizedValue,
selectedDate,
isOpen,
handleClear,

View File

@ -83,9 +83,7 @@ const OpeningSettingModal = ({
}, [handleSave, hideConfirmAddVar])
const autoAddVar = useCallback(() => {
onAutoAddPromptVariable?.([
...notIncludeKeys.map(key => getNewVar(key, 'string')),
])
onAutoAddPromptVariable?.(notIncludeKeys.map(key => getNewVar(key, 'string')))
hideConfirmAddVar()
handleSave(true)
}, [handleSave, hideConfirmAddVar, notIncludeKeys, onAutoAddPromptVariable])

View File

@ -24,7 +24,7 @@ const GA: FC<IGAProps> = ({
if (IS_CE_EDITION)
return null
const nonce = process.env.NODE_ENV === 'production' ? (headers() as unknown as UnsafeUnwrappedHeaders).get('x-nonce') : ''
const nonce = process.env.NODE_ENV === 'production' ? (headers() as unknown as UnsafeUnwrappedHeaders).get('x-nonce') ?? '' : ''
return (
<>
@ -32,7 +32,7 @@ const GA: FC<IGAProps> = ({
strategy="beforeInteractive"
async
src={`https://www.googletagmanager.com/gtag/js?id=${gaIdMaps[gaType]}`}
nonce={nonce!}
nonce={nonce ?? undefined}
></Script>
<Script
id="ga-init"
@ -44,14 +44,14 @@ gtag('js', new Date());
gtag('config', '${gaIdMaps[gaType]}');
`,
}}
nonce={nonce!}
nonce={nonce ?? undefined}
>
</Script>
{/* Cookie banner */}
<Script
id="cookieyes"
src='https://cdn-cookieyes.com/client_data/2a645945fcae53f8e025a2b1/script.js'
nonce={nonce!}
nonce={nonce ?? undefined}
></Script>
</>

View File

@ -17,7 +17,7 @@ const Link = ({ node, children, ...props }: any) => {
}
else {
const href = props.href || node.properties?.href
if (href && /^#[a-zA-Z0-9_\-]+$/.test(href.toString())) {
if (href && /^#[a-zA-Z0-9_-]+$/.test(href.toString())) {
const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
// scroll to target element if exists within the answer container

View File

@ -1,5 +1,6 @@
import React, { useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useChatContext } from '../chat/chat/context'
const hasEndThink = (children: any): boolean => {
if (typeof children === 'string')
@ -35,6 +36,7 @@ const removeEndThink = (children: any): any => {
}
const useThinkTimer = (children: any) => {
const { isResponding } = useChatContext()
const [startTime] = useState(Date.now())
const [elapsedTime, setElapsedTime] = useState(0)
const [isComplete, setIsComplete] = useState(false)
@ -54,9 +56,9 @@ const useThinkTimer = (children: any) => {
}, [startTime, isComplete])
useEffect(() => {
if (hasEndThink(children))
if (hasEndThink(children) || !isResponding)
setIsComplete(true)
}, [children])
}, [children, isResponding])
return { elapsedTime, isComplete }
}

View File

@ -241,7 +241,7 @@ const PageSelector = ({
if (current.expand) {
current.expand = false
newDataList = [...dataList.filter(item => !descendantsIds.includes(item.page_id))]
newDataList = dataList.filter(item => !descendantsIds.includes(item.page_id))
}
else {
current.expand = true
@ -258,7 +258,7 @@ const PageSelector = ({
setDataList(newDataList)
}
const copyValue = new Set([...value])
const copyValue = new Set(value)
const handleCheck = (index: number) => {
const current = currentDataList[index]
const pageId = current.page_id
@ -281,7 +281,7 @@ const PageSelector = ({
copyValue.add(pageId)
}
onSelect(new Set([...copyValue]))
onSelect(new Set(copyValue))
}
const handlePreview = (index: number) => {

View File

@ -20,7 +20,6 @@ const VALUE_LIMIT = {
max: 1,
}
const key = 'score_threshold'
const ScoreThresholdItem: FC<Props> = ({
className,
value,
@ -39,9 +38,9 @@ const ScoreThresholdItem: FC<Props> = ({
return (
<ParamItem
className={className}
id={key}
name={t(`appDebug.datasetConfig.${key}`)}
tip={t(`appDebug.datasetConfig.${key}Tip`) as string}
id='score_threshold'
name={t('appDebug.datasetConfig.score_threshold')}
tip={t('appDebug.datasetConfig.score_thresholdTip') as string}
{...VALUE_LIMIT}
value={value}
enable={enable}

View File

@ -24,7 +24,6 @@ const VALUE_LIMIT = {
max: maxTopK,
}
const key = 'top_k'
const TopKItem: FC<Props> = ({
className,
value,
@ -41,9 +40,9 @@ const TopKItem: FC<Props> = ({
return (
<ParamItem
className={className}
id={key}
name={t(`appDebug.datasetConfig.${key}`)}
tip={t(`appDebug.datasetConfig.${key}Tip`) as string}
id='top_k'
name={t('appDebug.datasetConfig.top_k')}
tip={t('appDebug.datasetConfig.top_kTip') as string}
{...VALUE_LIMIT}
value={value}
enable={enable}

View File

@ -160,7 +160,7 @@ export const PortalToFollowElemTrigger = (
context.getReferenceProps({
ref,
...props,
...(children.props || {}),
...children.props,
'data-state': context.open ? 'open' : 'closed',
} as React.HTMLProps<HTMLElement>),
)

View File

@ -0,0 +1,21 @@
import { memo } from 'react'
import { type UnsafeUnwrappedHeaders, headers } from 'next/headers'
import Script from 'next/script'
import { IS_CE_EDITION, ZENDESK_WIDGET_KEY } from '@/config'
const Zendesk = () => {
if (IS_CE_EDITION || !ZENDESK_WIDGET_KEY)
return null
const nonce = process.env.NODE_ENV === 'production' ? (headers() as unknown as UnsafeUnwrappedHeaders).get('x-nonce') ?? '' : ''
return (
<Script
nonce={nonce ?? undefined}
id="ze-snippet"
src={`https://static.zdassets.com/ekr/snippet.js?key=${ZENDESK_WIDGET_KEY}`}
/>
)
}
export default memo(Zendesk)

View File

@ -0,0 +1,23 @@
import { IS_CE_EDITION } from '@/config'
export type ConversationField = {
id: string,
value: any,
}
declare global {
// eslint-disable-next-line ts/consistent-type-definitions
interface Window {
zE?: (
command: string,
value: string,
payload?: ConversationField[] | string | string[] | (() => any),
callback?: () => any,
) => void;
}
}
export const setZendeskConversationFields = (fields: ConversationField[], callback?: () => any) => {
if (!IS_CE_EDITION && window.zE)
window.zE('messenger:set', 'conversationFields', fields, callback)
}