From 4249e44f4b84c69ef299f9c026e07a56c39d94c4 Mon Sep 17 00:00:00 2001 From: swarnabhasinha Date: Sat, 22 Feb 2025 12:17:59 +0530 Subject: [PATCH 1/3] feat: add dockerfile for better windows support --- Dockerfile | 54 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6c16d0f..8fdf4c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,67 @@ # Stage 1: Build Frontend -FROM node:18-alpine AS frontend-builder +FROM mcr.microsoft.com/mirror/docker/library/node:18-alpine AS frontend-builder WORKDIR /frontend COPY chat-ui/ . RUN npm install RUN npm run build # Stage 2: Build Backend -FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS backend-builder -ADD . /flare-ai-social +FROM mcr.microsoft.com/mirror/docker/library/python:3.11-slim AS backend-builder WORKDIR /flare-ai-social -RUN uv sync --frozen + +# Install build dependencies and uv globally +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + build-essential \ + curl && \ + rm -rf /var/lib/apt/lists/* && \ + pip install uv + +# Create and activate virtual environment +RUN python -m venv .venv && \ + . .venv/bin/activate && \ + python -m pip install --upgrade pip + +ENV PATH="/flare-ai-social/.venv/bin:$PATH" +ENV VIRTUAL_ENV="/flare-ai-social/.venv" +ENV PYTHONPATH="/flare-ai-social/.venv/lib/python3.11/site-packages" + +# Copy project files +COPY pyproject.toml ./ +COPY . . + +# Install dependencies based on the file type +RUN if [ -f "requirements.txt" ]; then \ + uv pip install -r requirements.txt; \ + elif [ -f "pyproject.toml" ]; then \ + uv sync --frozen; \ + fi # Stage 3: Final Image -FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim +FROM mcr.microsoft.com/mirror/docker/library/python:3.11-slim -# Install nginx -RUN apt-get update && apt-get install -y nginx supervisor curl && \ - rm -rf /var/lib/apt/lists/* +# Install runtime dependencies and uv +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + nginx \ + supervisor \ + curl && \ + rm -rf /var/lib/apt/lists/* && \ + pip install uv WORKDIR /app + +# Copy virtual environment and project files COPY --from=backend-builder /flare-ai-social/.venv ./.venv COPY --from=backend-builder /flare-ai-social/src ./src COPY --from=backend-builder /flare-ai-social/pyproject.toml . COPY --from=backend-builder /flare-ai-social/README.md . +# Set up Python environment in the final stage +ENV PATH="/app/.venv/bin:$PATH" +ENV VIRTUAL_ENV="/app/.venv" +ENV PYTHONPATH="/app/.venv/lib/python3.11/site-packages" + # Copy frontend files COPY --from=frontend-builder /frontend/build /usr/share/nginx/html From 150b1eac24e1486177a0f5830fbaa339bb9c118b Mon Sep 17 00:00:00 2001 From: swarnabhasinha Date: Sat, 22 Feb 2025 14:36:37 +0530 Subject: [PATCH 2/3] feat: dockerfile for windows and project ideas --- Dockerfile | 54 +++++++--------------------------------------- Dockerfile.windows | 43 ++++++++++++++++++++++++++++++++++++ README.md | 39 +++++++++++++++++++++++++++++++-- 3 files changed, 88 insertions(+), 48 deletions(-) create mode 100644 Dockerfile.windows diff --git a/Dockerfile b/Dockerfile index 8fdf4c6..6c16d0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,67 +1,29 @@ # Stage 1: Build Frontend -FROM mcr.microsoft.com/mirror/docker/library/node:18-alpine AS frontend-builder +FROM node:18-alpine AS frontend-builder WORKDIR /frontend COPY chat-ui/ . RUN npm install RUN npm run build # Stage 2: Build Backend -FROM mcr.microsoft.com/mirror/docker/library/python:3.11-slim AS backend-builder +FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS backend-builder +ADD . /flare-ai-social WORKDIR /flare-ai-social - -# Install build dependencies and uv globally -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - build-essential \ - curl && \ - rm -rf /var/lib/apt/lists/* && \ - pip install uv - -# Create and activate virtual environment -RUN python -m venv .venv && \ - . .venv/bin/activate && \ - python -m pip install --upgrade pip - -ENV PATH="/flare-ai-social/.venv/bin:$PATH" -ENV VIRTUAL_ENV="/flare-ai-social/.venv" -ENV PYTHONPATH="/flare-ai-social/.venv/lib/python3.11/site-packages" - -# Copy project files -COPY pyproject.toml ./ -COPY . . - -# Install dependencies based on the file type -RUN if [ -f "requirements.txt" ]; then \ - uv pip install -r requirements.txt; \ - elif [ -f "pyproject.toml" ]; then \ - uv sync --frozen; \ - fi +RUN uv sync --frozen # Stage 3: Final Image -FROM mcr.microsoft.com/mirror/docker/library/python:3.11-slim +FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim -# Install runtime dependencies and uv -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - nginx \ - supervisor \ - curl && \ - rm -rf /var/lib/apt/lists/* && \ - pip install uv +# Install nginx +RUN apt-get update && apt-get install -y nginx supervisor curl && \ + rm -rf /var/lib/apt/lists/* WORKDIR /app - -# Copy virtual environment and project files COPY --from=backend-builder /flare-ai-social/.venv ./.venv COPY --from=backend-builder /flare-ai-social/src ./src COPY --from=backend-builder /flare-ai-social/pyproject.toml . COPY --from=backend-builder /flare-ai-social/README.md . -# Set up Python environment in the final stage -ENV PATH="/app/.venv/bin:$PATH" -ENV VIRTUAL_ENV="/app/.venv" -ENV PYTHONPATH="/app/.venv/lib/python3.11/site-packages" - # Copy frontend files COPY --from=frontend-builder /frontend/build /usr/share/nginx/html diff --git a/Dockerfile.windows b/Dockerfile.windows new file mode 100644 index 0000000..a3e4648 --- /dev/null +++ b/Dockerfile.windows @@ -0,0 +1,43 @@ +# Stage 1: Build Frontend +FROM mcr.microsoft.com/mirror/docker/library/node:18-alpine AS frontend-builder +WORKDIR /frontend +COPY chat-ui/ . +RUN npm install +RUN npm run build + +# Stage 2: Build Backend +FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS backend-builder +ADD . /flare-ai-social +WORKDIR /flare-ai-social +RUN uv sync --frozen + +# Stage 3: Final Image +FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim + +# Install nginx +RUN apt-get update && apt-get install -y nginx supervisor curl && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /app +COPY --from=backend-builder /flare-ai-social/.venv ./.venv +COPY --from=backend-builder /flare-ai-social/src ./src +COPY --from=backend-builder /flare-ai-social/pyproject.toml . +COPY --from=backend-builder /flare-ai-social/README.md . + +# Copy frontend files +COPY --from=frontend-builder /frontend/build /usr/share/nginx/html + +# Copy nginx configuration +COPY nginx.conf /etc/nginx/sites-enabled/default + +# Setup supervisor configuration +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# Allow workload operator to override environment variables +LABEL "tee.launch_policy.allow_env_override"="GEMINI_API_KEY,TUNED_MODEL_NAME,SIMULATE_ATTESTATION" +LABEL "tee.launch_policy.log_redirect"="always" + +EXPOSE 80 + +# Start supervisor (which will start both nginx and the backend) +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] \ No newline at end of file diff --git a/README.md b/README.md index 253890a..6d240e9 100644 --- a/README.md +++ b/README.md @@ -87,8 +87,13 @@ The Docker setup mimics a TEE environment and includes an Nginx server for routi ```bash docker build -t flare-ai-social . ``` +**NOTE:** For Windows users encountering DNS issues, you can use the alternative Windows Dockerfile: -2. **Run the Docker Container:** + ```bash + docker build -f Dockerfile.windows -t flare-ai-social . + ``` + +2. b**Run the Docker Container:** ```bash docker run -p 80:80 -it --env-file .env flare-ai-social @@ -235,4 +240,34 @@ If you encounter issues, follow these steps: ## 💡 Next Steps -TODO +Below are several detailed project ideas demonstrating how the template can be used to build autonomous AI agents: + +### 1. Travel AI Agent +- Implement a travel service layer that: + - Connects to flight/hotel booking APIs + - Manages itinerary generation + - Handles payment processing + - Stores user preferences/history +- Agent interfaces with this to: + - Process natural language travel requests + - Check availability and pricing + - Generate customized itineraries + - Handle booking confirmations +- Example: User asks "Book me a trip to Paris" -> Agent queries travel service for options -> Handles booking flow through conversation + +### 2. Event & Updates Agent +- **Core Concept**: Keep community informed about Flare developments +- **Implementation**: + - Monitor official channels for announcements + - Summarize technical updates in accessible language + - Answer questions about recent changes + - Generate event reminders and summaries + +### 3. DeFi Portfolio AI Agent + +- Build a service that tracks single wallet DeFi positions, analyzes APY/risks, and calculates profit/loss +- Process natural language queries through Twitter/Telegram for portfolio stats and alerts +- Run sensitive wallet monitoring securely in TEE with attestation +- Examples: "Check my wallet APY", "Alert me when health factor < 80%", "Show today's earnings" + + From aa02e8dc65036fe7aace9d2c91576426d194d29d Mon Sep 17 00:00:00 2001 From: Dinesh Pinto Date: Sat, 22 Feb 2025 13:40:13 +0400 Subject: [PATCH 3/3] fix(readme): update next steps section --- README.md | 77 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 6d240e9..aa9a675 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,8 @@ The Docker setup mimics a TEE environment and includes an Nginx server for routi ```bash docker build -t flare-ai-social . ``` -**NOTE:** For Windows users encountering DNS issues, you can use the alternative Windows Dockerfile: + + **NOTE:** For Windows users encountering DNS issues, you can use the alternative Windows Dockerfile: ```bash docker build -f Dockerfile.windows -t flare-ai-social . @@ -240,34 +241,50 @@ If you encounter issues, follow these steps: ## 💡 Next Steps -Below are several detailed project ideas demonstrating how the template can be used to build autonomous AI agents: - -### 1. Travel AI Agent -- Implement a travel service layer that: - - Connects to flight/hotel booking APIs - - Manages itinerary generation - - Handles payment processing - - Stores user preferences/history -- Agent interfaces with this to: - - Process natural language travel requests - - Check availability and pricing - - Generate customized itineraries - - Handle booking confirmations -- Example: User asks "Book me a trip to Paris" -> Agent queries travel service for options -> Handles booking flow through conversation - -### 2. Event & Updates Agent -- **Core Concept**: Keep community informed about Flare developments -- **Implementation**: - - Monitor official channels for announcements - - Summarize technical updates in accessible language - - Answer questions about recent changes - - Generate event reminders and summaries - -### 3. DeFi Portfolio AI Agent - -- Build a service that tracks single wallet DeFi positions, analyzes APY/risks, and calculates profit/loss -- Process natural language queries through Twitter/Telegram for portfolio stats and alerts -- Run sensitive wallet monitoring securely in TEE with attestation -- Examples: "Check my wallet APY", "Alert me when health factor < 80%", "Show today's earnings" +Below are several project ideas demonstrating how the template can be used to build useful social AI agents: + +### Dev Support on Telegram + +- **Integrate with flare-ai-rag:** + Combine the social AI agent with the [flare-ai-rag](https://github.com/flare-foundation/flare-ai-rag) model trained on the [Flare Developer Hub](https://dev.flare.network) dataset. +- **Enhanced Developer Interaction:** + + - Provide targeted support for developers exploring [FTSO](https://dev.flare.network/ftso/overview) and [FDC](https://dev.flare.network/fdc/overview). + - Implement code-based interactions, including live debugging tips and code snippet sharing. + +- **Action Steps:** + - Connect the model to GitHub repositories to fetch live code examples. + - Fine-tune prompt templates using technical documentation to improve precision in code-related queries. + +### Community Support on Telegram + +- **Simplify Technical Updates:** + - Convert detailed [Flare governance proposals](https://proposals.flare.network) into concise, accessible summaries for community members. +- **Real-Time Monitoring and Q&A:** + + - Monitor channels like the [Flare Telegram](https://t.me/FlareNetwork) for live updates. + - Automatically answer common community questions regarding platform changes. + +- **Action Steps:** + - Integrate modules for content summarization and sentiment analysis. + - Establish a feedback loop to refine responses based on community engagement. + +### Social Media Sentiment & Moderation Bot + +- **Purpose:** + Analyze sentiment on platforms like Twitter, Reddit, or Discord to monitor community mood, flag problematic content, and generate real-time moderation reports. + +- **Action Steps:** + - Leverage NLP libraries for sentiment analysis and content filtering. + - Integrate with social media APIs to capture and process live data. + - Set up dashboards to monitor trends and flagged content. + +### Personalized Content Curation Agent +- **Purpose:** + Curate personalized content such as news, blog posts, or tutorials tailored to user interests and engagement history. +- **Action Steps:** + - Employ user profiling techniques to analyze preferences. + - Use machine learning algorithms to recommend content based on past interactions. + - Continuously refine the recommendation engine with user feedback and engagement metrics.