Skip to content

Commit

Permalink
Initial load (#4)
Browse files Browse the repository at this point in the history
* Doco and Repository Name configuration
  • Loading branch information
gotsysdba authored Sep 12, 2024
1 parent 4215972 commit 49d229c
Show file tree
Hide file tree
Showing 23 changed files with 333 additions and 209 deletions.
28 changes: 13 additions & 15 deletions app/src/content/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,24 @@ def main():
st_common.initialise_rag()
# Setup History
chat_history = StreamlitChatMessageHistory(key="sandbox_chat_history")
with st.chat_message("ai"):
# Do not put this in the history as messages must alternate human/ai
st.write("Hello, how can I help you?")

#########################################################################
# Sidebar Settings
#########################################################################
# Chat History
enable_history = st.sidebar.checkbox(
"Enable History and Context?",
value=True,
key="user_chat_history",
)
if st.sidebar.button("Clear History", disabled=not enable_history):
chat_history.clear()

# Language Model
try:
enabled_llms = sum(model_info["enabled"] for model_info in state.lm_model_config.values())
if enabled_llms > 0:
with st.chat_message("ai"):
# Do not put this in the history as messages must alternate human/ai
st.write("Hello, how can I help you?")
enable_history = st.sidebar.checkbox(
"Enable History and Context?",
value=True,
key="user_chat_history",
)
if st.sidebar.button("Clear History", disabled=not enable_history):
chat_history.clear()
lm_model = st_common.lm_sidebar()
except ValueError:
else:
st.error("No chat models are configured and/or enabled.", icon="🚨",)
st.stop()

Expand Down
98 changes: 49 additions & 49 deletions app/src/content/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,106 +76,106 @@ def update_lm_model_config():
def main():
"""Streamlit GUI"""
initialise_streamlit()
st.header("Embedding Models")

with st.form("update_embed_model_config"):

st.header("Language Models")
with st.form("update_lm_model_config"):
# Create table header
table1_col_format = st.columns([0.08, 0.3, 0.2, 0.2, 0.2])
col1_1, col2_1, col3_1, col4_1, col5_1 = table1_col_format
col1_1.markdown("**<u>Enabled</u>**", unsafe_allow_html=True)
col2_1.markdown("**<u>Model Name</u>**", unsafe_allow_html=True)
col3_1.markdown("**<u>API</u>**", unsafe_allow_html=True)
col4_1.markdown("**<u>API Server</u>**", unsafe_allow_html=True)
col5_1.markdown("**<u>API Key</u>**", unsafe_allow_html=True)
table2_col_format = st.columns([0.08, 0.3, 0.2, 0.2, 0.2])
col1_2, col2_2, col3_2, col4_2, col5_2 = table2_col_format
col1_2.markdown("**<u>Enabled</u>**", unsafe_allow_html=True)
col2_2.markdown("**<u>Model Name</u>**", unsafe_allow_html=True)
col3_2.markdown("**<u>API</u>**", unsafe_allow_html=True)
col4_2.markdown("**<u>API Server</u>**", unsafe_allow_html=True)
col5_2.markdown("**<u>API Key</u>**", unsafe_allow_html=True)

# Create table rows
for model_name, config in state.embed_model_config.items():
col1_1, col2_1, col3_1, col4_1, col5_1 = table1_col_format
col1_1.checkbox(
for model_name, config in state.lm_model_config.items():
col1_2, col2_2, col3_2, col4_2, col5_2 = table2_col_format
col1_2.checkbox(
"Enabled",
value=config["enabled"],
label_visibility="collapsed",
key=f"embed_{model_name}_enabled",
disabled=False,
key=f"lm_{model_name}_enabled",
disabled=False,
)
col2_1.text_input(
col2_2.text_input(
"Model",
value=model_name,
label_visibility="collapsed",
key=f"embed_{model_name}",
key=f"lm_{model_name}",
disabled=True,
)
col3_1.text_input(
col3_2.text_input(
"API",
value=get_class_name(config["api"]),
value=config["api"],
label_visibility="collapsed",
key=f"embed_{model_name}_api",
key=f"lm_{model_name}_api",
disabled=True,
)
col4_1.text_input(
col4_2.text_input(
"Server",
value=config["url"],
key=f"embed_{model_name}_api_server",
key=f"lm_{model_name}_api_server",
label_visibility="collapsed",
)
col5_1.text_input(
col5_2.text_input(
"Key",
value=str(config["api_key"]),
key=f"embed_{model_name}_api_key",
key=f"lm_{model_name}_api_key",
type="password",
label_visibility="collapsed",
)
st.form_submit_button(label="Save", on_click=update_embed_model_config)
st.form_submit_button(label="Save", on_click=update_lm_model_config)

st.header("Language Models")
with st.form("update_lm_model_config"):
st.header("Embedding Models")
with st.form("update_embed_model_config"):
# Create table header
table2_col_format = st.columns([0.08, 0.3, 0.2, 0.2, 0.2])
col1_2, col2_2, col3_2, col4_2, col5_2 = table2_col_format
col1_2.markdown("**<u>Enabled</u>**", unsafe_allow_html=True)
col2_2.markdown("**<u>Model Name</u>**", unsafe_allow_html=True)
col3_2.markdown("**<u>API</u>**", unsafe_allow_html=True)
col4_2.markdown("**<u>API Server</u>**", unsafe_allow_html=True)
col5_2.markdown("**<u>API Key</u>**", unsafe_allow_html=True)
table1_col_format = st.columns([0.08, 0.3, 0.2, 0.2, 0.2])
col1_1, col2_1, col3_1, col4_1, col5_1 = table1_col_format
col1_1.markdown("**<u>Enabled</u>**", unsafe_allow_html=True)
col2_1.markdown("**<u>Model Name</u>**", unsafe_allow_html=True)
col3_1.markdown("**<u>API</u>**", unsafe_allow_html=True)
col4_1.markdown("**<u>API Server</u>**", unsafe_allow_html=True)
col5_1.markdown("**<u>API Key</u>**", unsafe_allow_html=True)

# Create table rows
for model_name, config in state.lm_model_config.items():
col1_2, col2_2, col3_2, col4_2, col5_2 = table2_col_format
col1_2.checkbox(
for model_name, config in state.embed_model_config.items():
col1_1, col2_1, col3_1, col4_1, col5_1 = table1_col_format
col1_1.checkbox(
"Enabled",
value=config["enabled"],
label_visibility="collapsed",
key=f"lm_{model_name}_enabled",
disabled=False,
key=f"embed_{model_name}_enabled",
disabled=False,
)
col2_2.text_input(
col2_1.text_input(
"Model",
value=model_name,
label_visibility="collapsed",
key=f"lm_{model_name}",
key=f"embed_{model_name}",
disabled=True,
)
col3_2.text_input(
col3_1.text_input(
"API",
value=config["api"],
value=get_class_name(config["api"]),
label_visibility="collapsed",
key=f"lm_{model_name}_api",
key=f"embed_{model_name}_api",
disabled=True,
)
col4_2.text_input(
col4_1.text_input(
"Server",
value=config["url"],
key=f"lm_{model_name}_api_server",
key=f"embed_{model_name}_api_server",
label_visibility="collapsed",
)
col5_2.text_input(
col5_1.text_input(
"Key",
value=str(config["api_key"]),
key=f"lm_{model_name}_api_key",
key=f"embed_{model_name}_api_key",
type="password",
label_visibility="collapsed",
)
st.form_submit_button(label="Save", on_click=update_lm_model_config)
st.form_submit_button(label="Save", on_click=update_embed_model_config)


if __name__ == "__main__" or "page.py" in inspect.stack()[1].filename:
Expand Down
2 changes: 1 addition & 1 deletion app/src/content/split_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def main():
"""Streamlit GUI"""
db_initialise_streamlit()
if not state.db_configured:
st.warning("Database is not configured, all functionality is disabled", icon="🚨")
st.error("Database is not configured, all functionality is disabled", icon="🚨")
st.stop()

model_initialise()
Expand Down
4 changes: 2 additions & 2 deletions app/src/modules/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def embedding_models():
embedding_models_dict = {
# Model: [API, Chunk Size, API Server, API Key]
"thenlper/gte-base": {
"enabled": os.getenv("ON_PREM_EMBED_URL") is not None,
"enabled": os.getenv("ON_PREM_HF_URL") is not None,
"api": HuggingFaceEndpointEmbeddings,
"url": os.environ.get("ON_PREM_EMBED_URL", default="http://127.0.0.1:8080"),
"url": os.environ.get("ON_PREM_HF_URL", default="http://127.0.0.1:8080"),
"api_key": "",
"chunk_max": 512,
},
Expand Down
2 changes: 1 addition & 1 deletion app/src/modules/st_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def initialise_rag():
logger.debug("Initilaising RAG")
try:
if not state.db_configured:
st.warning("Database is not configured, RAG functionality is disabled.", icon="🚨")
st.warning("Database is not configured, RAG functionality is disabled.", icon="⚠️")

# Look-up Embedding Tables to generate RAG LOVs (don't use function)
if state.db_configured:
Expand Down
2 changes: 1 addition & 1 deletion app/src/oaim-sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def main():
if not state.disable_tools and not state.disable_admin:
# Define Additional Pages
split_embed = st.Page("content/split_embed.py", title="Split/Embed", icon="📚")
model_config = st.Page("content/model_config.py", title="Model", icon="🤖")
model_config = st.Page("content/model_config.py", title="Models", icon="🤖")
db_config = st.Page("content/db_config.py", title="Database", icon="🗄️")
# Update Navigation
navigation["Tools"].insert(0, split_embed)
Expand Down
99 changes: 0 additions & 99 deletions app/src/sandbox.py

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/tests/content/split_embed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_db_initialise_streamlit(unset_db_env):
"""DB is not configured"""
at = AppTest.from_file("content/split_embed.py", default_timeout=30).run()
assert at.session_state.db_configured is False
assert at.warning[0].icon == "🚨", "Database is not configured, all functionality is disabled"
assert at.error[0].icon == "🚨", "Database is not configured, all functionality is disabled"


######################################
Expand Down
18 changes: 11 additions & 7 deletions docs-source/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,24 @@ To run the application on bare-metal; download the [source](https://github.com/o
pip3 install --upgrade pip wheel
```

1. Install the Python modules.
1. Install the Python modules:

```bash
pip3 install -r app/requirements.txt
```

1. Start Streamlit.
1. Start Streamlit:

```bash
cd app/src
streamlit run oaim-sandbox.py --server.port 8501
```

1. Navigate to `http://localhost:8501`
1. Navigate to `http://localhost:8501`.

1. [Configure](configuration) the Sandbox
1. [Configure](configuration) the Sandbox.

1. Complete the [Walkthrough](walkthrough/) to get familiar with the Sandbox.

### Container Installation

Expand All @@ -76,15 +78,17 @@ To run the application in a container; download the [source](https://github.com/
podman build -t oaim-sandbox .
```

1. Start Container:
1. Start the Container:

```bash
podman run -p 8501:8501 -it --rm oaim-sandbox
```

1. Navigate to `http://localhost:8501`
1. Navigate to `http://localhost:8501`.

1. [Configure](configuration) the Sandbox.

1. [Configure](configuration) the Sandbox
1. Complete the [Walkthrough](walkthrough/) to get familiar with the Sandbox.

# Need help?

Expand Down
Loading

0 comments on commit 49d229c

Please sign in to comment.