Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 14, 2025
1 parent 3745128 commit 4b8af40
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
24 changes: 14 additions & 10 deletions src/ol_openedx_chat/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
from webob.response import Response
from xblock.core import XBlock, XBlockAside
from xblock.fields import Boolean, Scope, String
from xmodule.x_module import AUTHOR_VIEW, STUDENT_VIEW

from xmodule.video_block.transcripts_utils import get_transcript_from_contentstore
from xmodule.x_module import AUTHOR_VIEW, STUDENT_VIEW


def get_resource_bytes(path):
Expand Down Expand Up @@ -87,13 +86,19 @@ def student_view_aside(self, block, context=None):
fragment.add_content(
render_template(
"static/html/student_view.html",
{"block_key": self.scope_ids.usage_id.usage_key.block_id}
{"block_key": self.scope_ids.usage_id.usage_key.block_id},
)
)
fragment.add_css(get_resource_bytes("static/css/ai_chat.css"))
fragment.add_javascript(get_resource_bytes("static/js/ai_chat.js"))
fragment.add_javascript_url("https://unpkg.com/@mitodl/smoot-design@3.1.0/dist/bundles/aiChat.umd.js")
starters = [{"content": prompt} for prompt in self.chat_prompts.split(",")] if self.chat_prompts else []
fragment.add_javascript_url(
"https://unpkg.com/@mitodl/smoot-design@3.1.0/dist/bundles/aiChat.umd.js"
)
starters = (
[{"content": prompt} for prompt in self.chat_prompts.split(",")]
if self.chat_prompts
else []
)
extra_context = {
"starters": starters,
"block_usage_key": self.scope_ids.usage_id.usage_key.block_id,
Expand All @@ -102,16 +107,15 @@ def student_view_aside(self, block, context=None):

if getattr(block, "category", None) == "video":
try:
content, filename, mimetype = get_transcript_from_contentstore(block, 'en', 'txt', block.get_transcripts_info())
content, filename, mimetype = get_transcript_from_contentstore(
block, "en", "txt", block.get_transcripts_info()
)
except Exception:
content = ""

extra_context["video_transcript"] = content

fragment.initialize_js(
"AiChatAsideInit",
json_args=extra_context
)
fragment.initialize_js("AiChatAsideInit", json_args=extra_context)
return fragment

@XBlockAside.aside_for(AUTHOR_VIEW)
Expand Down
1 change: 0 additions & 1 deletion src/ol_openedx_chat/static/css/ai_chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@
align-items: center;
justify-content: center;
}

0 comments on commit 4b8af40

Please sign in to comment.