diff --git a/example/config_example.yaml b/example/config_example.yaml index db7a166..efbd1c3 100644 --- a/example/config_example.yaml +++ b/example/config_example.yaml @@ -16,15 +16,15 @@ ### API keys are required for OpenAI and GitHub integrations ### api_keys: - openai_api_key: '' - github_client_secret: '' + openai_api_key: '...' + github_client_secret: '...' ### Other application configurations ### application: - github_client_id: '' - github_callback_uri: 'http://localhost:3000/login/github_callback' + github_client_id: '...' + github_callback_uri: '...' rate_limit: max_requests_remaining: 5 # The maximum number of requests that a user can have at any given time rate_limit_interval_seconds: 180 # The time interval in seconds that the rate limit is enforced diff --git a/example/flask_example.py b/example/flask_example.py index f23fa42..2ffe46a 100644 --- a/example/flask_example.py +++ b/example/flask_example.py @@ -17,8 +17,14 @@ from maeser.chat.chat_logs import ChatLogsManager from maeser.chat.chat_session_manager import ChatSessionManager +from config_example import ( + LOG_SOURCE_PATH, OPENAI_API_KEY, VEC_STORE_PATH, CHAT_HISTORY_PATH +) +import os + +os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY -chat_logs_manager = ChatLogsManager("chat_logs") +chat_logs_manager = ChatLogsManager(CHAT_HISTORY_PATH) sessions_manager = ChatSessionManager(chat_logs_manager=chat_logs_manager) maeser_prompt: str = """You are speaking from the perspective of Karl G. Maeser. @@ -38,29 +44,34 @@ from maeser.graphs.simple_rag import get_simple_rag from langgraph.graph.graph import CompiledGraph -maeser_simple_rag: CompiledGraph = get_simple_rag(vectorstore_path="vectorstores/maeser", vectorstore_index="index", memory_filepath="chat_logs/maeser.db", system_prompt_text=maeser_prompt) +maeser_simple_rag: CompiledGraph = get_simple_rag(vectorstore_path=f"{VEC_STORE_PATH}/maeser", vectorstore_index="index", memory_filepath=f"{LOG_SOURCE_PATH}/maeser.db", system_prompt_text=maeser_prompt) sessions_manager.register_branch(branch_name="maeser", branch_label="Karl G. Maeser History", graph=maeser_simple_rag) -byu_simple_rag: CompiledGraph = get_simple_rag(vectorstore_path="vectorstores/byu", vectorstore_index="index", memory_filepath="chat_logs/byu.db", system_prompt_text=byu_prompt) +byu_simple_rag: CompiledGraph = get_simple_rag(vectorstore_path=f"{VEC_STORE_PATH}/byu", vectorstore_index="index", memory_filepath=f"{LOG_SOURCE_PATH}/byu.db", system_prompt_text=byu_prompt) sessions_manager.register_branch(branch_name="byu", branch_label="BYU History", graph=byu_simple_rag) from flask import Flask base_app = Flask(__name__) -from maeser.blueprints import add_flask_blueprint +from maeser.blueprints import App_Manager -app: Flask = add_flask_blueprint( - app=base_app, +app_manager = App_Manager( + app=base_app, + app_name="Maeser Test App -- NO USER MANAGER", flask_secret_key="secret", - chat_session_manager=sessions_manager, - app_name="Test App", - chat_head="/static/Karl_G_Maeser.png", - # Note that you can change other images too! We stick with the defaults for the logo and favicon. + chat_session_manager=sessions_manager, + user_manager=None, + chat_head="/static/Karl_G_Maeser.png" + # Note that you can change other aspects too! Heres some examples below # main_logo_login="/static/main_logo_login.png", # favicon="/static/favicon.png", + # login_text="Welcome to Maeser. This package is designed to facilitate the creation of Retrieval-Augmented Generation (RAG) chatbot applications, specifically tailored for educational purposes." + # primary_color="#f5f5f5" ) +app: Flask = app_manager.add_flask_blueprint() + if __name__ == "__main__": - extra_files = ["maeser/data/templates/chat_interface.html", "maeser/data/templates/login.html"] + extra_files = ["maeser/data/templates/chat_interface.html", "maeser/data/templates/login.html", "maeser/data/static/styles.css"] app.run(port=3002, debug=True, extra_files=extra_files) diff --git a/example/flask_example_user_mangement.py b/example/flask_example_user_mangement.py index 8f32e31..f24491a 100644 --- a/example/flask_example_user_mangement.py +++ b/example/flask_example_user_mangement.py @@ -55,7 +55,7 @@ from maeser.user_manager import UserManager, GithubAuthenticator, LDAPAuthenticator -# Replace the '...' with a client id and secret from a GitHub OAuth App that you generate +# Replace the '...' with a client id and secret from a GitHub OAuth App that you generate from config_example.yaml github_authenticator = GithubAuthenticator( client_id=GITHUB_CLIENT_ID, client_secret=GITHUB_CLIENT_SECRET,