fix toggling of ai instance discord properties
This commit is contained in:
@@ -37,6 +37,14 @@ interface AiInstanceVmV1 {
|
||||
messages: ChatMessageVmV1[];
|
||||
}
|
||||
|
||||
interface DiscordOnlineVmV1 {
|
||||
online: boolean;
|
||||
}
|
||||
|
||||
interface DiscordReactoToChatVmV1 {
|
||||
reactToChat: boolean;
|
||||
}
|
||||
|
||||
@Route('api/v1/ai/instances')
|
||||
@Middlewares(isAuthenticatedMiddleware)
|
||||
@Tags('ai')
|
||||
@@ -74,24 +82,24 @@ export class AiInstanceController extends Controller {
|
||||
@Post('{id}/discord/online')
|
||||
@SuccessResponse(200, 'Ok')
|
||||
@Response(404, 'Not found')
|
||||
async discordOnline(@Path() id: UUID, @Body() body: boolean): Promise<void> {
|
||||
async discordOnline(@Path() id: UUID, @Body() body: DiscordOnlineVmV1): Promise<void> {
|
||||
const ai = this.service.getInstanceById(id as nodeUUID);
|
||||
if (!ai) {
|
||||
this.setStatus(404);
|
||||
return;
|
||||
}
|
||||
await ai.discord.setOnline(body);
|
||||
await ai.discord.setOnline(body.online);
|
||||
}
|
||||
|
||||
@Post('{id}/discord/reactToChat')
|
||||
@SuccessResponse(200, 'Ok')
|
||||
@Response(404, 'Not found')
|
||||
async discordReactToChat(@Path() id: UUID, @Body() body: boolean): Promise<void> {
|
||||
async discordReactToChat(@Path() id: UUID, @Body() body: DiscordReactoToChatVmV1): Promise<void> {
|
||||
const ai = this.service.getInstanceById(id as nodeUUID);
|
||||
if (!ai) {
|
||||
this.setStatus(404);
|
||||
return;
|
||||
}
|
||||
ai.discord.setReactToChat(body);
|
||||
ai.discord.setReactToChat(body.reactToChat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +162,22 @@ const models: TsoaRoute.Models = {
|
||||
"additionalProperties": false,
|
||||
},
|
||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
"DiscordOnlineVmV1": {
|
||||
"dataType": "refObject",
|
||||
"properties": {
|
||||
"online": {"dataType":"boolean","required":true},
|
||||
},
|
||||
"additionalProperties": false,
|
||||
},
|
||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
"DiscordReactoToChatVmV1": {
|
||||
"dataType": "refObject",
|
||||
"properties": {
|
||||
"reactToChat": {"dataType":"boolean","required":true},
|
||||
},
|
||||
"additionalProperties": false,
|
||||
},
|
||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
};
|
||||
const templateService = new ExpressTemplateService(models, {"noImplicitAdditionalProperties":"throw-on-extras","bodyCoercion":true});
|
||||
|
||||
@@ -857,7 +873,7 @@ export function RegisterRoutes(app: Router) {
|
||||
async function AiInstanceController_discordOnline(request: ExRequest, response: ExResponse, next: any) {
|
||||
const args: Record<string, TsoaRoute.ParameterSchema> = {
|
||||
id: {"in":"path","name":"id","required":true,"ref":"UUID"},
|
||||
body: {"in":"body","name":"body","required":true,"dataType":"boolean"},
|
||||
body: {"in":"body","name":"body","required":true,"ref":"DiscordOnlineVmV1"},
|
||||
};
|
||||
|
||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
@@ -893,7 +909,7 @@ export function RegisterRoutes(app: Router) {
|
||||
async function AiInstanceController_discordReactToChat(request: ExRequest, response: ExResponse, next: any) {
|
||||
const args: Record<string, TsoaRoute.ParameterSchema> = {
|
||||
id: {"in":"path","name":"id","required":true,"ref":"UUID"},
|
||||
body: {"in":"body","name":"body","required":true,"dataType":"boolean"},
|
||||
body: {"in":"body","name":"body","required":true,"ref":"DiscordReactoToChatVmV1"},
|
||||
};
|
||||
|
||||
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script lang="ts">
|
||||
import {Options, Vue} from 'vue-class-component';
|
||||
import {Prop} from "vue-property-decorator";
|
||||
import {getCurrentInstance} from "vue";
|
||||
import {toast} from "vue3-toastify";
|
||||
import {AiInstanceVmV1} from 'ai-oas';
|
||||
import {Prop} from 'vue-property-decorator';
|
||||
import {getCurrentInstance} from 'vue';
|
||||
import {toast} from 'vue3-toastify';
|
||||
import {AiInstanceVmV1, DiscordOnlineVmV1, DiscordReactoToChatVmV1} from 'ai-oas';
|
||||
import {ApiStore} from '@/stores/ApiStore';
|
||||
|
||||
@Options({
|
||||
@@ -23,10 +23,12 @@ export default class Discord extends Vue {
|
||||
set online(val: boolean) {
|
||||
const oldVal = this.online;
|
||||
this.aiInstance.discord.online = val;
|
||||
this.apiStore.aiApi.discordOnline(this.aiInstance.configuration.id, val).catch(e => {
|
||||
toast.error('Error while set online status: ' + JSON.stringify(e));
|
||||
this.aiInstance.discord.online = oldVal;
|
||||
});
|
||||
this.apiStore.aiApi
|
||||
.discordOnline(this.aiInstance.configuration.id, DiscordOnlineVmV1.fromJson({online: val}))
|
||||
.catch(e => {
|
||||
toast.error('Error while set online status: ' + JSON.stringify(e));
|
||||
this.aiInstance.discord.online = oldVal;
|
||||
});
|
||||
}
|
||||
|
||||
get reactToChat(): boolean {
|
||||
@@ -36,14 +38,16 @@ export default class Discord extends Vue {
|
||||
set reactToChat(val: boolean) {
|
||||
const oldVal = this.online;
|
||||
this.aiInstance.discord.reactToChat = val;
|
||||
this.apiStore.aiApi.discordReactToChat(this.aiInstance.configuration.name, val).catch(e => {
|
||||
toast.error('Error while setting react_to_chat status: ' + JSON.stringify(e));
|
||||
this.aiInstance.discord.reactToChat = oldVal;
|
||||
});
|
||||
this.apiStore.aiApi
|
||||
.discordReactToChat(this.aiInstance.configuration.id, DiscordReactoToChatVmV1.fromJson({reactToChat: val}))
|
||||
.catch(e => {
|
||||
toast.error('Error while setting react_to_chat status: ' + JSON.stringify(e));
|
||||
this.aiInstance.discord.reactToChat = oldVal;
|
||||
});
|
||||
}
|
||||
|
||||
get uid(): string {
|
||||
return "" + getCurrentInstance()?.uid!;
|
||||
return '' + getCurrentInstance()?.uid!;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
24
swagger.json
24
swagger.json
@@ -308,6 +308,30 @@
|
||||
],
|
||||
"type": "object",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"DiscordOnlineVmV1": {
|
||||
"properties": {
|
||||
"online": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"online"
|
||||
],
|
||||
"type": "object",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"DiscordReactoToChatVmV1": {
|
||||
"properties": {
|
||||
"reactToChat": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"reactToChat"
|
||||
],
|
||||
"type": "object",
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"securitySchemes": {}
|
||||
|
||||
Reference in New Issue
Block a user