Skip to content

Commit c784366

Browse files
committed
dev instructions and fixes
1 parent c0df224 commit c784366

File tree

9 files changed

+31
-60
lines changed

9 files changed

+31
-60
lines changed

DEVELOPMENT_INSTRUCTIONS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- Never forget to update the conda environment config file when you update the requirements.txt
2+
- Make sure there are concise and up to date docstrings that document usage.
3+
- Debug information belongs into the command line logs, not in the app UI/UX.
4+
-

app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
import pdfplumber
88
import io
99
from ragnarok import EnhancedPDFProcessor
10+
from loguru import logger
11+
12+
# Configure loguru logging - simple console logging with defaults
13+
# loguru automatically logs to console by default, no configuration needed
1014

1115
# Check if we're running in Docker
1216
def is_running_in_docker():

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ dependencies:
1616
- ollama
1717
- streamlit-pdf-viewer
1818
- PyMuPDF
19+
- loguru
1920
- -e .

ragnarok.egg-info/PKG-INFO

Lines changed: 0 additions & 17 deletions
This file was deleted.

ragnarok.egg-info/SOURCES.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

ragnarok.egg-info/dependency_links.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

ragnarok.egg-info/top_level.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

ragnarok/enhanced_pdf_processor.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import streamlit as st
66
import fitz # PyMuPDF
77
import re
8+
from loguru import logger
89
from typing import List, Tuple, Dict, Optional
910

1011

@@ -96,29 +97,26 @@ def display_citation_based_references(
9697
# Extract quotes from AI response
9798
citation_quotes = self._extract_quotes_from_ai_response(ai_response)
9899

99-
# Debug information
100+
# Log debug information instead of showing in UI
100101
if not citation_quotes:
101-
# Show what we're looking for vs what we found
102-
st.caption("🔍 Debug: Citation extraction details")
103-
with st.expander("Debug Citation Parsing", expanded=False):
104-
st.text("AI Response:")
105-
st.code(ai_response[:500] + "..." if len(ai_response) > 500 else ai_response)
106-
107-
# Show what patterns we tried
108-
patterns = [
109-
(r'^\[(\d+)\]\s*"([^"]+)"', "Pattern 1: [1] \"quote\""),
110-
(r'^\[(\d+)\]:\s*"([^"]+)"', "Pattern 2: [1]: \"quote\""),
111-
(r'\[Exact quote:\s*"([^"]+)"\]', "Pattern 3: [Exact quote: \"text\"]"),
112-
(r'\["([^"]+)"\]', "Pattern 3b: [\"text\"]"),
113-
(r'"([^"]{20,})"', "Pattern 4: Any quotes 20+ chars")
114-
]
115-
116-
for pattern, description in patterns:
117-
matches = re.findall(pattern, ai_response, re.MULTILINE | re.IGNORECASE)
118-
st.text(f"{description}: {len(matches)} matches")
119-
if matches:
120-
for i, match in enumerate(matches[:3]): # Show first 3
121-
st.text(f" Match {i+1}: {str(match)[:100]}...")
102+
logger.debug("No citations found, attempting pattern matching")
103+
logger.debug(f"AI Response (first 500 chars): {ai_response[:500]}")
104+
105+
# Log what patterns we tried
106+
patterns = [
107+
(r'^\[(\d+)\]\s*"([^"]+)"', "Pattern 1: [1] \"quote\""),
108+
(r'^\[(\d+)\]:\s*"([^"]+)"', "Pattern 2: [1]: \"quote\""),
109+
(r'\[Exact quote:\s*"([^"]+)"\]', "Pattern 3: [Exact quote: \"text\"]"),
110+
(r'\["([^"]+)"\]', "Pattern 3b: [\"text\"]"),
111+
(r'"([^"]{20,})"', "Pattern 4: Any quotes 20+ chars")
112+
]
113+
114+
for pattern, description in patterns:
115+
matches = re.findall(pattern, ai_response, re.MULTILINE | re.IGNORECASE)
116+
logger.debug(f"{description}: {len(matches)} matches")
117+
if matches:
118+
for i, match in enumerate(matches[:3]): # Log first 3
119+
logger.debug(f" Match {i+1}: {str(match)[:100]}...")
122120

123121
if citation_quotes:
124122
all_quotes = list(citation_quotes.values())

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ pdfplumber
66
PyMuPDF
77
pytest
88
pytest-cov
9-
pillow
9+
pillow
10+
loguru

0 commit comments

Comments
 (0)