Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and push docker images to GHCR #11

Merged
merged 5 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/docker_build_push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build Docker Image and Push to GHCR

on:
push:
branches:
- main
- feat/docker-build

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
ghcr.io/developmentseed/llllm:latest
ghcr.io/developmentseed/llllm:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mambaorg/micromamba:1.4-bullseye-slim

USER root
RUN apt update && apt install -y gcc python3-dev \
&& rm -rf /var/lib/apt/lists/*
USER $MAMBA_USER

COPY --chown=$MAMBA_USER:$MAMBA_USER environment.yaml /tmp/env.yaml
# TODO: avoid installing development dependencies
RUN micromamba env create --yes -f /tmp/env.yaml && \
micromamba clean --all --yes

EXPOSE 8501

COPY . /app
WORKDIR /app

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

ENTRYPOINT ["/opt/conda/envs/llllm-env/bin/streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
5 changes: 3 additions & 2 deletions agents/l4m_agent.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from langchain.agents import initialize_agent
from langchain.agents import AgentType


def base_agent(llm, tools, name="zero-shot-react-description"):
def base_agent(llm, tools, agent_type=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION):
"""Base agent to perform xyz slippy map tiles operations.

llm: LLM object
Expand All @@ -10,7 +11,7 @@ def base_agent(llm, tools, name="zero-shot-react-description"):
agent = initialize_agent(
llm=llm,
tools=tools,
agent=name,
agent=agent_type,
max_iterations=3,
early_stopping_method="generate",
verbose=True,
Expand Down
15 changes: 6 additions & 9 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os

import osmnx as ox
import geopandas as gpd
import folium
import streamlit as st
from streamlit_folium import folium_static

from langchain.agents import AgentType
from langchain.chat_models import ChatOpenAI
from langchain.tools import Tool, DuckDuckGoSearchRun

Expand All @@ -13,11 +15,6 @@
from tools.osmnx.network import OSMnxNetworkTool
from agents.l4m_agent import base_agent

import geopandas as gpd
import streamlit as st
import folium
from streamlit_folium import folium_static


def get_llm():
llm = ChatOpenAI(
Expand All @@ -28,7 +25,7 @@ def get_llm():
return llm


def get_agent(llm, name="structured-chat-zero-shot-react-description"):
def get_agent(llm, agent_type=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION):
# define a set of tools the agent has access to for queries
duckduckgo_tool = Tool(
name="DuckDuckGo",
Expand All @@ -51,7 +48,7 @@ def get_agent(llm, name="structured-chat-zero-shot-react-description"):
network_tool,
]

agent = base_agent(llm, tools, name=name)
agent = base_agent(llm, tools, agent_type=agent_type)
return agent


Expand Down
19 changes: 10 additions & 9 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ dependencies:
- pip
- osmnx=1.3.1
- pip:
- openai
- langchain
- duckduckgo-search
- mercantile
- geopy
- ipywidgets
- jupyterlab
- streamlit
- streamlit-folium
- openai==0.27.8
- langchain==0.0.215
- duckduckgo-search==3.8.3
- mercantile==1.2.1
- geopy==2.3.0
- ipywidgets==8.0.6
- jupyterlab==4.0.2
- streamlit==1.23.1
- streamlit-folium==0.12.0
- watchdog==3.0.0