mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac
This commit is contained in:
@@ -9,7 +9,6 @@ export const uploadFile = async (token: string, file: File) => {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
},
|
||||
body: data
|
||||
|
||||
@@ -171,6 +171,7 @@ export const processDocToVectorDB = async (token: string, file_id: string) => {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
|
||||
@@ -147,7 +147,6 @@
|
||||
|
||||
if (res) {
|
||||
fileItem.status = 'processed';
|
||||
fileItem.collection_name = res.collection_name;
|
||||
files = files;
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -523,12 +522,12 @@
|
||||
</Tooltip>
|
||||
{/if}
|
||||
</div>
|
||||
{:else if file.type === 'doc'}
|
||||
{:else if ['doc', 'file'].includes(file.type)}
|
||||
<div
|
||||
class="h-16 w-[15rem] flex items-center space-x-3 px-2.5 dark:bg-gray-600 rounded-xl border border-gray-200 dark:border-none"
|
||||
>
|
||||
<div class="p-2.5 bg-red-400 text-white rounded-lg">
|
||||
{#if file.upload_status}
|
||||
{#if file.status === 'processed'}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
|
||||
@@ -117,15 +117,39 @@ const decodeTextChunk = (data) => {
|
||||
|
||||
const extractCharacter = (json) => {
|
||||
function getTrimmedValue(json, keys) {
|
||||
return keys.map((key) => json[key]).find((value) => value && value.trim());
|
||||
return keys
|
||||
.map((key) => {
|
||||
const keyParts = key.split('.');
|
||||
let value = json;
|
||||
for (const part of keyParts) {
|
||||
if (value && value[part] != null) {
|
||||
value = value[part];
|
||||
} else {
|
||||
value = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return value && value.trim();
|
||||
})
|
||||
.find((value) => value);
|
||||
}
|
||||
|
||||
const name = getTrimmedValue(json, ['char_name', 'name']);
|
||||
const summary = getTrimmedValue(json, ['personality', 'title']);
|
||||
const personality = getTrimmedValue(json, ['char_persona', 'description']);
|
||||
const scenario = getTrimmedValue(json, ['world_scenario', 'scenario']);
|
||||
const greeting = getTrimmedValue(json, ['char_greeting', 'greeting', 'first_mes']);
|
||||
const examples = getTrimmedValue(json, ['example_dialogue', 'mes_example', 'definition']);
|
||||
const name = getTrimmedValue(json, ['char_name', 'name', 'data.name']);
|
||||
const summary = getTrimmedValue(json, ['personality', 'title', 'data.description']);
|
||||
const personality = getTrimmedValue(json, ['char_persona', 'description', 'data.personality']);
|
||||
const scenario = getTrimmedValue(json, ['world_scenario', 'scenario', 'data.scenario']);
|
||||
const greeting = getTrimmedValue(json, [
|
||||
'char_greeting',
|
||||
'greeting',
|
||||
'first_mes',
|
||||
'data.first_mes'
|
||||
]);
|
||||
const examples = getTrimmedValue(json, [
|
||||
'example_dialogue',
|
||||
'mes_example',
|
||||
'definition',
|
||||
'data.mes_example'
|
||||
]);
|
||||
|
||||
return { name, summary, personality, scenario, greeting, examples };
|
||||
};
|
||||
|
||||
@@ -226,6 +226,8 @@
|
||||
return null;
|
||||
});
|
||||
|
||||
console.log(character);
|
||||
|
||||
if (character && character.character) {
|
||||
character = character.character;
|
||||
console.log(character);
|
||||
|
||||
Reference in New Issue
Block a user