Skip to content

Commit

Permalink
ci: build api reference of langchain (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoloboschi authored Apr 10, 2024
1 parent fd57dce commit 2033246
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
36 changes: 36 additions & 0 deletions .github/actions/deploy-api-reference/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and deploy API reference
description: Build and deploy API reference

inputs:
ragstack-version:
required: true
description: "RAGStack version"
runs:
using: "composite"
steps:
- name: Configure Git
shell: bash
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Generate API reference
shell: bash
run: |
set -e
./scripts/generate-api-reference.sh "${{ inputs.ragstack-version }}"
mv dist/api_reference /tmp/api_reference
git fetch origin
git checkout gh-pages
ls -la /tmp/api_reference/${{ inputs.ragstack-version }}/langchain
mkdir -p api_reference/${{ inputs.ragstack-version }}
mv /tmp/api_reference/${{ inputs.ragstack-version }}/langchain api_reference/${{ inputs.ragstack-version }}/langchain
if [ -z "$(git status --porcelain)" ]; then
echo "Git directory is clean, nothing changed"
git status
exit 0
fi
git add -A
git commit -m "Update api reference"
git pull --rebase origin gh-pages
git push origin gh-pages
5 changes: 4 additions & 1 deletion .github/workflows/release-ragstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ jobs:
run: |
echo "release-number=$(echo ${{ github.ref }} | sed -e 's/refs\/tags\/ragstack-ai-ts-//')" >> $GITHUB_OUTPUT
# TODO: build docker image
- name: Update API reference
uses: ./.github/actions/deploy-api-reference
with:
ragstack-version: ${{ steps.release-number.outputs.release-number }}
30 changes: 30 additions & 0 deletions scripts/generate-api-reference.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -e

here=$(pwd)
ragstack_version=$1
if [ -z "$ragstack_version" ]; then
echo "Usage: $0 <ragstack_version>"
exit 1
fi

langchain_version=$(curl -Ls "https://registry.npmjs.org/@datastax/ragstack-ai-ts/${ragstack_version}" | jq -r '.dependencies.langchain')
echo "langchain_version: $langchain_version"

clone_lc() {
rm -rf /tmp/lc
git clone https://github.com/langchain-ai/langchainjs.git --branch ${langchain_version} --depth 1 /tmp/lc
}
clone_lc
cd /tmp/lc/docs/api_refs
yarn install
yarn build

ls -la public

mkdir -p $here/dist
mkdir -p $here/dist/api_reference
mkdir -p $here/dist/api_reference/$ragstack_version
mkdir -p $here/dist/api_reference/$ragstack_version/langchain
cp -r public/* $here/dist/api_reference/$ragstack_version/langchain

0 comments on commit 2033246

Please sign in to comment.