Skip to content

Commit

Permalink
feat(kb): Link to personas
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola committed Aug 6, 2024
1 parent 4eb1a8e commit 37b589e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 116 deletions.
113 changes: 0 additions & 113 deletions src/components/KnowledgeStoreUploader.ts

This file was deleted.

21 changes: 20 additions & 1 deletion src/components/dialog/PersonaDialog.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<template>
<ltai-dialog
:title="title"
@save="emit('savePersona', { ...basePersona, name, role, description, avatar: toRaw(avatar) })"
@save="
emit('savePersona', {
...basePersona,
name,
role,
description,
avatar: toRaw(avatar),
knowledgeBases: toRaw(selectedKnowledgeBases),
})
"
>
<q-card-section horizontal>
<q-card-section class="tw-my-auto">
Expand All @@ -21,6 +30,10 @@
<span>Persona Description</span>
<q-input v-model="description" autogrow bg-color="secondary" input-class="text-light" outlined type="textarea" />
</q-card-section>
<q-card-section>
<span>Knowledge bases</span>
<knowledge-bases-selector v-model="selectedKnowledgeBases" />
</q-card-section>
</ltai-dialog>
</template>

Expand All @@ -29,6 +42,7 @@ import { PropType, ref, toRaw, watch } from 'vue';
import AlephAvatar from 'components/AlephAvatar.vue';
import { BasePersonaEdition, defaultBasePersona } from 'src/types/personas';
import LtaiDialog from 'components/libertai/LtaiDialog.vue';
import KnowledgeBasesSelector from 'components/select/KnowledgeBasesSelector.vue';
const props = defineProps({
title: {
Expand All @@ -48,6 +62,7 @@ const name = ref(props.basePersona.name);
const role = ref(props.basePersona.role);
const description = ref(props.basePersona.description);
const avatar = ref(props.basePersona.avatar);
const selectedKnowledgeBases = ref<string[]>([]);
watch(
() => props.basePersona.name,
Expand All @@ -65,4 +80,8 @@ watch(
() => props.basePersona.avatar,
() => (avatar.value = props.basePersona.avatar),
);
watch(
() => props.basePersona.knowledgeBases,
() => (selectedKnowledgeBases.value = JSON.parse(JSON.stringify(props.basePersona.knowledgeBases))),
);
</script>
3 changes: 2 additions & 1 deletion src/pages/PersonaManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
allowEdit: true,
hidden: false,
id: uuidv4(),
knowledgeBases: [],
});
}
"
Expand Down Expand Up @@ -166,6 +165,7 @@ const personaExportImportSchema = z.object({
item_hash: z.string(),
ipfs_hash: z.string(),
}),
knowledgeBases: z.array(z.string()),
}),
});
type PersonaExportImportSchema = z.infer<typeof personaExportImportSchema>;
Expand All @@ -178,6 +178,7 @@ const exportPersona = (persona: UIPersona) => {
name: persona.name,
role: persona.role,
avatar: persona.avatar,
knowledgeBases: persona.knowledgeBases,
},
};
Expand Down
3 changes: 2 additions & 1 deletion src/types/personas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type UIPersona = Persona & {
knowledgeBases: string[]; // IDs of linked knowledge bases
};

export type BasePersonaEdition = Pick<UIPersona, 'name' | 'role' | 'description' | 'avatar'>;
export type BasePersonaEdition = Pick<UIPersona, 'name' | 'role' | 'description' | 'avatar' | 'knowledgeBases'>;

export const defaultBasePersona: BasePersonaEdition = {
name: '',
Expand All @@ -22,6 +22,7 @@ export const defaultBasePersona: BasePersonaEdition = {
item_hash: '90db3237796d27118e0b9e21dae10a4b1179878f869cb6c0058d0d7c00b0440d',
ipfs_hash: 'QmQMBfgnmuxcQ4kptR1oPE9guYxG13GpASjYVeFQSxNxjE',
},
knowledgeBases: [],
};

// eslint-disable-next-line no-unused-vars
Expand Down

0 comments on commit 37b589e

Please sign in to comment.