Skip to content

Commit 2eb880a

Browse files
committed
feat: support manual summary
Signed-off-by: Innei <[email protected]>
1 parent 3df6946 commit 2eb880a

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

src/components/modules/shared/SummarySwitcher.tsx

+32-2
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,25 @@ import type { AiSummaryProps } from '../ai/Summary'
44

55
import { appStaticConfig } from '~/app.static.config'
66
import { ErrorBoundary } from '~/components/common/ErrorBoundary'
7+
import { clsxm } from '~/lib/helper'
78

89
import { AISummary } from '../ai/Summary'
910
import { XLogSummary } from '../xlog'
1011
import { getCidForBaseModel } from '../xlog/utils'
1112

12-
export const SummarySwitcher: FC<AiSummaryProps> = memo((props) => {
13+
export const SummarySwitcher: FC<
14+
AiSummaryProps & {
15+
summary?: string
16+
}
17+
> = memo((props) => {
1318
const { enabled, providers } = appStaticConfig.ai.summary
14-
const { data } = props
19+
const { data, summary } = props
1520
const cid = getCidForBaseModel(data)
1621

22+
const finalSummary = 'summary' in data ? data.summary : summary
23+
if (typeof finalSummary != 'undefined')
24+
return <ManualSummary className="my-4" summary={finalSummary} />
25+
1726
if (!enabled) return null
1827

1928
let comp: any
@@ -40,3 +49,24 @@ export const SummarySwitcher: FC<AiSummaryProps> = memo((props) => {
4049
})
4150

4251
SummarySwitcher.displayName = 'SummarySwitcher'
52+
53+
const ManualSummary: Component<{
54+
summary: string
55+
}> = ({ className, summary }) => {
56+
return (
57+
<div
58+
className={clsxm(
59+
`space-y-2 rounded-xl border border-slate-200 p-4 dark:border-neutral-800`,
60+
className,
61+
)}
62+
>
63+
<div className="flex items-center">
64+
<i className="icon-[mingcute--sparkles-line] mr-2 text-lg" />
65+
摘要
66+
</div>
67+
<div className="!m-0 text-sm leading-loose text-base-content/85">
68+
{summary}
69+
</div>
70+
</div>
71+
)
72+
}

0 commit comments

Comments
 (0)