-
Notifications
You must be signed in to change notification settings - Fork 628
Expand file tree
/
Copy pathAdmin.py
More file actions
83 lines (63 loc) · 2.6 KB
/
Admin.py
File metadata and controls
83 lines (63 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
"""
This module contains the code for the Admin app of the Chat with your data Solution Accelerator.
"""
import os
import logging
import sys
import streamlit as st
from azure.monitor.opentelemetry import configure_azure_monitor
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
logging.captureWarnings(True)
# Logging configuration from environment variables
AZURE_BASIC_LOGGING_LEVEL = os.environ.get("LOGLEVEL", "INFO")
PACKAGE_LOGGING_LEVEL = os.environ.get("PACKAGE_LOGGING_LEVEL", "WARNING")
AZURE_LOGGING_PACKAGES = os.environ.get("AZURE_LOGGING_PACKAGES", "")
AZURE_LOGGING_PACKAGES = [pkg.strip() for pkg in AZURE_LOGGING_PACKAGES if pkg.strip()]
# Configure logging levels from environment variables
logging.basicConfig(
level=getattr(logging, AZURE_BASIC_LOGGING_LEVEL.upper(), logging.INFO)
)
# Configure Azure package logging levels
azure_package_log_level = getattr(
logging, PACKAGE_LOGGING_LEVEL.upper(), logging.WARNING
)
for logger_name in AZURE_LOGGING_PACKAGES:
logging.getLogger(logger_name).setLevel(azure_package_log_level)
# We cannot use EnvHelper here as Application Insights needs to be configured first
# for instrumentation to work correctly
if os.getenv("APPLICATIONINSIGHTS_ENABLED", "false").lower() == "true":
configure_azure_monitor()
# Suppress noisy Azure SDK loggers AFTER configure_azure_monitor()
# to prevent it from overriding our levels
_NOISY_AZURE_LOGGERS = [
"azure.core.pipeline.policies.http_logging_policy",
"azure.monitor.opentelemetry.exporter",
"azure.identity",
]
for logger_name in _NOISY_AZURE_LOGGERS:
logging.getLogger(logger_name).setLevel(logging.WARNING)
logger = logging.getLogger(__name__)
logger.debug("Starting admin app")
st.set_page_config(
page_title="Admin",
page_icon=os.path.join("images", "favicon.ico"),
layout="wide",
menu_items=None,
)
def load_css(file_path):
with open(file_path) as f:
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
# Load the common CSS
load_css("pages/common.css")
col1, col2, col3 = st.columns([1, 2, 1])
with col1:
st.image(os.path.join("images", "logo.png"))
st.write("# Chat with your data Solution Accelerator")
st.write(
"""
* If you want to ingest data (pdf, websites, etc.), then use the `Ingest Data` tab
* If you want to explore how your data was chunked, check the `Explore Data` tab
* If you want to delete your data, check the `Delete Data` tab
* If you want to adapt the underlying prompts, logging settings and others, use the `Configuration` tab
"""
)