Skip to content

Commit

Permalink
uploading conversations is now possible :)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeus committed May 19, 2024
1 parent f3c4498 commit 1ee3bb5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
38 changes: 36 additions & 2 deletions src/components/ChatSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@
</q-item>
</q-list>
<div class="row justify-around items-center">
<FileDropzone
@update:model-value="loadConversation"
accept="*"
disable-dropzone-border
>
<q-btn dense class="fit" flat>
<q-icon name="file_upload" />
<q-tooltip>Upload Conversation</q-tooltip>
</q-btn>
</FileDropzone>
<q-btn
dense
flat
Expand Down Expand Up @@ -141,9 +151,10 @@ import {
} from 'src/modules/taskyon/taskManager';
import SimpleSettings from 'components/SimpleSettings.vue';
import { useTaskyonStore } from 'stores/taskyonState';
import { LLMTask } from 'src/modules/taskyon/types';
import { LLMTask, TaskListType } from 'src/modules/taskyon/types';
import { exportFile } from 'quasar';
import { dump } from 'js-yaml';
import { dump, load } from 'js-yaml';
import FileDropzone from 'components/FileDropzone.vue';

const state = useTaskyonStore();

Expand Down Expand Up @@ -206,4 +217,27 @@ async function onDownloadChat(conversationId: string) {
exportFile(fileName, fileContent, mimeType);
}
}
async function loadConversation(files: File[]) {
if (files) {
console.log('adding files to our conversations!');
const tm = await state.getTaskManager();
let last_task_id: string | undefined = undefined;
for (let i = 0; i < files.length; i++) {
console.log(files[i]);
const fileStr = await files[i].text();
const taskListRaw = load(fileStr);
const result = await TaskListType.safeParseAsync(taskListRaw);
if (result.success) {
const taskList = result.data;
taskList.forEach((t) => {
void tm.setTask(t, true);
last_task_id = t.id;
});
}
}
state.chatState.selectedTaskId = last_task_id;
}
}
</script>
2 changes: 1 addition & 1 deletion src/components/taskContentEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</q-btn>
</template>
<template v-slot:before>
<FileDropzone class="fit" @update:model-value="attachFileToChat">
<FileDropzone class="fit" @update:model-value="attachFileToChat" accept="*">
<q-btn dense class="fit" flat>
<q-icon class="gt-xs" name="upload_file" />
<q-icon name="attachment" />
Expand Down
3 changes: 3 additions & 0 deletions src/modules/taskyon/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ export const LLMTask = z.object({
});
export type LLMTask = z.infer<typeof LLMTask>;

export const TaskListType = z.array(LLMTask);
export type TaskListType = z.infer<typeof TaskListType>;

export type TaskGetter = (input: string) => Promise<LLMTask | undefined>;

export const partialTaskDraft = LLMTask.pick({
Expand Down

0 comments on commit 1ee3bb5

Please sign in to comment.