KajetanNiewczas commited on
Commit
693a7d3
·
1 Parent(s): 9e631e2

Fixing f-strings in logs

Browse files
ragntex.py CHANGED
@@ -19,15 +19,14 @@ from src import (
19
  prompt,
20
  CompilePresentation,
21
  client,
22
- demo,
23
  Logger,
24
  )
25
 
26
  LOGGER = Logger.get_logger()
27
 
28
- demo.launch()
29
  load_dotenv()
30
- load_dotenv("../.env")
31
  MAIN_DIR = os.getenv("MAIN_DIR")
32
 
33
  # Get all the existing papers in the database
@@ -59,7 +58,7 @@ if documents:
59
  # Prompting
60
  LOGGER.info("Retrieving relevant documents...")
61
  embed_fn.document_mode = False
62
- query = "I need a presentation about AI agents."
63
  query_oneline = query.replace(
64
  "\n", " "
65
  ) # (Optional) For cleaner input in case of newlines
@@ -76,24 +75,24 @@ for passage, metas in zip(documents, metadatas):
76
  prompt += f"IMAGES: {images_passage}\n"
77
 
78
  # Create a new subfolder
79
- LOGGER.info("💾Creating new subfolder...")
80
  base_path = MAIN_DIR + "output/"
81
  timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
82
  work_dir = os.path.join(base_path, timestamp)
83
  os.makedirs(work_dir, exist_ok=False)
84
- LOGGER.info(f"📁 Created folder: {work_dir}")
85
 
86
  # Generate the presentation code
87
  model_name = "gemini-2.0-flash"
88
  # model_name = "gemini-2.5-flash-preview-04-17"
89
- LOGGER.info("⭐️Generating response...")
90
  answer = client.models.generate_content(model=model_name, contents=prompt)
91
- LOGGER.info(f"🎲 Generated the response using: {model_name}")
92
 
93
  # Create a subfolder for graphics
94
  graphics_dir = os.path.join(work_dir, "gfx")
95
  os.makedirs(graphics_dir, exist_ok=True)
96
- LOGGER.info(f"🌄 Images will be saved to: {graphics_dir}")
97
 
98
  # Find images, which are used in the presentation
99
  pattern_img = re.compile(
 
19
  prompt,
20
  CompilePresentation,
21
  client,
22
+ # demo,
23
  Logger,
24
  )
25
 
26
  LOGGER = Logger.get_logger()
27
 
28
+ # demo.launch()
29
  load_dotenv()
 
30
  MAIN_DIR = os.getenv("MAIN_DIR")
31
 
32
  # Get all the existing papers in the database
 
58
  # Prompting
59
  LOGGER.info("Retrieving relevant documents...")
60
  embed_fn.document_mode = False
61
+ query = "I need an interesting presentation."
62
  query_oneline = query.replace(
63
  "\n", " "
64
  ) # (Optional) For cleaner input in case of newlines
 
75
  prompt += f"IMAGES: {images_passage}\n"
76
 
77
  # Create a new subfolder
78
+ LOGGER.info("💾 Creating new subfolder...")
79
  base_path = MAIN_DIR + "output/"
80
  timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
81
  work_dir = os.path.join(base_path, timestamp)
82
  os.makedirs(work_dir, exist_ok=False)
83
+ LOGGER.info("📁 Created folder: %s", work_dir)
84
 
85
  # Generate the presentation code
86
  model_name = "gemini-2.0-flash"
87
  # model_name = "gemini-2.5-flash-preview-04-17"
88
+ LOGGER.info("⭐️ Generating response...")
89
  answer = client.models.generate_content(model=model_name, contents=prompt)
90
+ LOGGER.info("🎲 Generated the response using: %s", model_name)
91
 
92
  # Create a subfolder for graphics
93
  graphics_dir = os.path.join(work_dir, "gfx")
94
  os.makedirs(graphics_dir, exist_ok=True)
