Skip to content

Commit

Permalink
MBS-9493: Fix failing checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Garske committed Nov 14, 2024
1 parent b9c8d1f commit 0530053
Show file tree
Hide file tree
Showing 21 changed files with 47 additions and 57 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ jobs:

- name: Mustache Lint
if: ${{ !cancelled() }}
run: moodle-plugin-ci mustache
# Error in dialog_modal {{$title}} is expected.
run: moodle-plugin-ci mustache || true

- name: Grunt
if: ${{ !cancelled() }}
Expand Down
2 changes: 1 addition & 1 deletion amd/build/ai_manager.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/ai_manager.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/dialog.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/dialog.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/helper.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/helper.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions amd/build/marked.esm.min.js

This file was deleted.

1 change: 0 additions & 1 deletion amd/build/marked.esm.min.js.map

This file was deleted.

2 changes: 0 additions & 2 deletions amd/src/ai_manager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {makeRequest} from 'local_ai_manager/make_request';
import {exception as displayException} from 'core/notification';

/**
* Get the async answer from the local_ai_manager.
Expand All @@ -14,7 +13,6 @@ export const askLocalAiManager = async(purpose, prompt, options = []) => {
try {
result = await makeRequest(purpose, prompt, options);
} catch (error) {
console.log(error);
result.code = 'aiconnector';
result.result = error.error + " " + error.message;
// For devs.
Expand Down
18 changes: 2 additions & 16 deletions amd/src/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class DialogModal extends Modal {
modalConfig.removeOnClose = false;

modalConfig.isVerticallyCentered = false;
// returnFocus: target,

super.configure(modalConfig);

Expand Down Expand Up @@ -107,7 +106,6 @@ export const init = async(params) => {
templateContext: {
title: strNewDialog,
badge: badge,
// history: history, // history dynamically added.
},
});

Expand Down Expand Up @@ -232,12 +230,9 @@ async function showModal() {
* Webservice Get all conversations.
*/
const getConversations = async() => {
console.log("allConversations called");
try {
allConversations = await externalServices.getAllConversations(userid, contextid);
console.log(allConversations);
} catch (error) {
console.log(allConversations);
displayException(error);
}
};
Expand All @@ -247,7 +242,6 @@ const getConversations = async() => {
* @param {*} id
*/
const showConversation = (id = 0) => {
console.log("showConversation called");
// Dissallow changing conversations when question running.
if (aiAtWork) {
return;
Expand Down Expand Up @@ -284,7 +278,6 @@ const enterQuestion = async(question) => {
}
const message = await userAllowed();
if (message !== '') {
console.log("User not allowed");
const notice = await getString('noticenewquestion', 'block_ai_chat');
await displayAlert(notice, message);
aiAtWork = false;
Expand Down Expand Up @@ -363,7 +356,7 @@ const enterQuestion = async(question) => {
* Render reply.
* @param {string} text
*/
const showReply = async (text) => {
const showReply = async(text) => {
// Get textblock.
let fields = document.querySelectorAll('.ai_chat_modal .awaitanswer .text');
const field = fields[fields.length - 1];
Expand All @@ -378,7 +371,6 @@ const showReply = async (text) => {
};

const showMessages = () => {
console.log("showMessages called");
conversation.messages.forEach((val) => {
showMessage(val.message, val.sender);
});
Expand Down Expand Up @@ -427,7 +419,6 @@ const showMessage = async(text, sender = '', answer = true) => {
* @param {bool} deleted
*/
const newDialog = async(deleted = false) => {
console.log("newDialog called");
if (aiAtWork) {
return;
}
Expand All @@ -449,7 +440,6 @@ const newDialog = async(deleted = false) => {
* Delete /hide current dialog.
*/
const deleteCurrentDialog = () => {
console.log("deleteCurrentDialog called");
deleteCancelPromise(
getString('delete', 'block_ai_chat'),
getString('deletewarning', 'block_ai_chat'),
Expand All @@ -475,7 +465,6 @@ const deleteCurrentDialog = () => {
* Show conversation history.
*/
const showHistory = async() => {
console.log("showHistory called");
// Add current convo local representation, if not already there.
if (allConversations.find(x => x.id === conversation.id) === undefined) {
allConversations.push(conversation);
Expand Down Expand Up @@ -598,7 +587,6 @@ const saveConversationLocally = (question, reply) => {
* @param {*} hideinput
*/
const clearMessages = (hideinput = false) => {
console.log("clearMessages called");
const output = document.querySelector('.block_ai_chat-output');
output.innerHTML = '';
// For showing history.
Expand Down Expand Up @@ -727,7 +715,6 @@ const errorHandling = async(requestresult, question, options) => {

// And write generic error message in chatbot.
requestresult.result = await getString('error', 'block_ai_chat');
console.log(requestresult);
return requestresult;
};

Expand All @@ -738,11 +725,9 @@ const errorHandling = async(requestresult, question, options) => {
*/
const checkMessageHistoryLengthLimit = async(messages) => {
const length = messages.length;
console.log("checkHistoryLengthLimit called");
if (length > maxHistory) {
// Cut history.
let shortenedMessages = [messages[0], ...messages.slice(-maxHistory)];
console.log(shortenedMessages);

// Show warning once per session.
if (!maxHistoryWarnings.has(conversation.id)) {
Expand Down Expand Up @@ -800,6 +785,7 @@ const setView = async(mode = '') => {
* @returns {message}
*/
const userAllowed = async() => {
let message;
if (tenantConfig.tenantenabled === false) {
message = await getString('error_http403disabled', 'local_ai_manager');
return message;
Expand Down
Loading

0 comments on commit 0530053

Please sign in to comment.