Skip to content

Commit

Permalink
fix: style
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola committed Aug 7, 2024
1 parent 744d121 commit f1ca947
Show file tree
Hide file tree
Showing 8 changed files with 319 additions and 178 deletions.
449 changes: 287 additions & 162 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,28 @@
"@libertai/libertai-js": "file:../libertai-js/libertai-libertai-js-0.0.10.tgz",
"@quasar/extras": "^1.16.12",
"@tanstack/vue-query": "^5.51.21",
"@wagmi/vue": "^0.0.34",
"@wagmi/vue": "^0.0.36",
"axios": "^1.7.3",
"dayjs": "^1.11.12",
"dompurify": "^3.1.6",
"eciesjs": "^0.4.7",
"filesize": "^10.1.4",
"highlight.js": "^11.10.0",
"langchain": "^0.2.12",
"langchain": "^0.2.13",
"localforage": "^1.10.0",
"marked": "^13.0.3",
"marked-highlight": "^2.1.3",
"marked": "^14.0.0",
"marked-highlight": "^2.1.4",
"mime": "^4.0.4",
"ml-distance": "^4.0.1",
"pdfjs-dist": "^4.5.136",
"pinia": "^2.2.1",
"pinia-plugin-persistedstate": "^3.2.1",
"quasar": "^2.16.7",
"quasar": "^2.16.8",
"stream": "^0.0.3",
"uuid": "^10.0.0",
"viem": "^2.18.8",
"viem": "^2.19.1",
"vue": "^3.4.36",
"vue-router": "^4.4.2",
"vue-router": "^4.4.3",
"web3": "^4.11.1",
"zod": "^3.23.8"
},
Expand Down
5 changes: 3 additions & 2 deletions src/components/MessageInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<!-- Hidden attachments upload -->
<input
ref="messageAttachmentsUpload"
accept=".txt,.md,.pdf"
:accept="supportedInputFiles"
hidden
multiple
type="file"
Expand All @@ -64,10 +64,11 @@

<script lang="ts" setup>
import { ref } from 'vue';
import { processAttachment } from 'src/utils/knowledge/attachments';
import { MessageAttachment, SendMessageParams } from 'src/types/chats';
import { processAttachment } from 'src/utils/knowledge/attachments';
import { useQuasar } from 'quasar';
import LtaiIcon from 'components/libertai/LtaiIcon.vue';
import { supportedInputFiles } from 'src/utils/knowledge/parsing';
const props = defineProps({
isLoading: {
Expand Down
14 changes: 11 additions & 3 deletions src/pages/KnowledgeBase.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<section v-if="knowledgeBaseRef" class="max-sm:tw-mx-4 md:tw-mx-10 tw-space-y-4 tw-my-5">
<section v-if="knowledgeBaseRef" class="max-sm:tw-mx-4 sm:tw-mx-10 tw-space-y-4 tw-my-5">
<q-btn class="tw-w-10 tw-h-10" to="/knowledge-base" unelevated>
<ltai-icon name="svguse:icons.svg#arrow-left" />
</q-btn>
Expand Down Expand Up @@ -41,7 +41,14 @@
<span>Upload document</span>
</q-btn>
<!-- Hidden document upload -->
<input ref="documentUpload" accept=".txt,.md,.pdf" hidden multiple type="file" @change="uploadDocuments" />
<input
ref="documentUpload"
:accept="supportedInputFiles"
hidden
multiple
type="file"
@change="uploadDocuments"
/>
</div>
</div>

Expand All @@ -55,7 +62,7 @@

<p class="tw-font-bold tw-text-base">{{ document.name }}</p>
<div class="tw-ml-auto tw-flex tw-items-center tw-gap-4">
<p>{{ filesize(document.size, { round: 0 }) }}</p>
<p class="max-sm:tw-hidden">{{ filesize(document.size, { round: 0 }) }}</p>
<q-btn class="tw-w-10 tw-h-10" disable unelevated>
<ltai-icon name="svguse:icons.svg#chat" />
</q-btn>
Expand Down Expand Up @@ -155,6 +162,7 @@ import KnowledgeBaseRenameDocumentDialog from 'components/dialog/KnowledgeBaseRe
import { processDocument } from 'src/utils/knowledge/document';
import { decryptFile, encryptFile } from 'src/utils/encryption';
import KnowledgeBaseRenameDialog from 'components/dialog/KnowledgeBaseRenameDialog.vue';
import { supportedInputFiles } from 'src/utils/knowledge/parsing';
const $q = useQuasar();
const route = useRoute();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/KnowledgeBasesList.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<section class="max-sm:tw-mx-4 md:tw-mx-10 tw-my-5">
<section class="max-sm:tw-mx-4 sm:tw-mx-10 tw-my-5">
<h4 class="text-h4 text-semibold tw-mb-5">Knowledge base</h4>
<p>Manage your knowledge bases</p>
<div class="tw-mt-4 tw-mb-8 tw-flex md:tw-justify-end">
Expand Down
6 changes: 5 additions & 1 deletion src/stores/knowledge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ export const useKnowledgeStore = defineStore('knowledge', {

await alephStorage.deleteFile(document.store.item_hash);
if (updateKnowledgeBase) {
await this.updateKnowledgeBase(knowledgeBase, kbIdentifier);
const newKnowledgeBase: KnowledgeBase = {
...knowledgeBase,
documents: knowledgeBase.documents.filter((d) => d.id !== document.id),
};
await this.updateKnowledgeBase(newKnowledgeBase, kbIdentifier);
}
},

Expand Down
5 changes: 3 additions & 2 deletions src/utils/aleph-persistent-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,12 @@ export class AlephPersistentStorage {

async saveSettings(content: object) {
try {
const message = await this.subAccountClient.createAggregate({
await this.subAccountClient.createAggregate({
key: LIBERTAI_SETTINGS_KEY,
content,
address: this.account.address,
channel: LIBERTAI_CHANNEL,
});
console.log(`Settings saved on Aleph with hash ${message.item_hash}`);
} catch (error) {
console.error(`Saving settings on Aleph failed: ${error}`);
}
Expand Down Expand Up @@ -191,6 +190,7 @@ export class AlephPersistentStorage {
content: encryptedKb,
address: this.account.address,
channel: LIBERTAI_CHANNEL,
storageEngine: ItemType.storage,
});

const identifier: KnowledgeBaseIdentifier = {
Expand Down Expand Up @@ -228,6 +228,7 @@ export class AlephPersistentStorage {
content: encryptedKb,
address: this.account.address,
channel: LIBERTAI_CHANNEL,
storageEngine: ItemType.storage,
});
} catch (error) {
console.error(`Update of knowledge base ${knowledgeBase.id} failed: ${error}`);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/knowledge/parsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import mime from 'mime';
import * as pdfjs from 'pdfjs-dist';
import { TextItem } from 'pdfjs-dist/types/src/display/api';

export const supportedInputFiles = ['.txt', '.md', '.pdf'].join(',');

const extractTextFromPdfFile = async (file: File): Promise<string> => {
const pdfUrl = URL.createObjectURL(file);

Expand Down

0 comments on commit f1ca947

Please sign in to comment.