Skip to content

Commit

Permalink
Asides with React component
Browse files Browse the repository at this point in the history
  • Loading branch information
asadali145 committed Dec 20, 2024
1 parent 9190d9c commit 515f871
Show file tree
Hide file tree
Showing 9 changed files with 2,084 additions and 121 deletions.
21 changes: 1 addition & 20 deletions src/ol_openedx_chat/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,9 @@ def student_view_aside(self, block, context=None): # noqa: ARG002
Renders the aside contents for the student view
""" # noqa: D401
fragment = Fragment("")
if getattr(block, "category", None) == "video":
content, filename, mimetype = get_transcript_from_contentstore(block, 'en', 'txt', block.get_transcripts_info())
prompt = (
"Summarize the following video transcript into a concise, informative summary:\n\n"
f"{content}"
)
response = openai.ChatCompletion.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are an expert at summarizing content."},
{"role": "user", "content": prompt},
],
max_tokens=200,
temperature=0.5,
)
print("\n\n\n", response["choices"][0]["message"]["content"], "\n\n\n")
return fragment

fragment.add_content(render_template("static/html/student_view.html", {"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.initialize_js("AiChatAsideView")
fragment.initialize_js('initReactXBlock8StudentView')
return fragment

@XBlock.handler
Expand Down
Loading

0 comments on commit 515f871

Please sign in to comment.