# For reading credentials from the .env file import os from dotenv import load_dotenv import streamlit as st import webchat # URL of the hosted LLMs is hardcoded because at this time all LLMs share the same endpoint url = "https://us-south.ml.cloud.ibm.com" # These global variables will be updated in get_credentials() function watsonx_project_id = "" # Replace with your IBM Cloud key api_key = "" def get_credentials(): load_dotenv() # Update the global variables that will be used for authentication in another function globals()["api_key"] = os.getenv("api_key", None) globals()["watsonx_project_id"] = os.getenv("project_id", None) def set_theme(): st.markdown(""" """, unsafe_allow_html=True) from urllib.parse import urlparse def create_collection_name(url): parsed_url = urlparse(url) domain_parts = parsed_url.netloc.split('.') if len(domain_parts) >= 2: return domain_parts[-2] # Extracting the second-level domain else: return "base" def main(): # Get the API key and project id and update global variables get_credentials() # Use the full page instead of a narrow central column st.set_page_config(layout="wide", page_title="RAG Web Demo", page_icon="") # Set the theme set_theme() # Streamlit app title with style st.markdown("""
Insert the website you want to chat with and ask your question.