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 9e335bf commit 491b58e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion chatgptxblock/chatgptxblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import yaml
from xblock.core import XBlock
from xblock.fields import Integer, String, Scope
from xblock.runtime import DictKeyValueStore
from xblock.fragment import Fragment
from xblockutils.studio_editable import StudioEditableXBlockMixin
from .common import (get_xblock_settings)
Expand Down Expand Up @@ -98,7 +99,10 @@ def get_answer(self, data, suffix=''):

# Send the user's question to the text-davinci-002 model using the OpenAI API
model = "text-davinci-003"
openai.api_key = self.api_key
# openai.api_key = self.api_key
xblock_config = self.runtime.handler_env['xblock'].runtime.get_user_state('XBLOCK_CONFIG')
openai.api_key = xblock_config.get('OPENAI_KEY')
print(openai.api_key)
response = openai.Completion.create(
engine=model,
prompt=prompt,
Expand Down

0 comments on commit 491b58e

Please sign in to comment.