Skip to content

Commit

Permalink
add chatId + pass Learning MFE URL
Browse files Browse the repository at this point in the history
  • Loading branch information
asadali145 committed Feb 20, 2025
1 parent 77ef5dc commit 935ded5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/ol_openedx_chat/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def student_view_aside(self, block, context=None):
"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,
"learning_mfe_base_url": settings.LEARNING_MICROFRONTEND_URL,
}

if getattr(block, "category", None) == "video":
Expand Down
4 changes: 3 additions & 1 deletion src/ol_openedx_chat/static/js/ai_chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
];
$(`#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 }));
const blockKey = $(this).data("block-key");

window.parent.postMessage(
{
type: "smoot-design::chat-open",
payload: {
chatId: blockKey,
askTimTitle: event.data.askTimTitle,
apiUrl: init_args.learn_ai_api_url,
initialMessages: INITIAL_MESSAGES,
conversationStarters: starters,
},
},
"http://apps.local.openedx.io:2000", // Ensure correct parent origin
init_args.learning_mfe_base_url, // Ensure correct parent origin
);
});
});
Expand Down

0 comments on commit 935ded5

Please sign in to comment.