95
+ LOGGER.info("🌄 Images will be saved to: %s", graphics_dir)
96
 
97
  # Find images, which are used in the presentation
98
  pattern_img = re.compile(
src/__init__.py CHANGED
@@ -3,7 +3,7 @@ from .processing import process_documents, save_pdf_images, save_pdf_figures, pr
3
  from .compilation import CompilePresentation
4
  from .services import client
5
  from .utils import upload_files, Logger
6
- from .interface import demo
7
 
8
  __all__ = [
9
  "db",
@@ -16,5 +16,5 @@ __all__ = [
16
  "client",
17
  "upload_files",
18
  "Logger",
19
- "demo",
20
  ]
 
3
  from .compilation import CompilePresentation
4
  from .services import client
5
  from .utils import upload_files, Logger
6
+ # from .interface import demo
7
 
8
  __all__ = [
9
  "db",
 
16
  "client",
17
  "upload_files",
18
  "Logger",
19
+ # "demo",
20
  ]
src/compilation/latex_compilation.py CHANGED
@@ -1,6 +1,6 @@
1
  import os
2
  import subprocess
3
- from ..logging_utils import Logger
4
 
5
  LOGGER = Logger.get_logger()
6
 
@@ -44,11 +44,10 @@ def CompilePresentation(latex_code, work_dir):
44
 
45
  except subprocess.CalledProcessError as e:
46
  # Handle error in case of failed LaTeX compilation
47
- LOGGER.info("❌ PDF generation failed. Here's the log:")
48
- LOGGER.info(e.stderr.decode())
49
  else:
50
  # Check for PDF output
51
  if not os.path.exists("presentation.pdf"):
52
- LOGGER.info("❌ PDF generation failed. No PDF file found.")
53
  else:
54
- LOGGER.info(f"💾 PDF generated successfully in: {work_dir}")
 
1
  import os
2
  import subprocess
3
+ from ..utils import Logger
4
 
5
  LOGGER = Logger.get_logger()
6
 
 
44
 
45
  except subprocess.CalledProcessError as e:
46
  # Handle error in case of failed LaTeX compilation
47
+ LOGGER.error("❌ PDF generation failed. Here's the log: %s", e.stderr.decode())
 
48
  else:
49
  # Check for PDF output
50
  if not os.path.exists("presentation.pdf"):
51
+ LOGGER.error("❌ PDF generation failed. No PDF file found.")
52
  else:
53
+ LOGGER.info("💾 PDF generated successfully in: %s", work_dir)
src/services/google_client.py CHANGED
@@ -3,6 +3,5 @@ from google import genai
3
  from dotenv import load_dotenv
4
 
5
  load_dotenv()
6
- load_dotenv("../.env")
7
  GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
8
  client = genai.Client(api_key=GOOGLE_API_KEY)
 
3
  from dotenv import load_dotenv
4
 
5
  load_dotenv()
 
6
  GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
7
  client = genai.Client(api_key=GOOGLE_API_KEY)
src/utils/__init__.py CHANGED
@@ -1,3 +1,4 @@
1
  from .upload_files import upload_files
 
2
 
3
- __all__ = ["upload_files"]
 
1
  from .upload_files import upload_files
2
+ from .logging_utils import Logger
3
 
4
+ __all__ = ["upload_files", "Logger"]
src/utils/upload_files.py CHANGED
@@ -17,7 +17,7 @@ def upload_files(files):
17
  # Temporary path where Gradio stores the file
18
  temp_path = file.name
19
  file_name = Path(file.name).name
20
- LOGGER.info(f"Uploading file: {file_name}")
21
 
22
  # Define where you want to save the file
23
  filepath = UPLOAD_DIR / file_name
 
17
  # Temporary path where Gradio stores the file
18
  temp_path = file.name
19
  file_name = Path(file.name).name
20
+ LOGGER.info("Uploading file: %s", file_name)
21
 
22
  # Define where you want to save the file
23
  filepath = UPLOAD_DIR / file_name