derek-thomas HF staff commited on
Commit
5b6661f
1 Parent(s): e446639

Add logging

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  from time import perf_counter
2
 
3
  import gradio as gr
@@ -5,13 +7,14 @@ from jinja2 import Environment, FileSystemLoader
5
 
6
  from backend.query_llm import generate
7
  from backend.semantic_search import qd_retriever
8
- from pathlib import Path
9
 
10
  proj_dir = Path(__file__).parent
11
-
 
 
12
 
13
  # Set up the template environment with the templates directory
14
- env = Environment(loader=FileSystemLoader(proj_dir/'templates'))
15
 
16
  # Load the templates directly from the environment
17
  template = env.get_template('template.j2')
@@ -36,6 +39,7 @@ def bot(history, system_prompt=""):
36
  # Create Prompt
37
  prompt = template.render(documents=documents, query=query)
38
  prompt_html = template_html.render(documents=documents, query=query)
 
39
 
40
  history[-1][1] = ""
41
  for character in generate(prompt, history[:-1]):
@@ -48,7 +52,8 @@ with gr.Blocks() as demo:
48
  chatbot = gr.Chatbot(
49
  [],
50
  elem_id="chatbot",
51
- avatar_images=('https://aui.atlassian.com/aui/8.8/docs/images/avatar-person.svg', 'https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.svg'),
 
52
  bubble_full_width=False,
53
  show_copy_button=True,
54
  show_share_button=True,
 
1
+ import logging
2
+ from pathlib import Path
3
  from time import perf_counter
4
 
5
  import gradio as gr
 
7
 
8
  from backend.query_llm import generate
9
  from backend.semantic_search import qd_retriever
 
10
 
11
  proj_dir = Path(__file__).parent
12
+ # Setting up the logging
13
+ logging.basicConfig(level=logging.INFO)
14
+ logger = logging.getLogger(__name__)
15
 
16
  # Set up the template environment with the templates directory
17
+ env = Environment(loader=FileSystemLoader(proj_dir / 'templates'))
18
 
19
  # Load the templates directly from the environment
20
  template = env.get_template('template.j2')
 
39
  # Create Prompt
40
  prompt = template.render(documents=documents, query=query)
41
  prompt_html = template_html.render(documents=documents, query=query)
42
+ logger.warning(prompt)
43
 
44
  history[-1][1] = ""
45
  for character in generate(prompt, history[:-1]):
 
52
  chatbot = gr.Chatbot(
53
  [],
54
  elem_id="chatbot",
55
+ avatar_images=('https://aui.atlassian.com/aui/8.8/docs/images/avatar-person.svg',
56
+ 'https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.svg'),
57
  bubble_full_width=False,
58
  show_copy_button=True,
59
  show_share_button=True,