Skip to content

Commit

Permalink
runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
lokeshk-18 committed Jul 23, 2023
1 parent 824dbb2 commit 8cd261b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions chatgptxblock/chatgptxblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ class ChatgptXBlock(StudioEditableXBlockMixin, XBlock):
# a_key = xblock_config.get('OPENAI_KEY')
# print(a_key)
# api_init(self)
a_key=''
def __init__(self, *args, **kwargs):
# Call the superclass' __init__ method first
super(ChatgptXBlock, self).__init__(*args, **kwargs)

# Accessing the configuration data from XBlock runtime
xblock_config = self.runtime.handler_env['xblock'].runtime.get_user_state('XBLOCK_CONFIG')
a_key = xblock_config.get('OPENAI_KEY')
print(a_key)
this.a_key = xblock_config.get('OPENAI_KEY')
print(this.a_key)
display_name = String(
display_name="Display Name",
help="Display name for this module",
Expand All @@ -51,7 +52,7 @@ def __init__(self, *args, **kwargs):
)

api_key = String(
default=a_key,
default=this.a_key,
scope=Scope.settings,
help="Your OpenAI API key, which can be found at <a href='https://platform.openai.com/account/api-keys' target='_blank'>https://platform.openai.com/account/api-keys</a>",
)
Expand Down

0 comments on commit 8cd261b

Please sign in to comment.