feat: Add citations display to playground message

Adds a collapsible section to the playground message that displays citations for the response. This is intended to help users better understand the sources used by the model.
This commit is contained in:
n4ze3m 2024-08-31 21:06:32 +05:30
parent 9bd3193ad9
commit 3f61c6afc2
11 changed files with 46 additions and 20 deletions

View File

@ -95,5 +95,6 @@
"rephrase": "Rephrase",
"translate": "Translate",
"custom": "Custom"
}
},
"citations": "Citations"
}

View File

@ -94,5 +94,6 @@
"explain": "Explicar",
"rephrase": "Reformular",
"translate": "Traducir"
}
},
"citations": "Citas"
}

View File

@ -88,5 +88,6 @@
}
},
"advanced": "تنظیمات بیشتر مدل"
}
},
"citations": "منابع"
}

View File

@ -94,5 +94,6 @@
"explain": "Expliquer",
"rephrase": "Reformuler",
"translate": "Traduire"
}
},
"citations": "Citations"
}

View File

@ -93,5 +93,6 @@
"explain": "Spiegare",
"rephrase": "Riformulare",
"translate": "Tradurre"
}
},
"citations": "Citazioni"
}

View File

@ -94,5 +94,6 @@
"explain": "説明",
"rephrase": "言い換え",
"translate": "翻訳"
}
},
"citations": "引用"
}

View File

@ -93,5 +93,6 @@
"explain": "വിശദീകരിക്കുക",
"rephrase": "പുനഃരൂപീകരിക്കുക",
"translate": "വിവർത്തനം ചെയ്യുക"
}
},
"citations": "ഉദ്ധരണികൾ"
}

View File

@ -94,5 +94,6 @@
"explain": "Explicar",
"rephrase": "Reformular",
"translate": "Traduzir"
}
},
"citations": "Citações"
}

View File

@ -93,5 +93,6 @@
"explain": "Объяснить",
"rephrase": "Перефразировать",
"translate": "Перевести"
}
},
"citations": "Цитаты"
}

View File

@ -94,5 +94,6 @@
"explain": "解释",
"rephrase": "重述",
"translate": "翻译"
}
},
"citations": "引用"
}

View File

@ -1,6 +1,6 @@
import Markdown from "../../Common/Markdown"
import React from "react"
import { Tag, Image, Tooltip } from "antd"
import { Tag, Image, Tooltip, Collapse } from "antd"
import { WebSearch } from "./WebSearch"
import {
CheckIcon,
@ -127,6 +127,18 @@ export const PlaygroundMessage = (props: Props) => {
)}
{props.isBot && props?.sources && props?.sources.length > 0 && (
<Collapse
className="mt-6"
ghost
items={[
{
key: "1",
label: (
<div className="italic text-gray-500 dark:text-gray-400">
{t('citations')}
</div>
),
children: (
<div className="mb-3 flex flex-wrap gap-2">
{props?.sources?.map((source, index) => (
<MessageSource
@ -136,6 +148,10 @@ export const PlaygroundMessage = (props: Props) => {
/>
))}
</div>
)
}
]}
/>
)}
{!props.isProcessing && !editMode && (
<div