-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(wren-ai-service): create Streamlit UI for configuring LLM models #1690
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
Open
yichieh-lu
wants to merge
76
commits into
Canner:main
Choose a base branch
from
yichieh-lu:feature/providers-setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 69 commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
da42d8d
fix: add fmt.Scanln for debugging missing error report
yichieh-lu 4584b05
Merge branch 'main' into main
cyyeh 462554d
Merge remote-tracking branch 'upstream/main'
yichieh-lu 96667ab
Merge branch 'main' of https://github.com/yichieh-lu/WrenAI
yichieh-lu a275e42
Remove redundant code
yichieh-lu c96f296
Add initial config.grok.yaml to support deploymen
yichieh-lu e7edbd3
Merge remote-tracking branch 'upstream/main'
yichieh-lu 398a14c
Remove redundant engine declaration
yichieh-lu e090cf0
Remove incorrect settings from config_examples YAML files
yichieh-lu a39d71f
Merge remote-tracking branch 'upstream/main'
yichieh-lu d59c6bf
Merge remote-tracking branch 'upstream/main'
yichieh-lu 1168301
Draft streamlit_ui
yichieh-lu c70f183
Build a testing streamlit_ui
yichieh-lu a261c3b
Extract constants to constants.py
yichieh-lu 0cf0ddd
refactor: extract download_config and load_block from custom_llm_ui.py
yichieh-lu 35a9743
refactor: split load_blocks into load_yaml_list and group_blocks
yichieh-lu 66488b1
refactor: move session state handling to ConfigState class in session…
yichieh-lu 54885d7
style: remove trailing whitespace
yichieh-lu c6bc142
refactor: extract UI layout and elements to ui_components.py
yichieh-lu 01d3208
Refactor app structure and fix data type issues
yichieh-lu 04edc56
feat: check for duplicate alias names
yichieh-lu fdb2114
refactor: extract preview and generate YAML UI to ui_components.py
yichieh-lu 7f8daca
feat: add pipeline configuration in ui_components.py
yichieh-lu 494fac4
feat: add dry_run_test.py testing api_key and embedding model with li…
yichieh-lu 181eb6f
Merge remote-tracking branch 'upstream/main'
yichieh-lu 7436303
feat: add validate function ensuring every field can be validated
yichieh-lu 0f8e386
feat: support multiple API keys configuration for different LLMs
yichieh-lu cf14ae5
feat: support multiple API keys configuration for different LLMs
yichieh-lu ac81e37
feat: support saving multiple API keys and enable validation for LLM …
yichieh-lu 9d4f0a0
Merge remote-tracking branch 'upstream/main'
yichieh-lu 90dd5a3
fix: ensure config.yaml is downloaded correctly
yichieh-lu a608d80
fix: ensure config.yaml is downloaded correctly
yichieh-lu 667043b
feat: add api_base support to render_embedder and session state
yichieh-lu 5a675aa
feat: get the latest WrenAI version in constants.py
yichieh-lu 57077c2
feat: add selectbox for users to choose config.example.yaml by LLM pr…
yichieh-lu 54f133d
chore: improve code comments and docstrings across UI components
yichieh-lu cad7459
chore: add initial requirements.txt with ui dependencies
yichieh-lu e9639e4
Merge remote-tracking branch 'upstream/main'
yichieh-lu 05aac3d
chore: updates requirements.txt with ui dependencies
yichieh-lu f1b3e45
chore: improve code comments and docstrings across UI components
yichieh-lu 6533430
feat: add Finished.setting to close Streamlit UI, continue CLI setup,…
yichieh-lu 366db9f
feat: add Streamlit UI Dockerfile and implement 'custom' launch option
yichieh-lu 9ce5946
refactor: decouple RunStreamlitUIContainer logic from launch.go and d…
yichieh-lu 6bed2b4
feat: add 'custom' mode to launch Streamlit UI and ensure config file…
yichieh-lu 6a068d1
Merge remote-tracking branch 'upstream/main'
yichieh-lu d40ae29
chore: rename streamlit-ui to providers-setup and move to tools direc…
yichieh-lu 011ce4b
feat: rewrite Dockerfile to use Poetry and remove requirements.txt
yichieh-lu bb8dab6
chore: rename streamlit-ui to providers-setup
yichieh-lu b4d5b4e
update dependencies
cyyeh 6255290
Merge remote-tracking branch 'upstream/main'
yichieh-lu d0d0360
Merge branches 'main' and 'main' of https://github.com/yichieh-lu/WrenAI
yichieh-lu 8341378
chore: fix Streamlit UI layout
yichieh-lu eeedb81
Merge remote-tracking branch 'upstream/main'
yichieh-lu d9bd650
Merge branch 'main' into main
cyyeh 9f830b1
Merge branch 'main' into main
cyyeh 430c67b
Merge remote-tracking branch 'upstream/main'
yichieh-lu fc5ee05
refactor(wren-ai-service): streamline UI components and enhance confi…
yichieh-lu efc6529
refactor(wren-ai-service): improve configuration path handling and UI…
yichieh-lu 095475c
feat(wren-ai-service): add validation for configuration blocks and im…
yichieh-lu 8f892e6
refactor(wren-ai-service): enhance config extraction and improve UI c…
yichieh-lu 2dc1b38
Merge remote-tracking branch 'upstream/main'
yichieh-lu ea0765c
feat(workflow): add setup provider image workflow
yichieh-lu 06ccc36
fix(workflow): update IMAGE_NAME to use repository owner
yichieh-lu 1b80ae1
fix(workflow): update Docker image tags to include registry
yichieh-lu 1cbeb60
fix(workflow): comment out ARM64 runner configuration in build matrix
yichieh-lu de9d460
fix(workflow): enable ARM64 runner configuration in build matrix
yichieh-lu f08abae
fix(workflow): enhance setup-provider-image workflow with multi-archi…
yichieh-lu b983e36
Merge remote-tracking branch 'upstream/main'
yichieh-lu bdd4f9f
feat(pipeline): enhance pipeline initialization to fetch and add miss…
yichieh-lu 0d236be
feat(ui): add context window size configuration to LLM setup and vali…
yichieh-lu a706d3b
Merge branch 'main' into feature/providers-setup
yichieh-lu 8afc269
fix: update local path for .env file and improve error handling in em…
yichieh-lu 0b991c6
feat: enhance Streamlit UI container setup with configurable port and…
yichieh-lu d43e7cf
Update wren-ai-service/tools/providers-setup/ui_components.py
yichieh-lu 2c4614b
Merge branch 'main' into feature/providers-setup
cyyeh 6540936
Merge branch 'main' into feature/providers-setup
yichieh-lu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| name: Providers Setup Release Image | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag_name: | ||
| description: 'Docker image tag name (optional)' | ||
| type: string | ||
|
|
||
|
|
||
| # permissions: | ||
| # contents: read | ||
| # packages: write | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| PROVIDER_UI_IMAGE: ${{ github.repository_owner }}/wren-setup-provider-ui | ||
|
|
||
|
|
||
| jobs: | ||
| build-image: | ||
| outputs: | ||
| tag_name: ${{ steps.prep-tag.outputs.TAG_NAME }} | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| arch: | ||
| - runner: ubuntu-latest | ||
| platform: linux/amd64 | ||
| - runner: ubuntu-24.04-arm | ||
| platform: linux/arm64 | ||
|
|
||
| runs-on: ${{ matrix.arch.runner }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Login to GHCR | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Prepare tag | ||
| id: prep-tag | ||
| run: | | ||
| if [ -n "${{ github.event.inputs.tag_name }}" ]; then | ||
| TAG="${{ github.event.inputs.tag_name }}" | ||
| else | ||
| TAG="commit-$(git rev-parse --short HEAD)" | ||
| fi | ||
| echo "TAG_NAME=$TAG" >> "$GITHUB_OUTPUT" | ||
| echo "TAG=$TAG" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Prepare platform env | ||
| run: | | ||
| echo "PLATFORM_PAIR=${{ matrix.arch.platform // '/' '-'}}" >> "$GITHUB_ENV" | ||
yichieh-lu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - name: Build and push by digest | ||
| id: build | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: ./wren-ai-service/tools/providers-setup | ||
| file: ./wren-ai-service/tools/providers-setup/Dockerfile | ||
| platforms: ${{ matrix.arch.platform }} | ||
| labels: ${{ env.REGISTRY }}/${{ env.PROVIDER_UI_IMAGE }} | ||
| outputs: | | ||
| type=image,\ | ||
| name=${{ env.REGISTRY }}/${{ env.PROVIDER_UI_IMAGE }},\ | ||
| push-by-digest=true,\ | ||
| name-canonical=true,\ | ||
| push=true | ||
|
|
||
| - name: Export digest | ||
| run: | | ||
| mkdir -p /tmp/digests | ||
| digest="${{ steps.build.outputs.digest }}" | ||
| touch "/tmp/digests/${digest#sha256:}" | ||
|
|
||
| - name: Upload digest artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: digests-${{ env.PLATFORM_PAIR }} | ||
| path: /tmp/digests/* | ||
| if-no-files-found: error | ||
| retention-days: 1 | ||
|
|
||
| merge: | ||
| needs: [build-image] | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Download digests | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| path: /tmp/digests | ||
| pattern: digests-* | ||
| merge-multiple: true | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Docker meta (tag list) | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.PROVIDER_UI_IMAGE }} | ||
| tags: | | ||
| ${{ needs.build-image.outputs.tag_name }} | ||
|
|
||
| - name: Login to GHCR | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Create & push manifest list | ||
| working-directory: /tmp/digests | ||
| run: | | ||
| TAGS=$(jq -cr '.tags | map("--tag " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") | ||
| docker buildx imagetools create \ | ||
| $(printf '${{ env.REGISTRY }}/${{ env.PROVIDER_UI_IMAGE }}@sha256:%s ' *) \ | ||
| $TAGS | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Use official slim Python 3.12 base image | ||
| FROM python:3.12.0-slim | ||
|
|
||
| # ------------------------------- | ||
| # System Dependencies for Poetry | ||
| # ------------------------------- | ||
| # Install minimal system packages: curl (for downloading), build tools (for native extensions) | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| curl build-essential gcc \ | ||
| && apt-get clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # ------------------------------- | ||
| # Install Poetry (Python package manager) | ||
| # ------------------------------- | ||
| ENV POETRY_VERSION=1.8.2 | ||
| ENV POETRY_HOME="/opt/poetry" | ||
| ENV PATH="$POETRY_HOME/bin:$PATH" | ||
| ENV POETRY_VIRTUALENVS_CREATE=false | ||
| # Don't use virtualenvs inside the container | ||
|
|
||
| RUN curl -sSL https://install.python-poetry.org | python3 - \ | ||
| && ln -s $POETRY_HOME/bin/poetry /usr/local/bin/poetry | ||
|
|
||
| # ------------------------------- | ||
| # Set working directory for app | ||
| # ------------------------------- | ||
| WORKDIR /app | ||
|
|
||
| # ------------------------------- | ||
| # Install Python dependencies via Poetry | ||
| # ------------------------------- | ||
| # Copy only dependency files first to leverage Docker layer caching | ||
| COPY pyproject.toml poetry.lock ./ | ||
| RUN poetry install --no-interaction --no-ansi | ||
|
|
||
| # ------------------------------- | ||
| # Copy remaining app code | ||
| # ------------------------------- | ||
| COPY . . | ||
|
|
||
| # ------------------------------- | ||
| # Environment variables for Streamlit | ||
| # ------------------------------- | ||
| ENV PYTHONUNBUFFERED=1 | ||
| ENV STREAMLIT_SERVER_HEADLESS=true | ||
| ENV STREAMLIT_SERVER_PORT=8501 | ||
| ENV STREAMLIT_SERVER_ENABLECORS=false | ||
|
|
||
| # ------------------------------- | ||
| # Expose Streamlit port | ||
| # ------------------------------- | ||
| EXPOSE 8501 | ||
|
|
||
| # ------------------------------- | ||
| # Default command to run the Streamlit app | ||
| # ------------------------------- | ||
| CMD ["streamlit", "run", "app.py"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| from config_loader import load_config_yaml_blocks, group_blocks | ||
| from session_state import ConfigState | ||
| from ui_components import ( | ||
| render_llm_config, | ||
| render_embedder_config, | ||
| render_import_yaml, | ||
| render_pipeline_config, | ||
| render_preview, | ||
| render_apikey, | ||
| render_generate_button | ||
| ) | ||
| import streamlit as st | ||
|
|
||
| # Set Streamlit page layout | ||
| st.set_page_config( | ||
| layout="wide", # Use a wide layout for better horizontal space | ||
| initial_sidebar_state="expanded" # Expand sidebar by default | ||
| ) | ||
|
|
||
| # Load and group configuration blocks from YAML | ||
| yaml_list = load_config_yaml_blocks() | ||
| blocks = group_blocks(yaml_list) | ||
|
|
||
| # Retrieve individual configuration sections | ||
| llm_block = blocks.get("llm", {}) | ||
| embedder_block = blocks.get("embedder", {}) | ||
| document_store_block = blocks.get("document_store", {}) | ||
| engine_blocks = blocks.get("engine", []) | ||
| pipeline_block = blocks.get("pipeline", {}) | ||
| settings_block = blocks.get("settings", {}) | ||
|
|
||
|
|
||
| # Validate required blocks (type + content) | ||
| missing_blocks = [] | ||
|
|
||
| if not isinstance(llm_block, dict) or not llm_block: | ||
| missing_blocks.append("LLM") | ||
| if not isinstance(embedder_block, dict) or not embedder_block: | ||
| missing_blocks.append("Embedder") | ||
| if not isinstance(document_store_block, dict) or not document_store_block: | ||
| missing_blocks.append("Document Store") | ||
| if not isinstance(pipeline_block, dict) or not pipeline_block: | ||
| missing_blocks.append("Pipeline") | ||
|
|
||
| if missing_blocks: | ||
| st.warning( | ||
| f"⚠️ Missing or empty configuration blocks: {', '.join(missing_blocks)}. " | ||
| "Default values will be used where applicable." | ||
| ) | ||
|
|
||
| # Initialize session state with default or imported config values | ||
| ConfigState.init(llm_block, embedder_block, document_store_block, pipeline_block) | ||
|
|
||
| # ---------------------- | ||
| # Streamlit UI rendering | ||
| # ---------------------- | ||
| st.title("Custom Provider Config Generator") | ||
|
|
||
| # Layout: two columns – left for inputs, right for preview/export | ||
| col1, col2 = st.columns([1.5, 1]) | ||
|
|
||
| with col1: | ||
|
|
||
| # API key input section | ||
| st.subheader("API_KEY Configuration") | ||
| render_apikey() | ||
|
|
||
| # Upload and parse YAML file into session state | ||
| st.subheader("LLM Configuration") | ||
| render_import_yaml() | ||
|
|
||
| # LLM model configuration UI | ||
| render_llm_config() | ||
|
|
||
| # Embedding model configuration UI | ||
| st.subheader("Embedder Configuration") | ||
| render_embedder_config() | ||
|
|
||
| # Pipeline flow configuration UI | ||
| st.subheader("Pipeline Configuration") | ||
| render_pipeline_config() | ||
|
|
||
| # Generate config.yaml and save configuration button | ||
| render_generate_button(engine_blocks, settings_block) | ||
|
|
||
| with col2: | ||
| # Final preview and export of the combined configuration as YAML | ||
| render_preview(engine_blocks, settings_block) | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.