Skip to content

Commit

Permalink
Regen DTOs and Fix UIs
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Nov 26, 2024
1 parent 22edcaa commit 8d881d0
Show file tree
Hide file tree
Showing 15 changed files with 279 additions and 292 deletions.
3 changes: 2 additions & 1 deletion AiServer/Configure.AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public override void Configure()
feature.MetadataTypesConfig.DefaultNamespaces.Add(typeof(BackgroundJobBase).Namespace);
});

#if DEBUG && FALSE
#if DEBUG && !FALSE
Metadata.ForceInclude = [
typeof(AdminQueryApiKeys),
typeof(AdminCreateApiKey),
Expand All @@ -173,6 +173,7 @@ public override void Configure()
typeof(AdminJobDashboard),
typeof(AdminRequeueFailedJobs),
typeof(AdminGetJobProgress),
typeof(QueryPrompts),
];

// Avoid having to re-renter AuthSecret and API Keys during Development
Expand Down
2 changes: 1 addition & 1 deletion AiServer/wwwroot/mjs/components/AiProviders.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ref, computed, onMounted, watch, nextTick } from "vue"
import { leftPart, rightPart } from "@servicestack/client"
import { useClient } from "@servicestack/vue"
import { QueryAiTypes, GetOllamaModels } from "dtos"
import { QueryAiTypes, GetOllamaModels } from "../dtos.mjs"

const SelectModels = {
template:`
Expand Down
2 changes: 1 addition & 1 deletion AiServer/wwwroot/mjs/components/Chat.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useClient } from "@servicestack/vue"
import { marked } from "../markdown.mjs"
import { addCopyButtonToCodeBlocks } from "../dom.mjs"
import { useUiLayout, UiLayout, ThreadStorage, HistoryTitle, HistoryGroups } from "../utils.mjs"
import { QueryPrompts, ActiveAiModels, OpenAiChatCompletion } from "dtos"
import { QueryPrompts, ActiveAiModels, OpenAiChatCompletion } from "../dtos.mjs"

export default {
components: {
Expand Down
10 changes: 5 additions & 5 deletions AiServer/wwwroot/mjs/components/ImageToImage.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ref, computed, onMounted, inject, watch } from "vue"
import { useClient } from "@servicestack/vue"
import { createErrorStatus } from "@servicestack/client"
import { ImageToImage } from "dtos"
import { ImageToImage } from "../dtos.mjs"
import { UiLayout, ThreadStorage, HistoryTitle, HistoryGroups, useUiLayout, icons, acceptedImages } from "../utils.mjs"
import { ArtifactGallery, ArtifactDownloads } from "./Artifacts.mjs"
import PromptGenerator from "./PromptGenerator.mjs"
Expand Down Expand Up @@ -188,12 +188,12 @@ export default {

const api = await client.apiForm(request.value, formData, { jsconfig: 'eccn' })

/** @type {GenerationResponse} */
/** @type {ArtifactGenerationResponse} */
const r = api.response
if (r) {
console.debug(`${storage.prefix}.response`, r)

if (!r.outputs?.length) {
if (!r.results?.length) {
error.value = createErrorStatus("no results were returned")
} else {
const id = parseInt(routes.id) || storage.createId()
Expand All @@ -214,7 +214,7 @@ export default {
history.value.push({
id,
title: thread.value.title,
icon: r.outputs[0].url
icon: r.results[0].url
})
}
saveHistory()
Expand All @@ -237,7 +237,7 @@ export default {
}

function toArtifacts(result) {
return result.response?.outputs?.map(x => ({
return result.response?.results?.map(x => ({
width: result.request.width,
height: result.request.height,
url: x.url,
Expand Down
8 changes: 4 additions & 4 deletions AiServer/wwwroot/mjs/components/ImageToText.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ref, onMounted, inject, watch } from "vue"
import { useClient, useFiles } from "@servicestack/vue"
import { createErrorStatus } from "@servicestack/client"
import { ImageToText } from "dtos"
import { ImageToText } from "../dtos.mjs"
import { UiLayout, ThreadStorage, HistoryTitle, HistoryGroups, useUiLayout, icons, Img, acceptedImages } from "../utils.mjs"
import FileUpload from "./FileUpload.mjs"

Expand Down Expand Up @@ -66,7 +66,7 @@ export default {
</div>
</div>
<div>
<div v-for="output in result.response.textOutputs" class="relative border border-indigo-600/25 rounded-lg p-2 mb-4 overflow-hidden">
<div v-for="output in result.response.results" class="relative border border-indigo-600/25 rounded-lg p-2 mb-4 overflow-hidden">
<div class="prose">{{output.text}}</div>
</div>
</div>
Expand Down Expand Up @@ -135,12 +135,12 @@ export default {
const image = formData.get('image').name

const api = await client.apiForm(request.value, formData, { jsconfig: 'eccn' })
/** @type {GenerationResponse} */
/** @type {ArtifactGenerationResponse} */
const r = api.response
if (r) {
console.debug(`${storage.prefix}.response`, r)

if (!r.textOutputs?.length) {
if (!r.results?.length) {
error.value = createErrorStatus("no results were returned")
} else {
const id = parseInt(routes.id) || storage.createId()
Expand Down
8 changes: 4 additions & 4 deletions AiServer/wwwroot/mjs/components/ImageUpscale.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ref, onMounted, inject, watch } from "vue"
import { useClient, useFiles } from "@servicestack/vue"
import { createErrorStatus } from "@servicestack/client"
import { ImageUpscale } from "dtos"
import { ImageUpscale } from "../dtos.mjs"
import { UiLayout, ThreadStorage, HistoryTitle, HistoryGroups, useUiLayout, icons, toArtifacts, acceptedImages } from "../utils.mjs"
import { ArtifactGallery, ArtifactDownloads } from "./Artifacts.mjs"
import FileUpload from "./FileUpload.mjs"
Expand Down Expand Up @@ -151,12 +151,12 @@ export default {
const image = formData.get('image').name

const api = await client.apiForm(request.value, formData, { jsconfig: 'eccn' })
/** @type {GenerationResponse} */
/** @type {ArtifactGenerationResponse} */
const r = api.response
if (r) {
console.debug(`${storage.prefix}.response`, r)

if (!r.outputs?.length) {
if (!r.results?.length) {
error.value = createErrorStatus("no results were returned")
} else {
const id = parseInt(routes.id) || storage.createId()
Expand All @@ -177,7 +177,7 @@ export default {
history.value.push({
id,
title: thread.value.title,
icon: r.outputs[0].url
icon: r.results[0].url
})
}
saveHistory()
Expand Down
8 changes: 3 additions & 5 deletions AiServer/wwwroot/mjs/components/MediaProviders.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {ref, computed, onMounted, watch, nextTick, toRef, watchEffect} from "vue"
import {leftPart, rightPart} from "@servicestack/client"
import {useClient} from "@servicestack/vue"
import {QueryMediaTypes, GetComfyModels, GetComfyModelMappings} from "dtos"
import {QueryMediaModels} from "../dtos.mjs";
import {ref, computed, onMounted, watch } from "vue"
import { useClient } from "@servicestack/vue"
import { QueryMediaModels, QueryMediaTypes, GetComfyModels } from "../dtos.mjs"

const SelectModels = {
template: `
Expand Down
2 changes: 1 addition & 1 deletion AiServer/wwwroot/mjs/components/PromptGenerator.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ref, computed, watch, onMounted } from "vue"
import { useClient } from "@servicestack/vue"
import { createErrorStatus } from "@servicestack/client"
import { ActiveAiModels, QueryPrompts, OpenAiChatCompletion } from "dtos"
import { ActiveAiModels, QueryPrompts, OpenAiChatCompletion } from "../dtos.mjs"

