acecalisto3 commited on
Commit
85262de
·
verified ·
1 Parent(s): c33b7ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -22,8 +22,23 @@ from agent import (
22
  from utils import parse_action, parse_file_content, read_python_module_structure
23
  from datetime import datetime
24
  import yaml
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
- logger = gr.Logger(os.path.join("logs", "gradio_log.txt"), mode='a+', append_empty_lines=True)
 
27
 
28
  # Load custom prompts
29
  try:
@@ -483,6 +498,6 @@ with iface:
483
 
484
  iface.load(fn=get_helpful_tip, inputs=agent_dropdown, outputs=ui.info)
485
  iface.load(fn=update_sys_prompt, inputs=agent_dropdown, outputs=sys_prompt)
486
- iface.load(fn=log_messages, input_type='state', event_type='save_model')
487
-
488
  iface.launch()
 
22
  from utils import parse_action, parse_file_content, read_python_module_structure
23
  from datetime import datetime
24
  import yaml
25
+ import logging
26
+
27
+ # Create a directory for logs if it doesn't exist
28
+ log_dir = "logs"
29
+ if not os.path.exists(log_dir):
30
+ os.makedirs(log_dir)
31
+
32
+ # Configure logging
33
+ logging.basicConfig(
34
+ filename=os.path.join(log_dir, "gradio_log.txt"),
35
+ level=logging.INFO,
36
+ format="%(asctime)s [%(levelname)s] %(message)s",
37
+ filemode="a+",
38
+ )
39
 
40
+ # Use the logger
41
+ logger = logging.getLogger(__name__)
42
 
43
  # Load custom prompts
44
  try:
 
498
 
499
  iface.load(fn=get_helpful_tip, inputs=agent_dropdown, outputs=ui.info)
500
  iface.load(fn=update_sys_prompt, inputs=agent_dropdown, outputs=sys_prompt)
501
+ # Log messages
502
+ logger.info("Application started")
503
  iface.launch()