Ask HPCC4J KB #1
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
| name: Ask HPCC4J KB | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| agent: | |
| description: "AI agent to run" | |
| type: choice | |
| options: | |
| - chroma-release # Preferred: use prebuilt embeddings (embeddings-latest) | |
| - rebuild-from-index # Fallback: rebuild embeddings from kb-latest index.jsonl | |
| default: chroma-release | |
| question: | |
| description: "Your question" | |
| type: string | |
| required: true | |
| top_k: | |
| description: "How many chunks to retrieve" | |
| type: number | |
| default: 5 | |
| model: | |
| description: "Embedding model (only used by rebuild-from-index)" | |
| type: string | |
| default: sentence-transformers/all-MiniLM-L6-v2 | |
| permissions: | |
| contents: read | |
| env: | |
| # Collection name used in both agents (manifest may override for chroma-release) | |
| KB_COLLECTION: hpcckb | |
| jobs: | |
| ask: | |
| name: Run AI Agent (${{ inputs.agent }}) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout (no submodules needed) | |
| uses: actions/checkout@v4 | |
| - name: Setup Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install runtime deps | |
| run: | | |
| set -euo pipefail | |
| python -m pip install --upgrade pip | |
| pip install chromadb sentence-transformers tqdm pyyaml requests | |
| - name: Prepare scripts | |
| run: | | |
| set -euo pipefail | |
| mkdir -p dist | |
| echo "Using pre-created Python scripts in .github/scripts/ai/" | |
| - name: Run agent (chroma-release) | |
| if: ${{ inputs.agent == 'chroma-release' }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| mkdir -p .artifacts | |
| echo "Downloading embeddings_chroma.tgz from embeddings-latest..." | |
| gh release download embeddings-latest --pattern "embeddings_chroma.tgz" --dir .artifacts | |
| tar -xzf .artifacts/embeddings_chroma.tgz | |
| test -f .kb_index/MANIFEST.json || echo "::warning :: MANIFEST.json not found under .kb_index" | |
| python .github/scripts/ai/agent_chroma_release.py \ | |
| --db ".kb_index" \ | |
| --collection "${KB_COLLECTION}" \ | |
| --question "${{ inputs.question }}" \ | |
| --top-k "${{ inputs.top_k }}" | |
| - name: Run agent (rebuild-from-index) | |
| if: ${{ inputs.agent == 'rebuild-from-index' }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| mkdir -p .kb_index_enhanced | |
| echo "Downloading index.jsonl from kb-latest..." | |
| gh release download kb-latest --pattern "index.jsonl" --dir .kb_index_enhanced | |
| test -f .kb_index_enhanced/index.jsonl | |
| python .github/scripts/ai/agent_from_index.py \ | |
| --index ".kb_index_enhanced/index.jsonl" \ | |
| --persist ".kb_index_ephemeral" \ | |
| --collection "${KB_COLLECTION}" \ | |
| --model "${{ inputs.model }}" \ | |
| --batch-size 256 \ | |
| --question "${{ inputs.question }}" \ | |
| --top-k "${{ inputs.top_k }}" | |
| - name: Upload answer | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: kb-answer-${{ github.run_id }} | |
| path: dist/answer.md | |
| retention-days: 14 |