export default {
template:`
Expand Down
2 changes: 1 addition & 1 deletion AiServer/wwwroot/mjs/components/SignInForm.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ref } from "vue"
import { useClient, useAuth } from "@servicestack/vue"
import { Authenticate } from "dtos"
import { Authenticate } from "../dtos.mjs"
import { Img } from "/mjs/utils.mjs"

export default {
Expand Down
8 changes: 4 additions & 4 deletions AiServer/wwwroot/mjs/components/SpeechToText.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ref, onMounted, inject, watch } from "vue"
import { useClient, useFiles } from "@servicestack/vue"
import { createErrorStatus } from "@servicestack/client"
import { SpeechToText } from "dtos"
import { SpeechToText } from "../dtos.mjs"
import { UiLayout, ThreadStorage, HistoryTitle, HistoryGroups, useUiLayout, icons, acceptedAudios } from "../utils.mjs"
import FileUpload from "./FileUpload.mjs"

Expand Down Expand Up @@ -65,7 +65,7 @@ export default {
</div>
</div>
<div>
<div v-for="output in result.response.textOutputs.filter(x => !x.text.startsWith('['))" class="relative border border-indigo-600/25 rounded-lg p-2 mb-4 overflow-hidden">
<div v-for="output in result.response.results.filter(x => !x.text.startsWith('['))" class="relative border border-indigo-600/25 rounded-lg p-2 mb-4 overflow-hidden">
<div class="prose">{{output.text}}</div>
</div>
</div>
Expand Down Expand Up @@ -134,12 +134,12 @@ export default {
const audio = formData.get('audio').name

const api = await client.apiForm(request.value, formData, { jsconfig: 'eccn' })
/** @type {GenerationResponse} */
/** @type {TextGenerationResponse} */
const r = api.response
if (r) {
console.debug(`${storage.prefix}.response`, r)

if (!r.textOutputs?.length) {
if (!r.results?.length) {
error.value = createErrorStatus("no results were returned")
} else {
const id = parseInt(routes.id) || storage.createId()
Expand Down
10 changes: 5 additions & 5 deletions AiServer/wwwroot/mjs/components/TextToImage.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ref, computed, onMounted, inject, watch } from "vue"
import { useClient } from "@servicestack/vue"
import { createErrorStatus } from "@servicestack/client"
import { TextToImage, ActiveMediaModels } from "dtos"
import { TextToImage, ActiveMediaModels } from "../dtos.mjs"
import { UiLayout, ThreadStorage, HistoryTitle, HistoryGroups, useUiLayout, icons, toArtifacts } from "../utils.mjs"
import { ArtifactGallery, ArtifactDownloads } from "./Artifacts.mjs"
import PromptGenerator from "./PromptGenerator.mjs"
Expand Down Expand Up @@ -167,12 +167,12 @@ export default {

error.value = null
const api = await client.api(request.value)
/** @type {GenerationResponse} */
/** @type {ArtifactGenerationResponse} */
const r = api.response
if (r) {
console.debug(`${storage.prefix}.response`, r)

if (!r.outputs?.length) {
if (!r.results?.length) {
error.value = createErrorStatus("no results were returned")
} else {
const id = parseInt(routes.id) || storage.createId()
Expand All @@ -193,7 +193,7 @@ export default {
history.value.push({
id,
title: thread.value.title,
icon: r.outputs[0].url
icon: r.results[0].url
})
}
saveHistory()
Expand Down Expand Up @@ -244,7 +244,7 @@ export default {
thread.value = storage.getThread(storage.getThreadId(id))
threadRef.value = history.value.find(x => x.id === parseInt(routes.id))
Object.keys(storage.defaults).forEach(k =>
request.value[k] = thread.value[k] ?? storage.defaults[k])
request.value[k] = thread.value?.[k] ?? storage.defaults[k])
} else {
thread.value = null
Object.keys(storage.defaults).forEach(k => request.value[k] = storage.defaults[k])
Expand Down
8 changes: 4 additions & 4 deletions AiServer/wwwroot/mjs/components/TextToSpeech.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ In the ancient land of Eldoria, where the skies were painted with shades of myst
import { ref, onMounted, inject, watch, nextTick } from "vue"
import { createErrorStatus, lastRightPart, EventBus } from "@servicestack/client"
import { useClient, useFormatters } from "@servicestack/vue"
import { TextToSpeech, QueryTextToSpeechVoices } from "dtos"
import { TextToSpeech, QueryTextToSpeechVoices } from "../dtos.mjs"
import { UiLayout, ThreadStorage, HistoryTitle, HistoryGroups, useUiLayout, icons, toArtifacts, acceptedImages } from "../utils.mjs"
import { ArtifactGallery } from "./Artifacts.mjs"
import FileUpload from "./FileUpload.mjs"
Expand Down Expand Up @@ -74,7 +74,7 @@ export default {
</div>
<div>
<div v-for="output in result.response.outputs" class="flex items-center justify-between">
<div v-for="output in result.response.results" class="flex items-center justify-between">
<ListenButton :src="output.url" :title="result.request.input"
@play="playAudio=$event" @pause="playAudio=null" :playing="playingAudio?.src==output.url" />
<a :href="output.url + '?download=1'" class="flex items-center text-indigo-600 hover:text-indigo-700">
Expand Down Expand Up @@ -160,12 +160,12 @@ export default {
error.value = null

const api = await client.api(request.value, { jsconfig: 'eccn' })
/** @type {GenerationResponse} */
/** @type {ArtifactGenerationResponse} */
const r = api.response
if (r) {
console.debug(`${storage.prefix}.response`, r)

if (!r.outputs?.length) {
if (!r.results?.length) {
error.value = createErrorStatus("no results were returned")
} else {
const id = parseInt(routes.id) || storage.createId()
Expand Down
2 changes: 1 addition & 1 deletion AiServer/wwwroot/mjs/components/UiHome.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ref, inject, watch, onMounted } from "vue"
import { inject, onMounted } from "vue"
import { langs, openAi } from "../langs.mjs"
import { prefixes, icons, uiLabel } from "../utils.mjs"
import ShellCommand from "./ShellCommand.mjs"
Expand Down
Loading

0 comments on commit 8d881d0

Please sign in to comment.