diff --git a/src/ol_openedx_chat/block.py b/src/ol_openedx_chat/block.py index 520526bd..507b1c8f 100644 --- a/src/ol_openedx_chat/block.py +++ b/src/ol_openedx_chat/block.py @@ -7,7 +7,7 @@ from web_fragments.fragment import Fragment from webob.response import Response from xblock.core import XBlock, XBlockAside -from xblock.fields import Boolean, Scope, String +from xblock.fields import Boolean, Scope from xmodule.x_module import AUTHOR_VIEW, STUDENT_VIEW from .compat import get_ol_openedx_chat_enabled_flag @@ -48,30 +48,6 @@ class OLChatAside(XBlockAside): scope=Scope.settings, help=_("Indicates whether or not Open Learning chat is enabled for a block"), ) - chat_prompts = String( - display_name=_("Open Learning Chat Prompt text"), - default="", - scope=Scope.settings, - help=_("Prompt hint text for chat in a block"), - ) - additional_solution = String( - display_name=_("Additional solution for problem"), - default="", - scope=Scope.settings, - help=_("Additional solution for the problem in context of chat"), - ) - llm_model = String( - display_name=_("Open Learning Chat selected LLM model"), - default="", - scope=Scope.settings, - help=_("Selected LLM model to be used for a block"), - ) - ask_tim_drawer_title = String( - display_name=_("Open Learning Drawer Title"), - default="", - scope=Scope.settings, - help=_("Drawer title displayed in the chat drawer"), - ) @XBlockAside.aside_for(STUDENT_VIEW) def student_view_aside(self, block, context=None): @@ -102,8 +78,7 @@ def student_view_aside(self, block, context=None): fragment.add_css(get_resource_bytes("static/css/ai_chat.css")) fragment.add_javascript(get_resource_bytes("static/js/ai_chat.js")) extra_context = { - "starters": self.chat_prompts.split("\n") if self.chat_prompts else [], - "ask_tim_drawer_title": self.ask_tim_drawer_title, + "ask_tim_drawer_title": f"about {block.display_name}", "block_usage_key": self.scope_ids.usage_id.usage_key.block_id, "user_id": self.runtime.user_id, "learn_ai_api_url": settings.LEARN_AI_API_URL, @@ -124,15 +99,6 @@ def author_view_aside(self, block, context=None): # noqa: ARG002 "static/html/studio_view.html", { "is_enabled": self.ol_chat_enabled, - "chat_prompts": self.chat_prompts, - "ask_tim_drawer_title": self.ask_tim_drawer_title - if self.ask_tim_drawer_title - else f"about {block.display_name}", - "selected_llm_model": self.llm_model, - "additional_solution": self.additional_solution, - "llm_models_list": list( - settings.OL_CHAT_SETTINGS - ), # Converting dict keys into a list "block_id": block.location.block_id, # Passing this along as a unique key for checkboxes # noqa: E501 }, ) @@ -166,9 +132,5 @@ def update_chat_config(self, request, suffix=""): # noqa: ARG002 "Invalid request body", status=api_status.HTTP_400_BAD_REQUEST ) - self.chat_prompts = posted_data.get("chat_prompts", "") - self.ask_tim_drawer_title = posted_data.get("ask_tim_drawer_title", "") - self.llm_model = posted_data.get("selected_llm_model", "") self.ol_chat_enabled = posted_data.get("is_enabled", False) - self.additional_solution = posted_data.get("additional_solution", "") return Response() diff --git a/src/ol_openedx_chat/static/html/studio_view.html b/src/ol_openedx_chat/static/html/studio_view.html index 245497e1..a1eafefc 100644 --- a/src/ol_openedx_chat/static/html/studio_view.html +++ b/src/ol_openedx_chat/static/html/studio_view.html @@ -1,33 +1,9 @@
- - - - - - - - - - - - - - - - - - -
- +
diff --git a/src/ol_openedx_chat/static/js/ai_chat.js b/src/ol_openedx_chat/static/js/ai_chat.js index a4e5b53d..dcda8561 100644 --- a/src/ol_openedx_chat/static/js/ai_chat.js +++ b/src/ol_openedx_chat/static/js/ai_chat.js @@ -8,10 +8,8 @@ role: "assistant", }, ]; - $(`#chat-button-${init_args.block_usage_key}`).on("click", { starters: init_args.starters, askTimTitle: init_args.ask_tim_drawer_title }, function (event) { - const starters = event.data.starters.map(message => ({ content: message })); + $(`#chat-button-${init_args.block_usage_key}`).on("click", { askTimTitle: init_args.ask_tim_drawer_title }, function (event) { const blockKey = $(this).data("block-key"); - window.parent.postMessage( { type: "smoot-design::chat-open", @@ -20,7 +18,6 @@ askTimTitle: event.data.askTimTitle, apiUrl: init_args.learn_ai_api_url, initialMessages: INITIAL_MESSAGES, - conversationStarters: starters, }, }, init_args.learning_mfe_base_url, // Ensure correct parent origin diff --git a/src/ol_openedx_chat/static/js/studio.js b/src/ol_openedx_chat/static/js/studio.js index b6df623f..22101816 100644 --- a/src/ol_openedx_chat/static/js/studio.js +++ b/src/ol_openedx_chat/static/js/studio.js @@ -10,16 +10,11 @@ chatForm.addEventListener("submit", function(event) { event.preventDefault(); var studioRuntime = new window.StudioRuntime.v1(); - - const chatPromptsField = element.querySelector("#chat-prompts"); - const askTIMTitleField = element.querySelector("#ask-tim-drawer-title"); - const llmModelDropdown = element.querySelector("#llm-model-dropdown"); - const additionalSolutionField = element.querySelector("#additional-solution"); const enabledCheck = element.querySelector("#is-enabled-"+chatForm.dataset.blockId); // Get the handler URL const handlerUrl = studioRuntime.handlerUrl(element, 'update_chat_config'); - var dataToPost = {"chat_prompts": chatPromptsField.value, "ask_tim_drawer_title": askTIMTitleField.value, "selected_llm_model": llmModelDropdown.value, "is_enabled": enabledCheck.checked, "additional_solution": additionalSolutionField.value}; + var dataToPost = {"is_enabled": enabledCheck.checked}; $.ajax({ url: handlerUrl,