Skip to content

Commit

Permalink
update conversation
Browse files Browse the repository at this point in the history
  • Loading branch information
Germey committed Jan 27, 2024
1 parent 65c923f commit ab21121
Show file tree
Hide file tree
Showing 10 changed files with 699 additions and 23 deletions.
3 changes: 0 additions & 3 deletions src/components/chat/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ export default defineComponent({
}
});
}
// onStop() {
// this.$emit('stop');
// }
}
});
</script>
Expand Down
40 changes: 40 additions & 0 deletions src/components/chatdoc/AnsweringMark.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<div class="box"></div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
name: 'AnsweringMark',
data() {
return {};
},
computed: {
conversationId() {
return this.$route.params?.conversationId?.toString();
}
}
});
</script>

<style lang="scss">
@keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.box {
width: 2px;
height: 16px;
margin-top: 3px;
background-color: var(--el-color-black);
animation: blink 1s infinite;
}
</style>
26 changes: 16 additions & 10 deletions src/components/chatdoc/Conversations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@
import { defineComponent } from 'vue';
import { ElSkeleton, ElInput } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { ROUTE_CHAT_CONVERSATION } from '@/router/constants';
import { IChatdocRepository, chatdocOperator } from '@/operators';
import { IChatdocConversation } from '@/operators';
import { ROUTE_CHATDOC_CONVERSATION, ROUTE_CHATDOC_CONVERSATION_NEW } from '@/router/constants';
import { IChatdocRepository, chatdocOperator, IChatdocConversation } from '@/operators';
export default defineComponent({
name: 'SidePanel',
Expand All @@ -82,11 +81,14 @@ export default defineComponent({
props: {},
emits: ['click'],
computed: {
repositoryId() {
return this.$route.params?.repositoryId?.toString();
},
conversationId() {
return this.$route.params?.id?.toString();
return this.$route.params?.conversationId?.toString();
},
repository(): IChatdocRepository | undefined {
return this.$store.state?.chatdoc?.repositories?.find((repository) => repository.id === this.id);
return this.$store.state?.chatdoc?.repositories?.find((repository) => repository.id === this.repositoryId);
},
conversations() {
return this.repository?.conversations;
Expand All @@ -97,9 +99,12 @@ export default defineComponent({
},
methods: {
async onNewConversation() {
// this.$router.push({
// name: ROUTE_CHATDOC_CONVERSATION
// });
this.$router.push({
name: ROUTE_CHATDOC_CONVERSATION_NEW,
params: {
repositoryId: this.repositoryId
}
});
},
async onConfirm(conversation: IChatdocConversation) {
if (conversation?.deleting) {
Expand All @@ -117,9 +122,10 @@ export default defineComponent({
return;
}
this.$router.push({
name: ROUTE_CHAT_CONVERSATION,
name: ROUTE_CHATDOC_CONVERSATION,
params: {
id
repositoryId: this.repositoryId,
conversationId: id
}
});
this.$emit('click', id);
Expand Down
223 changes: 223 additions & 0 deletions src/components/chatdoc/InputBox.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
<template>
<div class="input-box">
<el-upload
v-model:file-list="fileList"
:class="{
upload: true,
disabled: !canUpload
}"
:disabled="!canUpload"
name="file"
:show-file-list="true"
:limit="1"
:multiple="false"
action="/api/v1/files/"
:on-exceed="onExceed"
:on-error="onError"
:headers="headers"
>
<el-tooltip class="box-item" effect="dark" :content="$t('chat.message.uploadFile')" placement="top">
<span class="btn btn-upload">
<font-awesome-icon icon="fa-solid fa-paperclip" class="icon icon-attachment" />
</span>
</el-tooltip>
</el-upload>
<span
:class="{
btn: true,
'btn-send': true,
disabled: !question
}"
@click="onSubmit"
>
<font-awesome-icon icon="fa-solid fa-location-arrow" class="icon icon-send" />
</span>
<el-input
v-model="questionValue"
:rows="1"
:disabled="disabled"
class="input"
type="textarea"
:placeholder="$t('chat.message.newMessagePlaceholder')"
@keydown.enter.exact.prevent="onSubmit"
>
</el-input>
<p class="info">{{ $t('chat.message.howToUse') }}</p>
</div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { ElInput, ElMessage, ElTooltip, ElUpload } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { CHAT_MODEL_CHATGPT4_VISION, IChatModel } from '@/operators';
export default defineComponent({
name: 'InputBox',
components: {
ElInput,
ElTooltip,
FontAwesomeIcon,
ElUpload
},
props: {
disabled: {
type: Boolean,
required: false,
default: false
},
references: {
type: Array,
required: false,
default: () => []
},
question: {
type: String,
required: true
}
},
emits: ['update:question', 'update:references', 'submit'],
data() {
return {
questionValue: this.question,
fileList: []
};
},
computed: {
headers() {
return {
Authorization: `Bearer ${this.$store.state.token.access}`
};
},
urls(): string[] {
// @ts-ignore
return this.fileList.map((file: UploadFile) => file?.response?.file_url);
},
canUpload() {
return [CHAT_MODEL_CHATGPT4_VISION.name].includes(this.model.name);
},
model(): IChatModel {
return this.$store.state.chat.model;
}
},
watch: {
urls(val) {
this.$emit('update:references', val);
},
questionValue(val: string) {
this.$emit('update:question', val);
},
question(val: string) {
if (val !== this.questionValue) {
this.questionValue = val;
}
},
references(val: string[]) {
if (val.length === 0) {
this.fileList = [];
}
}
},
methods: {
onSubmit() {
if (!this.question) {
return;
}
this.$emit('submit');
},
onExceed() {
ElMessage.warning(this.$t('chat.message.uploadReferencesExceed'));
},
onError() {
ElMessage.error(this.$t('chat.message.uploadReferencesError'));
}
}
});
</script>

<style lang="scss">
.input-box {
.input {
textarea {
border: none;
background: none;
box-shadow: none;
resize: none;
line-height: 30px;
height: 40px;
}
}
.el-upload-list {
position: absolute;
width: 400px;
bottom: 45px;
}
.el-textarea.is-disabled .el-textarea__inner {
background-color: initial;
}
}
</style>

<style lang="scss" scoped>
.input-box {
position: relative;
width: 100%;
border: 1px solid #eee;
border-radius: 10px;
background: none;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.1);
top: 30px;
.upload {
display: inline-block;
&.disabled {
.btn-upload {
cursor: not-allowed;
.icon-attachment {
color: #eee;
}
}
}
}
.input {
border: none;
width: calc(100% - 80px);
margin-left: 30px;
}
.info {
display: block;
position: absolute;
font-size: 12px;
color: #666;
margin-top: 5px;
margin-left: 3px;
}
.btn {
display: block;
z-index: 100;
cursor: pointer;
position: absolute;
top: 7px;
&.btn-upload {
left: 10px;
.icon-attachment {
font-size: 14px;
color: #666;
}
}
&.btn-send {
right: 15px;
&.disabled {
.icon-send {
color: #eee;
}
cursor: not-allowed;
}
.icon-send {
font-size: 16px;
color: #666;
}
}
}
}
</style>
Loading

0 comments on commit ab21121

Please sign in to comment.