Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/components/AssistantTextProcessingForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ import { saveLastSelectedTaskType } from '../assistant.js'

const TEXT2TEXT_TASK_TYPE_ID = 'core:text2text'
const CHAT_TASK_TYPE_ID = 'chatty-llm'
const TEXT2TEXT_IMPROVE_TASK_TYPE_ID = 'core:text2text:improve'

export default {
name: 'AssistantTextProcessingForm',
Expand Down Expand Up @@ -253,6 +254,24 @@ export default {
return {
providedCurrentTaskId: () => this.selectedTaskId,
streaming: () => this.streaming,
improveOutput: (content) => {
if (!this.showImproveWithNewInstructionsButton) {
return
}
this.$emit('new-task')
this.mySelectedTaskTypeId = TEXT2TEXT_IMPROVE_TASK_TYPE_ID
this.$nextTick(() => {
this.$refs?.assistantFormInputs?.setDefaultValues(true)
this.$nextTick(() => {
this.myInputs = {
...this.myInputs,
input: content,
}
saveLastSelectedTaskType(this.mySelectedTaskTypeId)
})
})
},
canImproveOutput: () => this.showImproveWithNewInstructionsButton,
}
},
props: {
Expand Down Expand Up @@ -460,6 +479,20 @@ export default {
actionButtonsToShow() {
return this.hasOutput ? this.actionButtons : []
},
contextWriteTaskType() {
const taskType = this.taskTypes.find(tt => tt.id === TEXT2TEXT_IMPROVE_TASK_TYPE_ID)
if (taskType === undefined) {
return null
}
if (this.taskTypeIdList !== null && !this.taskTypeIdList.includes(TEXT2TEXT_IMPROVE_TASK_TYPE_ID)) {
return null
}
return taskType
},
showImproveWithNewInstructionsButton() {
return this.hasOutput
&& this.contextWriteTaskType !== null
},
showRunningEmptyContent() {
return this.showSyncTaskRunning && this.myOutputs === null
},
Expand Down
67 changes: 41 additions & 26 deletions src/components/fields/TextInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,33 @@
:title="title"
@submit="hasValue && $emit('submit', $event)"
@update:model-value="$emit('update:value', $event)" />
<NcButton v-if="isOutput && hasValue"
class="copy-button"
variant="secondary"
:title="t('assistant', 'Copy output')"
@click="onCopy">
<template #icon>
<NcLoadingIcon v-if="streaming()" />
<ClipboardCheckOutlineIcon v-else-if="copied" />
<ContentCopyIcon v-else />
</template>
<span v-if="streaming()">
{{ t('assistant', 'Getting results...') }}
</span>
<span v-else>
{{ t('assistant', 'Copy') }}
</span>
</NcButton>
<div v-if="isOutput && hasValue"
class="output-buttons">
<NcButton v-if="!streaming() && canImproveOutput()"
class="improve-button"
variant="secondary"
:title="t('assistant', 'Improve with new instructions')"
@click="improveOutput(formattedValue)">
{{ t('assistant', 'Improve') }}
</NcButton>
<NcButton
class="copy-button"
variant="secondary"
:title="t('assistant', 'Copy output')"
@click="onCopy">
<template #icon>
<NcLoadingIcon v-if="streaming()" />
<ClipboardCheckOutlineIcon v-else-if="copied" />
<ContentCopyIcon v-else />
</template>
<span v-if="streaming()">
{{ t('assistant', 'Getting results...') }}
</span>
<span v-else>
{{ t('assistant', 'Copy') }}
</span>
</NcButton>
</div>
<NcButton v-if="!isOutput && !hasValue && showChooseButton"
class="choose-file-button"
variant="secondary"
Expand Down Expand Up @@ -95,9 +105,7 @@ export default {
isMobile,
],

inject: [
'streaming',
],
inject: ['streaming', 'improveOutput', 'canImproveOutput'],

props: {
id: {
Expand Down Expand Up @@ -230,21 +238,28 @@ body[dir="rtl"] .choose-file-button {
right: unset;
}

body[dir="rtl"] .output-buttons {
left: 4px;
right: unset;
}

.text-input {
position: relative;

.copy-button,
.output-buttons,
.choose-file-button {
position: absolute !important;
}

.choose-file-button {
bottom: 2px;
}

.copy-button {
.output-buttons {
bottom: 4px;
right: 4px;
display: flex;
gap: 4px;
}

.choose-file-button {
bottom: 2px;
}

.rich-contenteditable__input {
Expand Down
Loading