mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-02 16:00:34 +02:00
add proper citation handling
This commit is contained in:
parent
eb227c0acc
commit
cb85be41b1
@ -10,7 +10,6 @@ from onyx.auth.users import current_user
|
||||
from onyx.auth.users import is_user_admin
|
||||
from onyx.configs.constants import KV_REINDEX_KEY
|
||||
from onyx.configs.constants import NotificationType
|
||||
from onyx.db.engine import get_current_tenant_id
|
||||
from onyx.db.engine import get_session
|
||||
from onyx.db.models import User
|
||||
from onyx.db.notification import create_notification
|
||||
@ -43,7 +42,6 @@ def put_settings(
|
||||
def fetch_settings(
|
||||
user: User | None = Depends(current_user),
|
||||
db_session: Session = Depends(get_session),
|
||||
tenant_id: str | None = Depends(get_current_tenant_id),
|
||||
) -> UserSettings:
|
||||
"""Settings and notifications are stuffed into this single endpoint to reduce number of
|
||||
Postgres calls"""
|
||||
|
@ -142,6 +142,11 @@ export const AgenticMessage = ({
|
||||
}
|
||||
}
|
||||
|
||||
processed = processed.replace(/\[([QD])(\d+)\]/g, (match, type, number) => {
|
||||
const citationNumber = parseInt(number, 10);
|
||||
return `[[${type}${citationNumber}]]()`;
|
||||
});
|
||||
|
||||
processed = processed.replace(/\{\{(\d+)\}\}/g, (match, p1) => {
|
||||
const citationNumber = parseInt(p1, 10);
|
||||
return `[[${citationNumber}]]()`;
|
||||
@ -158,7 +163,6 @@ export const AgenticMessage = ({
|
||||
const [isViewingInitialAnswer, setIsViewingInitialAnswer] = useState(true);
|
||||
|
||||
const [canShowResponse, setCanShowResponse] = useState(isComplete);
|
||||
const [isPulsing, setIsPulsing] = useState(false);
|
||||
const [isRegenerateHovered, setIsRegenerateHovered] = useState(false);
|
||||
const [isRegenerateDropdownVisible, setIsRegenerateDropdownVisible] =
|
||||
useState(false);
|
||||
|
@ -139,15 +139,16 @@ const SubQuestionDisplay: React.FC<{
|
||||
return preprocessLaTeX(content);
|
||||
}
|
||||
}
|
||||
// Add newlines after ]] or ) if there's text immediately following
|
||||
content = content.replace(/(\]\]|\))((?!\s|\n|\[|\(|$).)/g, "$1\n$2");
|
||||
// Turn {{number}} into citation in content
|
||||
content = content.replace(/\[([QD])(\d+)\]/g, (match, type, number) => {
|
||||
const citationNumber = parseInt(number, 10);
|
||||
return `[[${type}${citationNumber}]]()`;
|
||||
});
|
||||
|
||||
content = content.replace(/\{\{(\d+)\}\}/g, (match, p1) => {
|
||||
const citationNumber = parseInt(p1, 10);
|
||||
return `[[${citationNumber}]]()`;
|
||||
});
|
||||
|
||||
// Add () after ]] if not present
|
||||
content = content.replace(/\]\](?!\()/g, "]]()");
|
||||
|
||||
return (
|
||||
|
Loading…
x
Reference in New Issue
Block a user