datascientist22 commited on
Commit
0b99432
·
verified ·
1 Parent(s): 4741c15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -34,8 +34,6 @@ if url_input:
34
  st.sidebar.markdown('<p style="color:green; font-weight:bold;">URL is correctly entered</p>', unsafe_allow_html=True)
35
  else:
36
  st.sidebar.markdown('<p style="color:red; font-weight:bold;">Invalid URL, please enter a valid one</p>', unsafe_allow_html=True)
37
- else:
38
- st.sidebar.markdown('<p style="color:red; font-weight:bold;">URL is required</p>', unsafe_allow_html=True)
39
 
40
  # Input fields for API keys with placeholders and helper text
41
  api_key_1 = st.sidebar.text_input("Enter LangChain API Key", type="password", placeholder="Enter your LangChain API Key", help="Please enter a valid LangChain API key here")
@@ -50,15 +48,15 @@ if st.sidebar.button("Submit API Keys"):
50
  else:
51
  st.sidebar.markdown('<p style="color:red; font-weight:bold;">Please fill in both API keys</p>', unsafe_allow_html=True)
52
 
53
- # Main Section with Multicolored Background
54
  main_bg_style = """
55
  <style>
56
  body {
57
  background: linear-gradient(135deg, #ff9a9e, #fad0c4, #fbc2eb, #a18cd1);
58
- color: #333; /* Ensures text visibility */
59
  }
60
- .stTextInput input {
61
- color: #333; /* Ensures text color in inputs */
62
  }
63
  </style>
64
  """
@@ -74,9 +72,11 @@ query = st.text_input("Ask a question based on the blog post", placeholder="Type
74
  if 'chat_history' not in st.session_state:
75
  st.session_state['chat_history'] = []
76
 
77
- # Submit button for chat
78
  if st.button("Submit Query"):
79
- if query and url_input:
 
 
80
  # Blog loading logic based on user input URL
81
  loader = WebBaseLoader(
82
  web_paths=(url_input,), # Use the user-input URL
@@ -131,8 +131,6 @@ if st.button("Submit Query"):
131
 
132
  # Store query and response in session for chat history
133
  st.session_state['chat_history'].append((query, result))
134
- else:
135
- st.warning("Both URL and query are required")
136
 
137
  # Display chat history
138
  for q, r in st.session_state['chat_history']:
 
34
  st.sidebar.markdown('<p style="color:green; font-weight:bold;">URL is correctly entered</p>', unsafe_allow_html=True)
35
  else:
36
  st.sidebar.markdown('<p style="color:red; font-weight:bold;">Invalid URL, please enter a valid one</p>', unsafe_allow_html=True)
 
 
37
 
38
  # Input fields for API keys with placeholders and helper text
39
  api_key_1 = st.sidebar.text_input("Enter LangChain API Key", type="password", placeholder="Enter your LangChain API Key", help="Please enter a valid LangChain API key here")
 
48
  else:
49
  st.sidebar.markdown('<p style="color:red; font-weight:bold;">Please fill in both API keys</p>', unsafe_allow_html=True)
50
 
51
+ # Main Section with Multicolored Background and Chatbot Title
52
  main_bg_style = """
53
  <style>
54
  body {
55
  background: linear-gradient(135deg, #ff9a9e, #fad0c4, #fbc2eb, #a18cd1);
56
+ color: #333; /* Ensure text is visible against the background */
57
  }
58
+ .stTextInput>div>div>input {
59
+ border: 1px solid #ccc; /* Style input borders */
60
  }
61
  </style>
62
  """
 
72
  if 'chat_history' not in st.session_state:
73
  st.session_state['chat_history'] = []
74
 
75
+ # Warning message for empty query
76
  if st.button("Submit Query"):
77
+ if not query:
78
+ st.markdown('<p style="color:red; font-weight:bold;">Please enter a question before submitting.</p>', unsafe_allow_html=True)
79
+ elif url_input:
80
  # Blog loading logic based on user input URL
81
  loader = WebBaseLoader(
82
  web_paths=(url_input,), # Use the user-input URL
 
131
 
132
  # Store query and response in session for chat history
133
  st.session_state['chat_history'].append((query, result))
 
 
134
 
135
  # Display chat history
136
  for q, r in st.session_state['chat_history']: