Skip to content

Commit

Permalink
fix: Fix documentation builds
Browse files Browse the repository at this point in the history
Resolve import and setup issues that were causing doc builds to fail.
  • Loading branch information
jmbowman committed Oct 24, 2023
1 parent 41fd211 commit de1cc69
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
8 changes: 8 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ def get_version(*file_paths):

VERSION = get_version('../flashcards', '__init__.py')

# Specify settings module (which will be picked up from the sandbox)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'flashcards.settings.test')

import django


django.setup()

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down
3 changes: 3 additions & 0 deletions flashcards/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,6 @@ def root(*path_fragments):

# Set up logging for development use (logging to stdout)
LOGGING = get_logger_config(debug=DEBUG)

# OpenAI API key, to be specified in the private settings file
OPENAI_API_KEY = ''
36 changes: 17 additions & 19 deletions flashcards/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
"""

import openai
from django.conf import settings

Check warning on line 9 in flashcards/utils.py

View check run for this annotation

Codecov / codecov/patch

flashcards/utils.py#L9

Added line #L9 was not covered by tests

from flashcards.settings.private import OPENAI_API_KEY # pylint: disable=import-error,no-name-in-module

openai.api_key = OPENAI_API_KEY
openai.api_key = settings.OPENAI_API_KEY

Check warning on line 11 in flashcards/utils.py

View check run for this annotation

Codecov / codecov/patch

flashcards/utils.py#L11

Added line #L11 was not covered by tests


content_prompt = """
Expand Down Expand Up @@ -181,19 +180,18 @@
"content": content_prompt + course_content},
]


c3 = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=messages,
temperature=1.0,
)

print(c3['choices'][0]['message']['content'])

# c4 = openai.ChatCompletion.create(
# model="gpt-4",
# messages=messages,
# temperature=1.0,
# )

# print(c4)
if openai.api_key:
c3 = openai.ChatCompletion.create(

Check warning on line 184 in flashcards/utils.py

View check run for this annotation

Codecov / codecov/patch

flashcards/utils.py#L184

Added line #L184 was not covered by tests
model="gpt-3.5-turbo",
messages=messages,
temperature=1.0,
)
print(c3['choices'][0]['message']['content'])

Check warning on line 189 in flashcards/utils.py

View check run for this annotation

Codecov / codecov/patch

flashcards/utils.py#L189

Added line #L189 was not covered by tests

# c4 = openai.ChatCompletion.create(
# model="gpt-4",
# messages=messages,
# temperature=1.0,
# )

# print(c4)

0 comments on commit de1cc69

Please sign in to comment.