mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-27 20:38:32 +02:00
(minor) search memoization + context (#2732)
* add markdown blocks to search * nit * k
This commit is contained in:
@@ -346,6 +346,7 @@ def get_session() -> Generator[Session, None, None]:
|
|||||||
raise HTTPException(status_code=401, detail="User must authenticate")
|
raise HTTPException(status_code=401, detail="User must authenticate")
|
||||||
|
|
||||||
engine = get_sqlalchemy_engine()
|
engine = get_sqlalchemy_engine()
|
||||||
|
|
||||||
with Session(engine, expire_on_commit=False) as session:
|
with Session(engine, expire_on_commit=False) as session:
|
||||||
if MULTI_TENANT:
|
if MULTI_TENANT:
|
||||||
if not is_valid_schema_name(tenant_id):
|
if not is_valid_schema_name(tenant_id):
|
||||||
|
@@ -4,7 +4,7 @@ import {
|
|||||||
MemoizedLink,
|
MemoizedLink,
|
||||||
MemoizedParagraph,
|
MemoizedParagraph,
|
||||||
} from "@/app/chat/message/MemoizedTextComponents";
|
} from "@/app/chat/message/MemoizedTextComponents";
|
||||||
import React from "react";
|
import React, { useMemo } from "react";
|
||||||
import ReactMarkdown from "react-markdown";
|
import ReactMarkdown from "react-markdown";
|
||||||
import remarkGfm from "remark-gfm";
|
import remarkGfm from "remark-gfm";
|
||||||
|
|
||||||
@@ -17,22 +17,26 @@ export const MinimalMarkdown: React.FC<MinimalMarkdownProps> = ({
|
|||||||
content,
|
content,
|
||||||
className = "",
|
className = "",
|
||||||
}) => {
|
}) => {
|
||||||
|
const markdownComponents = useMemo(
|
||||||
|
() => ({
|
||||||
|
a: MemoizedLink,
|
||||||
|
p: MemoizedParagraph,
|
||||||
|
code: ({ node, inline, className, children, ...props }: any) => {
|
||||||
|
const codeText = extractCodeText(node, content, children);
|
||||||
|
return (
|
||||||
|
<CodeBlock className={className} codeText={codeText}>
|
||||||
|
{children}
|
||||||
|
</CodeBlock>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
[content]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
className={`w-full text-wrap break-word ${className}`}
|
className={`w-full text-wrap break-word ${className}`}
|
||||||
components={{
|
components={markdownComponents}
|
||||||
a: MemoizedLink,
|
|
||||||
p: MemoizedParagraph,
|
|
||||||
code: ({ node, inline, className, children, ...props }: any) => {
|
|
||||||
const codeText = extractCodeText(node, content, children);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<CodeBlock className={className} codeText={codeText}>
|
|
||||||
{children}
|
|
||||||
</CodeBlock>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
remarkPlugins={[remarkGfm]}
|
remarkPlugins={[remarkGfm]}
|
||||||
>
|
>
|
||||||
{content}
|
{content}
|
||||||
|
Reference in New Issue
Block a user