From 2fa831e1766c2916501ad3e5d7740d08853a11ce Mon Sep 17 00:00:00 2001 From: An Phan Date: Thu, 7 Nov 2024 00:09:33 -0800 Subject: [PATCH 1/7] refactor: streamlit-main.py -> app.py --- examples/llamarine/Makefile | 2 +- .../llamarine/{streamlit-main.py => app.py} | 21 ++++++++++--------- examples/llamarine/make.bat | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) rename examples/llamarine/{streamlit-main.py => app.py} (65%) diff --git a/examples/llamarine/Makefile b/examples/llamarine/Makefile index 04903eaed..b37cc6dd1 100644 --- a/examples/llamarine/Makefile +++ b/examples/llamarine/Makefile @@ -1,2 +1,2 @@ streamlit-run: - @poetry run streamlit run streamlit-main.py --server.allowRunOnSave=true --server.runOnSave=true + @poetry run streamlit run app.py --server.allowRunOnSave=true --server.runOnSave=true diff --git a/examples/llamarine/streamlit-main.py b/examples/llamarine/app.py similarity index 65% rename from examples/llamarine/streamlit-main.py rename to examples/llamarine/app.py index 3c036b7c3..c1daa883f 100644 --- a/examples/llamarine/streamlit-main.py +++ b/examples/llamarine/app.py @@ -25,16 +25,17 @@ if 'typed_problem' not in st.session_state: st.session_state.typed_problem: str = DEFAULT_PROBLEM -st.session_state.typed_problem: str = st.text_area(label='Problem/Question', - value=st.session_state.typed_problem, - height=3, - max_chars=None, - key=None, - help='Problem/Question', - on_change=None, args=None, kwargs=None, - placeholder='Problem/Question', - disabled=False, - label_visibility='collapsed') +st.session_state.typed_problem: str = st.text_area( + label='Problem/Question', + value=st.session_state.typed_problem, + max_chars=None, + key=None, + help='Problem/Question', + on_change=None, args=None, kwargs=None, + placeholder='Problem/Question', + disabled=False, + label_visibility='collapsed' +) if 'agent_solutions' not in st.session_state: st.session_state.agent_solutions: defaultdict[str, str] = defaultdict(str) diff --git a/examples/llamarine/make.bat b/examples/llamarine/make.bat index ade0d5bca..506c67b85 100644 --- a/examples/llamarine/make.bat +++ b/examples/llamarine/make.bat @@ -13,7 +13,7 @@ IF "%TARGET%"=="streamlit-run" GOTO streamlit-run :: STREAMLIT APP :: ============= :streamlit-run - poetry run streamlit run streamlit-main.py --server.allowRunOnSave=true --server.runOnSave=true + poetry run streamlit run app.py --server.allowRunOnSave=true --server.runOnSave=true GOTO end From 656fd7b27652a18be187417b101d852e268be4a1 Mon Sep 17 00:00:00 2001 From: An Phan Date: Thu, 7 Nov 2024 00:09:50 -0800 Subject: [PATCH 2/7] build: add Dockerfile --- examples/llamarine/.dockerignore | 2 ++ examples/llamarine/Dockerfile | 21 +++++++++++++++++++++ examples/llamarine/requirements.txt | 2 ++ 3 files changed, 25 insertions(+) create mode 100644 examples/llamarine/.dockerignore create mode 100644 examples/llamarine/Dockerfile create mode 100644 examples/llamarine/requirements.txt diff --git a/examples/llamarine/.dockerignore b/examples/llamarine/.dockerignore new file mode 100644 index 000000000..a56435031 --- /dev/null +++ b/examples/llamarine/.dockerignore @@ -0,0 +1,2 @@ +README.md +.env diff --git a/examples/llamarine/Dockerfile b/examples/llamarine/Dockerfile new file mode 100644 index 000000000..483709ae7 --- /dev/null +++ b/examples/llamarine/Dockerfile @@ -0,0 +1,21 @@ +# Use an official Python runtime as a base image +FROM python:3.12-slim + +# Set the working directory +WORKDIR /app + +# Install git and any other system dependencies +RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* + +# Copy the requirements file and install dependencies +COPY requirements.txt /app/ +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code +COPY . /app + +# Expose port 8501 (default Streamlit port) +EXPOSE 8501 + +# Run the Streamlit app +CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.enableCORS=false", "--server.enableXsrfProtection=false"] diff --git a/examples/llamarine/requirements.txt b/examples/llamarine/requirements.txt new file mode 100644 index 000000000..da23b2fea --- /dev/null +++ b/examples/llamarine/requirements.txt @@ -0,0 +1,2 @@ +streamlit>=1.40.0 +git+https://github.com/aitomatic/openssa.git@0.24.10.26 From 29378a035ab6f76b73652f1d295618038609cf83 Mon Sep 17 00:00:00 2001 From: An Phan Date: Thu, 7 Nov 2024 00:12:08 -0800 Subject: [PATCH 3/7] doc: add docker run guide --- examples/llamarine/README.md | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/examples/llamarine/README.md b/examples/llamarine/README.md index 810a0b36a..65ddc8133 100644 --- a/examples/llamarine/README.md +++ b/examples/llamarine/README.md @@ -1,7 +1,35 @@ -# Maritime-Specific Agents leveraging Open-Source `Llamarine` LM +# Maritime-Specific Agent -## Streamlit App +This app serves as a proof of concept (PoC) for a maritime-specific AI agent designed to address and solve collision avoidance problems in marine navigation. -Run by `make streamlit-run` +## Usage + +```shell +make streamlit-run +``` + +## Running with Docker + +If you prefer to run the app in a Docker container, follow these steps: + +### Prerequisites + +- Docker installed on your machine. + +### Building the Docker Image + +```shell +docker build -t dana-llamarine . +``` + +### Running the Docker Container + +1. Running the container: + +```shell +docker run --name llamarine-test --rm -p 8501:8501 -e .env dana-llamarine +``` + +2. Access the app at [http://localhost:8501](http://localhost:8501). From 2892ad813e49fc5425101de35d57712f59aed44d Mon Sep 17 00:00:00 2001 From: An Phan Date: Thu, 7 Nov 2024 00:18:06 -0800 Subject: [PATCH 4/7] doc: mention DANA --- examples/llamarine/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/llamarine/README.md b/examples/llamarine/README.md index 65ddc8133..f2b48a0e2 100644 --- a/examples/llamarine/README.md +++ b/examples/llamarine/README.md @@ -2,7 +2,7 @@ # Maritime-Specific Agent -This app serves as a proof of concept (PoC) for a maritime-specific AI agent designed to address and solve collision avoidance problems in marine navigation. +This app serves as a proof of concept (PoC) for a maritime-specific AI agent leveraging [Domain-Aware Neurosymbolic Agent (DANA)](https://arxiv.org/abs/2410.02823) architecture to address and solve collision avoidance problems in marine navigation. ## Usage From 821c3af38f80239398b10ced7f971a08bb3cf4cd Mon Sep 17 00:00:00 2001 From: An Phan Date: Thu, 7 Nov 2024 06:05:00 -0800 Subject: [PATCH 5/7] build: apt install --no-install-recommends --- examples/llamarine/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/llamarine/Dockerfile b/examples/llamarine/Dockerfile index 483709ae7..6caae765e 100644 --- a/examples/llamarine/Dockerfile +++ b/examples/llamarine/Dockerfile @@ -5,7 +5,7 @@ FROM python:3.12-slim WORKDIR /app # Install git and any other system dependencies -RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/* # Copy the requirements file and install dependencies COPY requirements.txt /app/ From 81ebd04bd3dcf3178edbe364964a565ac83db5fd Mon Sep 17 00:00:00 2001 From: An Phan Date: Thu, 7 Nov 2024 06:08:05 -0800 Subject: [PATCH 6/7] doc: fix codacy warning --- examples/llamarine/README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/llamarine/README.md b/examples/llamarine/README.md index f2b48a0e2..bc3cdd0db 100644 --- a/examples/llamarine/README.md +++ b/examples/llamarine/README.md @@ -2,7 +2,9 @@ # Maritime-Specific Agent -This app serves as a proof of concept (PoC) for a maritime-specific AI agent leveraging [Domain-Aware Neurosymbolic Agent (DANA)](https://arxiv.org/abs/2410.02823) architecture to address and solve collision avoidance problems in marine navigation. +This app serves as a proof of concept (PoC) for a maritime-specific AI agent +leveraging [Domain-Aware Neurosymbolic Agent (DANA)](https://arxiv.org/abs/2410.02823) architecture to address and solve +collision avoidance problems in marine navigation. ## Usage @@ -26,10 +28,12 @@ docker build -t dana-llamarine . ### Running the Docker Container -1. Running the container: +#### Running the container ```shell docker run --name llamarine-test --rm -p 8501:8501 -e .env dana-llamarine ``` -2. Access the app at [http://localhost:8501](http://localhost:8501). +#### Access the app + +[http://localhost:8501](http://localhost:8501) From ca6a8482c1c3cf831a4610f901afac89fe163e8c Mon Sep 17 00:00:00 2001 From: An Phan Date: Thu, 7 Nov 2024 08:41:23 -0800 Subject: [PATCH 7/7] codacy: specify git version --- examples/llamarine/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/llamarine/Dockerfile b/examples/llamarine/Dockerfile index 6caae765e..97fef4d3c 100644 --- a/examples/llamarine/Dockerfile +++ b/examples/llamarine/Dockerfile @@ -5,7 +5,7 @@ FROM python:3.12-slim WORKDIR /app # Install git and any other system dependencies -RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y --no-install-recommends git=1:2.39.5-0+deb12u1 && rm -rf /var/lib/apt/lists/* # Copy the requirements file and install dependencies COPY requirements.txt /app/ @@ -14,7 +14,7 @@ RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application code COPY . /app -# Expose port 8501 (default Streamlit port) +# Expose Streamlit port EXPOSE 8501 # Run the Streamlit app