further refactor fixes
Run Tests / Run Tests (push) Successful in 46s
Details
Run Tests / Run Tests (push) Successful in 46s
Details
This commit is contained in:
parent
c82cb00013
commit
d323754153
|
@ -11,6 +11,6 @@ import os
|
||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
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()
|
application = get_asgi_application()
|
||||||
|
|
|
@ -3,7 +3,7 @@ import os
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
|
|
||||||
# Set the default Django settings module for the 'celery' program.
|
# 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')
|
app = Celery('penparse')
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ REST_FRAMEWORK = {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
ROOT_URLCONF = "penparse.urls"
|
ROOT_URLCONF = "config.urls"
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ MARKDOWNIFY = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WSGI_APPLICATION = "penparse.wsgi.application"
|
WSGI_APPLICATION = "config.wsgi.application"
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
|
|
|
@ -11,6 +11,6 @@ import os
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
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()
|
application = get_wsgi_application()
|
||||||
|
|
|
@ -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
|
litellm.api_key = settings.OPENAI_API_KEY
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = litellm.completion(
|
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],
|
messages=[message],
|
||||||
temperature=0.01
|
temperature=0.01
|
||||||
)
|
)
|
||||||
|
|
||||||
response.choices[0].message["content"]
|
response.choices[0].message["content"]
|
||||||
|
|
||||||
|
logger.info(f"Got OCR output for memo {memo.id}")
|
||||||
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
memo.content = response.choices[0].message["content"]
|
memo.content = response.choices[0].message["content"]
|
||||||
memo.status = MemoStatus.Done
|
memo.status = MemoStatus.Done
|
||||||
memo.model_name = settings.OPENAI_MODEL
|
memo.model_name = settings.OPENAI_MODEL
|
||||||
memo.save()
|
memo.save()
|
||||||
|
|
||||||
|
logger.info(f"Saved OCR output for memo {memo.id} to db")
|
||||||
|
|
||||||
except openai.OpenAIError as e:
|
except openai.OpenAIError as e:
|
||||||
|
|
||||||
|
logger.error(f"Got error response from OCR API for memo {memo.id}")
|
||||||
|
logger.error(e)
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
memo.status = MemoStatus.Error
|
memo.status = MemoStatus.Error
|
||||||
memo.error_message = e.__repr__()
|
memo.error_message = e.__repr__()
|
||||||
memo.save()
|
memo.save()
|
||||||
logger.error(e)
|
|
||||||
|
logger.info(f"Saved error message for memo {memo.id} to db")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# -- FILE: pytest.ini (or tox.ini)
|
# -- FILE: pytest.ini (or tox.ini)
|
||||||
[pytest]
|
[pytest]
|
||||||
DJANGO_SETTINGS_MODULE = penparse.test_settings
|
DJANGO_SETTINGS_MODULE = config.test_settings
|
||||||
# -- recommended but optional:
|
# -- recommended but optional:
|
||||||
python_files = tests.py test/test_*.py *_tests.py
|
python_files = tests.py test/test_*.py *_tests.py
|
||||||
|
|
Loading…
Reference in New Issue