mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-29 20:34:28 +00:00
feat(chat): append and display context_display_info custom entry for attached assets
This commit is contained in:
@@ -90,6 +90,24 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
|
||||
}
|
||||
|
||||
const renderMessage = (msg: ChatMessage) => {
|
||||
if (msg.role === 'custom' && (msg as { customType?: string }).customType === 'context_display_info') {
|
||||
const details = msg.details as { assets?: Array<{ id: string; name: string; type: string }> } | undefined
|
||||
const assets = details?.assets || []
|
||||
if (assets.length === 0) return null
|
||||
return (
|
||||
<div key={msg.id} className="text-xs text-muted-foreground bg-muted/40 p-2.5 rounded-lg border border-border/50 space-y-1 my-1">
|
||||
<div className="font-semibold">{m.assets_added_to_context()}</div>
|
||||
<ul className="list-disc list-inside space-y-0.5">
|
||||
{assets.map((asset) => (
|
||||
<li key={asset.id} className="truncate">
|
||||
{asset.name} <span className="text-muted-foreground/70">({asset.type})</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const isUser = msg.role === 'user'
|
||||
const isAssistant = msg.role === 'assistant'
|
||||
const isTool = msg.role === 'toolResult'
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"language": "Language",
|
||||
"personal_info": "Personal Info",
|
||||
"language_settings": "Language Settings",
|
||||
"assets_added_to_context": "Assets added to context:",
|
||||
"select_preferred_language": "Select your preferred display language.",
|
||||
"settings": "Settings",
|
||||
"welcome_back": "Welcome Back",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"language": "语言",
|
||||
"personal_info": "个人信息",
|
||||
"language_settings": "语言设置",
|
||||
"assets_added_to_context": "已添加至上下文的资源:",
|
||||
"select_preferred_language": "选择您首选的显示语言。",
|
||||
"settings": "设置",
|
||||
"welcome_back": "欢迎回来",
|
||||
|
||||
+1
@@ -4,6 +4,7 @@ export * from "./uploads.js";
|
||||
export * from "./language.js";
|
||||
export * from "./personal_info.js";
|
||||
export * from "./language_settings.js";
|
||||
export * from "./assets_added_to_context.js";
|
||||
export * from "./select_preferred_language.js";
|
||||
export * from "./settings.js";
|
||||
export * from "./welcome_back.js";
|
||||
|
||||
+1
@@ -6,6 +6,7 @@ export * from './uploads.js'
|
||||
export * from './language.js'
|
||||
export * from './personal_info.js'
|
||||
export * from './language_settings.js'
|
||||
export * from './assets_added_to_context.js'
|
||||
export * from './select_preferred_language.js'
|
||||
export * from './settings.js'
|
||||
export * from './welcome_back.js'
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Assets added to context:" |
|
||||
*
|
||||
* @param {Assets_Added_To_ContextInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const assets_added_to_context: ((inputs?: Assets_Added_To_ContextInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Assets_Added_To_ContextInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Assets_Added_To_ContextInputs = {};
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Assets_Added_To_ContextInputs */
|
||||
|
||||
const en_assets_added_to_context = /** @type {(inputs: Assets_Added_To_ContextInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Assets added to context:`)
|
||||
};
|
||||
|
||||
const zh_assets_added_to_context = /** @type {(inputs: Assets_Added_To_ContextInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`已添加至上下文的资源:`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Assets added to context:" |
|
||||
*
|
||||
* @param {Assets_Added_To_ContextInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const assets_added_to_context = /** @type {((inputs?: Assets_Added_To_ContextInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Assets_Added_To_ContextInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_assets_added_to_context(inputs)
|
||||
return zh_assets_added_to_context(inputs)
|
||||
});
|
||||
Reference in New Issue
Block a user