diff --git a/docker-compose.yml b/docker-compose.yml index e55e887..f447c49 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: vllm: image: vllm/vllm-openai:latest - command: "--model Qwen/Qwen2-VL-2B-Instruct" + command: "--model Qwen/Qwen2-VL-2B-Instruct-GPTQ-Int4 --quantization gptq" volumes: - ~/.cache/huggingface:/root/.cache/huggingface ports: @@ -21,4 +21,4 @@ services: devices: - driver: nvidia device_ids: ["0"] - capabilities: [gpu] \ No newline at end of file + capabilities: [gpu] diff --git a/penparse/penparse/settings.py b/penparse/penparse/settings.py index 3f1882c..8c92da9 100644 --- a/penparse/penparse/settings.py +++ b/penparse/penparse/settings.py @@ -149,5 +149,6 @@ CELERY_BROKER_URL = "amqp://guest:guest@localhost/" OPENAI_API_BASE = os.getenv("OPENAI_API_BASE") -OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") +#OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") +OPENAI_API_KEY = "test" OPENAI_MODEL = os.getenv("OPENAI_MODEL", "openai/gpt-4o") diff --git a/penparse/webui/tasks.py b/penparse/webui/tasks.py index 0c39599..616e9d1 100644 --- a/penparse/webui/tasks.py +++ b/penparse/webui/tasks.py @@ -1,26 +1,26 @@ -import requests import base64 import litellm -import os from loguru import logger -from celery import shared_task, Task +from celery import shared_task from django.db import transaction from django.core.files.storage import default_storage from django.conf import settings from .models import ImageMemo, MemoStatus -from datetime import datetime -TRANSCRIBE_PROMPT = """Transcribe the hand written notes in the attached image and present them as markdown. +TRANSCRIBE_PROMPT = """Transcribe the hand written notes in the attached image and present them as markdown. Do not use a fence, simply respond using markdown. -If any words or letters are unclear, denote them with a '??'. +If any words or letters are unclear, denote them with a '??'. For example if you were not sure whether a word is blow or blew you would transcribe it as '?blow?' + +Please include whitespace and formatting for headings too. """ + @shared_task def process_memo(memo_id: str): """Run OCR on a memo and store the output""" @@ -67,6 +67,7 @@ def process_memo(memo_id: str): response = litellm.completion( model=settings.OPENAI_MODEL, #os.getenv("MODEL", "openai/gpt-4o"), messages=[message], + temperature=0.01 ) response.choices[0].message["content"] diff --git a/penparse/webui/templates/dashboard.html b/penparse/webui/templates/dashboard.html index 08ad24d..b6734f4 100644 --- a/penparse/webui/templates/dashboard.html +++ b/penparse/webui/templates/dashboard.html @@ -36,11 +36,11 @@ Created: - {{ document.created_at|date:"d/m/Y H:i" }} + {{ document.created_at|date:"d/m/Y H:i:s" }} Updated: - {{ document.updated_at|date:"d/m/Y H:i" }} + {{ document.updated_at|date:"d/m/Y H:i:s" }} {% if document.content %} diff --git a/uv.lock b/uv.lock index 5077633..840974a 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,10 @@ version = 1 requires-python = ">=3.9" +resolution-markers = [ + "python_full_version < '3.11'", + "python_full_version == '3.11.*'", + "python_full_version >= '3.12'", +] [[package]] name = "aiohappyeyeballs"