Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
4c490132
Commit
4c490132
authored
May 06, 2024
by
Timothy J. Baek
Browse files
refac: styling
parent
38590da0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
21 deletions
+28
-21
backend/apps/rag/utils.py
backend/apps/rag/utils.py
+2
-0
src/lib/components/chat/Messages/CitationsModal.svelte
src/lib/components/chat/Messages/CitationsModal.svelte
+24
-21
src/lib/components/chat/Messages/ResponseMessage.svelte
src/lib/components/chat/Messages/ResponseMessage.svelte
+2
-0
No files found.
backend/apps/rag/utils.py
View file @
4c490132
...
@@ -320,6 +320,7 @@ def rag_messages(
...
@@ -320,6 +320,7 @@ def rag_messages(
extracted_collections
.
extend
(
collection
)
extracted_collections
.
extend
(
collection
)
context_string
=
""
context_string
=
""
citations
=
[]
citations
=
[]
for
context
in
relevant_contexts
:
for
context
in
relevant_contexts
:
try
:
try
:
...
@@ -335,6 +336,7 @@ def rag_messages(
...
@@ -335,6 +336,7 @@ def rag_messages(
)
)
except
Exception
as
e
:
except
Exception
as
e
:
log
.
exception
(
e
)
log
.
exception
(
e
)
context_string
=
context_string
.
strip
()
context_string
=
context_string
.
strip
()
ra_content
=
rag_template
(
ra_content
=
rag_template
(
...
...
src/lib/components/chat/Messages/CitationsModal.svelte
View file @
4c490132
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
<Modal size="lg" bind:show>
<Modal size="lg" bind:show>
<div>
<div>
<div class=" flex justify-between dark:text-gray-300 px-5 pt-4">
<div class=" flex justify-between dark:text-gray-300 px-5 pt-4
pb-2
">
<div class=" text-lg font-medium self-center capitalize">
<div class=" text-lg font-medium self-center capitalize">
{$i18n.t('Citation')}
{$i18n.t('Citation')}
</div>
</div>
...
@@ -45,10 +45,12 @@
...
@@ -45,10 +45,12 @@
</svg>
</svg>
</button>
</button>
</div>
</div>
<div class="flex flex-col w-full px-5 py-4 dark:text-gray-200 overflow-y-scroll max-h-[22rem]">
<div class="flex flex-col md:flex-row w-full px-5 pb-5 md:space-x-4">
<div class="flex flex-col w-full dark:text-gray-200 overflow-y-scroll max-h-[22rem]">
{#each mergedDocuments as document, documentIdx}
{#each mergedDocuments as document, documentIdx}
<div class="flex flex-col w-full">
<div class="flex flex-col w-full">
<div class=" font-medium dark:text-gray-300">
<div class="
text-sm
font-medium dark:text-gray-300">
{$i18n.t('Source')}
{$i18n.t('Source')}
</div>
</div>
<div class="text-sm dark:text-gray-400">
<div class="text-sm dark:text-gray-400">
...
@@ -56,18 +58,19 @@
...
@@ -56,18 +58,19 @@
</div>
</div>
</div>
</div>
<div class="flex flex-col w-full">
<div class="flex flex-col w-full">
<div class=" font-medium dark:text-gray-300">
<div class="
text-sm
font-medium dark:text-gray-300">
{$i18n.t('Content')}
{$i18n.t('Content')}
</div>
</div>
<pre class="text-sm dark:text-gray-400">
<pre class="text-sm dark:text-gray-400
whitespace-pre-line
">
{document.document}
{document.document}
</pre>
</pre>
</div>
</div>
{#if documentIdx !== mergedDocuments.length - 1}
{#if documentIdx !== mergedDocuments.length - 1}
<hr class=" dark:border-gray-850" />
<hr class=" dark:border-gray-850
my-3
" />
{/if}
{/if}
{/each}
{/each}
</div>
</div>
</div>
</div>
</div>
</Modal>
</Modal>
src/lib/components/chat/Messages/ResponseMessage.svelte
View file @
4c490132
...
@@ -141,6 +141,7 @@
...
@@ -141,6 +141,7 @@
const zipped = (citation?.document ?? []).map(function (document, index) {
const zipped = (citation?.document ?? []).map(function (document, index) {
return [document, citation.metadata?.[index]];
return [document, citation.metadata?.[index]];
});
});
for (const [document, metadata] of zipped) {
for (const [document, metadata] of zipped) {
const source = metadata?.source ?? 'N/A';
const source = metadata?.source ?? 'N/A';
if (source in flattenedCitations) {
if (source in flattenedCitations) {
...
@@ -154,6 +155,7 @@
...
@@ -154,6 +155,7 @@
}
}
}
}
}
}
console.log(flattenedCitations);
console.log(flattenedCitations);
console.log(Object.keys(flattenedCitations));
console.log(Object.keys(flattenedCitations));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment