mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-16 08:21:29 +00:00
Add OpenAI series evaluation
This commit is contained in:
parent
5b2a788cfc
commit
77206d90cb
11 changed files with 1107 additions and 2 deletions
|
|
@ -1,5 +1,20 @@
|
|||
<template>
|
||||
<div class="w-full h-full px-1 md:px-2 py-1 mb-4">
|
||||
<div v-if="isBookLibrary" class="w-full border border-black-200 p-4 my-8">
|
||||
<div class="flex flex-wrap items-center">
|
||||
<div>
|
||||
<p class="text-lg">Detect Missing Series With AI</p>
|
||||
<p class="max-w-sm text-sm pt-2 text-gray-300">Analyze books in this library and add missing series names and sequence values using OpenAI. Use the full re-evaluation option after editing book metadata and you want existing series assignments reconsidered.</p>
|
||||
</div>
|
||||
<div class="grow" />
|
||||
<div>
|
||||
<ui-btn class="mb-3 block" :disabled="processing || !openAIConfigured" @click.stop="detectSeriesWithAI">Detect Missing Series</ui-btn>
|
||||
<ui-btn :disabled="processing || !openAIConfigured" @click.stop="reEvaluateSeriesWithAI">Re-evaluate All Series</ui-btn>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="!openAIConfigured" class="text-sm text-yellow-400 mt-3">Configure OpenAI first in server settings.</p>
|
||||
</div>
|
||||
|
||||
<div class="w-full border border-black-200 p-4 my-8">
|
||||
<div class="flex flex-wrap items-center">
|
||||
<div>
|
||||
|
|
@ -38,9 +53,55 @@ export default {
|
|||
},
|
||||
isBookLibrary() {
|
||||
return this.mediaType === 'book'
|
||||
},
|
||||
openAIConfigured() {
|
||||
return !!this.$store.getters['getServerSetting']('openAIConfigured')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
detectSeriesWithAI() {
|
||||
const payload = {
|
||||
message: 'Detect missing series in this library with AI? This only fills books that currently have no series metadata.',
|
||||
callback: (confirmed) => {
|
||||
if (confirmed) {
|
||||
this.runSeriesDetection(true)
|
||||
}
|
||||
},
|
||||
type: 'yesNo'
|
||||
}
|
||||
this.$store.commit('globals/setConfirmPrompt', payload)
|
||||
},
|
||||
reEvaluateSeriesWithAI() {
|
||||
const payload = {
|
||||
message: 'Re-evaluate all books in this library with AI? This can update sequence values for books that already have series metadata.',
|
||||
callback: (confirmed) => {
|
||||
if (confirmed) {
|
||||
this.runSeriesDetection(false)
|
||||
}
|
||||
},
|
||||
type: 'yesNo'
|
||||
}
|
||||
this.$store.commit('globals/setConfirmPrompt', payload)
|
||||
},
|
||||
runSeriesDetection(onlyMissing = true) {
|
||||
this.$emit('update:processing', true)
|
||||
this.$axios
|
||||
.$post(`/api/libraries/${this.libraryId}/detect-series-with-ai?onlyMissing=${onlyMissing ? 1 : 0}`)
|
||||
.then((data) => {
|
||||
if (!data.updated) {
|
||||
this.$toast.info(this.$strings.ToastNoUpdatesNecessary)
|
||||
} else {
|
||||
this.$toast.success(onlyMissing ? `AI added series data to ${data.updated} books` : `AI re-evaluated series data for ${data.updated} books`)
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed to detect series with AI', error)
|
||||
this.$toast.error(error.response?.data || this.$strings.ToastFailedToUpdate)
|
||||
})
|
||||
.finally(() => {
|
||||
this.$emit('update:processing', false)
|
||||
})
|
||||
},
|
||||
removeAllMetadataClick(ext) {
|
||||
const payload = {
|
||||
message: this.$getString('MessageConfirmRemoveMetadataFiles', [ext]),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue