fix: 去掉用户气泡中<>的显示
This commit is contained in:
1 parent
8ba3a67401
commit
cb0b30690e
3 files changed
+35
-17
No files matched your search
@@ -45,6 +45,7 @@ export type ParsedBrainyChatSubmitMessage = {
|
||||
submitText: string;
|
||||
files: IframePromptInputFilePart[];
|
||||
iframeContext?: Record<string, unknown>;
|
||||
additionalKwargs?: Record<string, unknown>;
|
||||
};
|
||||
|
||||
const IMAGE_PRIORITY_INSTRUCTION = [
|
||||
@@ -137,30 +138,23 @@ function normalizePageContext(
|
||||
: undefined;
|
||||
}
|
||||
|
||||
export function buildIframeMessageText({
|
||||
text,
|
||||
function buildIframePromptPrefix({
|
||||
prompt,
|
||||
pageContext,
|
||||
hasAttachedImage = false,
|
||||
}: {
|
||||
text?: string;
|
||||
prompt?: string;
|
||||
pageContext?: BrainyPageContext;
|
||||
hasAttachedImage?: boolean;
|
||||
}) {
|
||||
const primaryText = trimToUndefined(text) || trimToUndefined(prompt) || "";
|
||||
const sections: string[] = [];
|
||||
|
||||
if (primaryText) {
|
||||
sections.push(primaryText);
|
||||
}
|
||||
|
||||
if (hasAttachedImage) {
|
||||
sections.push(IMAGE_PRIORITY_INSTRUCTION);
|
||||
}
|
||||
|
||||
const normalizedPrompt = trimToUndefined(prompt);
|
||||
if (normalizedPrompt && normalizedPrompt !== primaryText) {
|
||||
if (normalizedPrompt) {
|
||||
sections.push(
|
||||
`<extension_prompt>\n${normalizedPrompt}\n</extension_prompt>`,
|
||||
);
|
||||
@@ -190,6 +184,17 @@ export function buildIframeMessageText({
|
||||
return sections.join("\n\n");
|
||||
}
|
||||
|
||||
export function buildIframeMessageText({
|
||||
text,
|
||||
prompt,
|
||||
}: {
|
||||
text?: string;
|
||||
prompt?: string;
|
||||
}) {
|
||||
const primaryText = trimToUndefined(text) || trimToUndefined(prompt) || "";
|
||||
return primaryText;
|
||||
}
|
||||
|
||||
function buildScreenshotFileParts(
|
||||
screenshot: BrainyScreenshot | undefined,
|
||||
): IframePromptInputFilePart[] {
|
||||
@@ -249,8 +254,8 @@ export function parseBrainyChatSubmitMessage(
|
||||
const prompt = trimToUndefined(data.payload?.prompt);
|
||||
const pageContext = normalizePageContext(data.payload?.pageContext);
|
||||
const files = buildScreenshotFileParts(data.payload?.screenshot);
|
||||
const submitText = buildIframeMessageText({
|
||||
text,
|
||||
const submitText = buildIframeMessageText({ text, prompt });
|
||||
const promptPrefix = buildIframePromptPrefix({
|
||||
prompt,
|
||||
pageContext,
|
||||
hasAttachedImage: files.length > 0,
|
||||
@@ -263,5 +268,6 @@ export function parseBrainyChatSubmitMessage(
|
||||
...(requestId
|
||||
? { iframeContext: { brainy_request_id: requestId } }
|
||||
: {}),
|
||||
...(promptPrefix ? { additionalKwargs: { prompt_prefix: promptPrefix } } : {}),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user