diff --git a/penparse/config/asgi.py b/penparse/config/asgi.py index ca4a31a..4109e24 100644 --- a/penparse/config/asgi.py +++ b/penparse/config/asgi.py @@ -11,6 +11,6 @@ import os from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'penparse.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') application = get_asgi_application() diff --git a/penparse/config/celery.py b/penparse/config/celery.py index d1ec953..f04ad73 100644 --- a/penparse/config/celery.py +++ b/penparse/config/celery.py @@ -3,7 +3,7 @@ import os from celery import Celery # Set the default Django settings module for the 'celery' program. -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'penparse.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') app = Celery('penparse') diff --git a/penparse/config/settings.py b/penparse/config/settings.py index 2b9db62..9259a0c 100644 --- a/penparse/config/settings.py +++ b/penparse/config/settings.py @@ -68,7 +68,7 @@ REST_FRAMEWORK = { ] } -ROOT_URLCONF = "penparse.urls" +ROOT_URLCONF = "config.urls" TEMPLATES = [ { @@ -95,7 +95,7 @@ MARKDOWNIFY = { } } -WSGI_APPLICATION = "penparse.wsgi.application" +WSGI_APPLICATION = "config.wsgi.application" # Database diff --git a/penparse/config/wsgi.py b/penparse/config/wsgi.py index a40ab91..94ffd80 100644 --- a/penparse/config/wsgi.py +++ b/penparse/config/wsgi.py @@ -11,6 +11,6 @@ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'penparse.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') application = get_wsgi_application() diff --git a/penparse/penparse/tasks.py b/penparse/penparse/tasks.py index 6c86af7..a1d3340 100644 --- a/penparse/penparse/tasks.py +++ b/penparse/penparse/tasks.py @@ -67,27 +67,37 @@ def process_memo(memo_id: str): ], } - litellm.api_base = settings.OPENAI_API_BASE # os.environ.get("OPENAI_API_BASE") + # os.environ.get("OPENAI_API_BASE") + litellm.api_base = settings.OPENAI_API_BASE litellm.api_key = settings.OPENAI_API_KEY try: response = litellm.completion( - model=settings.OPENAI_MODEL, #os.getenv("MODEL", "openai/gpt-4o"), + # os.getenv("MODEL", "openai/gpt-4o"), + model=settings.OPENAI_MODEL, messages=[message], temperature=0.01 ) response.choices[0].message["content"] + logger.info(f"Got OCR output for memo {memo.id}") + with transaction.atomic(): memo.content = response.choices[0].message["content"] memo.status = MemoStatus.Done memo.model_name = settings.OPENAI_MODEL memo.save() + + logger.info(f"Saved OCR output for memo {memo.id} to db") + except openai.OpenAIError as e: + logger.error(f"Got error response from OCR API for memo {memo.id}") + logger.error(e) with transaction.atomic(): memo.status = MemoStatus.Error memo.error_message = e.__repr__() memo.save() - logger.error(e) + + logger.info(f"Saved error message for memo {memo.id} to db") diff --git a/pytest.ini b/pytest.ini index ed4898d..6456568 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,5 +1,5 @@ # -- FILE: pytest.ini (or tox.ini) [pytest] -DJANGO_SETTINGS_MODULE = penparse.test_settings +DJANGO_SETTINGS_MODULE = config.test_settings # -- recommended but optional: python_files = tests.py test/test_*.py *_tests.py