Skip to content

Add support for artifact in llama-index-server #580

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

Merged
merged 28 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
be4550f
support artifact
leehuwuj Apr 23, 2025
ba29391
migrate poetry to uv
leehuwuj Apr 23, 2025
629a179
fix ci
leehuwuj Apr 24, 2025
d787ecf
update ci
leehuwuj Apr 24, 2025
630a76d
Refactor artifact generation tools by introducing separate CodeGenera…
leehuwuj Apr 24, 2025
96d846f
enhance code
leehuwuj Apr 24, 2025
11fa3bc
remove previous content from tool input
leehuwuj Apr 24, 2025
f85e913
fix test
leehuwuj Apr 24, 2025
03ee8c3
bump chat ui
leehuwuj Apr 25, 2025
2b27ebd
revert changes
leehuwuj Apr 25, 2025
66636e5
remove dead code
leehuwuj Apr 25, 2025
ef56e1d
Add artifact workflows for code and document generation
leehuwuj Apr 25, 2025
322f43d
remove app_writer workflow
leehuwuj Apr 25, 2025
2c3ac6d
Refactor artifact workflow classes and UI event handling
leehuwuj Apr 25, 2025
f975b79
Use uv to release package
leehuwuj Apr 25, 2025
4fdfca5
Refactor artifact workflows and UI components
leehuwuj Apr 25, 2025
1ba5a26
move code
leehuwuj Apr 25, 2025
fbed55a
Merge remote-tracking branch 'origin/main' into lee/add-artifact
leehuwuj Apr 25, 2025
9e42cf3
Merge remote-tracking branch 'origin/main' into lee/add-artifact
leehuwuj Apr 25, 2025
872f238
sort artifact
leehuwuj Apr 25, 2025
e09de60
fix mypy
leehuwuj Apr 28, 2025
11ae75d
fix adding custom route does not work
leehuwuj Apr 28, 2025
51f70a9
fix mypy
leehuwuj Apr 28, 2025
830b3e5
revert create-llama change
leehuwuj Apr 28, 2025
484cb9c
disable e2e test for python package change
leehuwuj Apr 28, 2025
88af75c
fix missing set memory
leehuwuj Apr 28, 2025
6104c3d
remove include last artifact in the code
leehuwuj Apr 28, 2025
2f17cdc
Add ArtifactEvent model and update workflows to use it
leehuwuj Apr 28, 2025
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
2 changes: 2 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ on:
branches: [main]
paths-ignore:
- "python/llama-index-server/**"
- ".github/workflows/*llama_index_server.yml"
pull_request:
branches: [main]
paths-ignore:
- "python/llama-index-server/**"
- ".github/workflows/*llama_index_server.yml"

jobs:
e2e-python:
Expand Down
52 changes: 30 additions & 22 deletions .github/workflows/release_llama_index_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,46 @@ jobs:
working-directory: ./python/llama-index-server
if: |
github.event_name == 'push' &&
!startsWith(github.ref, 'refs/heads/release/llama-index-server-v')
!startsWith(github.ref, 'refs/heads/release/llama-index-server-v') &&
!contains(github.event.head_commit.message, 'Release: llama-index-server v')

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -

- name: Install dependencies
run: poetry install
shell: bash
run: uv sync --all-extras --dev

- name: Setup Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

- name: Bump patch version
shell: bash
run: |
poetry version patch
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version | awk -F. '{$NF = $NF + 1;}1' OFS=.)
git add pyproject.toml
git commit -m "chore(release): bump version to $(poetry version -s)"
git commit -m "chore(release): bump llama-index-server version to $(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version)"

- name: Get current version
id: get_version
shell: bash
run: |
version=$(poetry version -s)
version=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version)
echo "current_version=${version}" >> "$GITHUB_OUTPUT"

- name: Create Release PR
Expand Down Expand Up @@ -91,31 +96,34 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -

- name: Install dependencies
run: poetry install
shell: bash
run: uv sync --all-extras

- name: Get current version
id: get_version
shell: bash
run: |
version=$(poetry version -s)
version=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version)
echo "current_version=${version}" >> "$GITHUB_OUTPUT"

- name: Build and publish to PyPI
uses: JRubics/[email protected]
with:
python_version: "3.11"
pypi_token: ${{ secrets.PYPI_TOKEN }}
package_directory: "python/llama-index-server"
poetry_install_options: "--without dev"
- name: Build package
shell: bash
run: uv build --no-sources

- name: Publish to PyPI
shell: bash
run: uv publish --token ${{ secrets.PYPI_TOKEN }}

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
Expand Down
62 changes: 25 additions & 37 deletions .github/workflows/test_llama_index_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
pull_request:

env:
POETRY_VERSION: "1.8.3"
PYTHON_VERSION: "3.9"

jobs:
Expand All @@ -21,29 +20,23 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"

- name: Configure Poetry
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry env use python

- name: Install dependencies
shell: bash
run: poetry install --with dev
run: uv sync --all-extras --dev

- name: Run unit tests
shell: bash
run: |
poetry run pytest tests
run: uv run pytest tests

type-check:
name: Type Check
Expand All @@ -54,28 +47,23 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"

- name: Configure Poetry
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry env use python

- name: Install dependencies
shell: bash
run: poetry install --with dev
run: uv sync --all-extras --dev

- name: Run mypy
shell: bash
run: poetry run mypy llama_index
run: uv run mypy llama_index

build:
needs: [unit-test, type-check]
Expand All @@ -85,25 +73,25 @@ jobs:
working-directory: python/llama-index-server
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Clear python cache
shell: bash
run: poetry cache clear --all pypi
- name: Build package
shell: bash
run: poetry build
- name: Test installing built package

- name: Install build package
shell: bash
run: python -m pip install .
run: uv sync --all-extras

- name: Test import
shell: bash
working-directory: ${{ vars.RUNNER_TEMP }}
run: python -c "from llama_index.server import LlamaIndexServer"
run: uv run python -c "from llama_index.server import LlamaIndexServer"

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
Expand Down
24 changes: 24 additions & 0 deletions python/llama-index-server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Python files
**/__pycache__
**/build
**/dist
**/venv
**/env
**/llama-index-server.egg-info

# Jupyter files
**/*.ipynb

# Pytest files
**/pytest.ini
**/pytest.ini

# Pytest cache
**/pytest_cache

# Tools
**/.ruff_cache
**/.mypy_cache
**/.pylint.d
**/.pyrightconfig.json
**/.ui
52 changes: 52 additions & 0 deletions python/llama-index-server/examples/artifact/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Artifacts App

This guide explains how to set up and use the LlamaIndex server with the artifact workflow to write code or documents.

## Prerequisites

- [uv](https://github.com/astral-sh/uv) installed (a fast Python package manager and runner)
- An OpenAI API key

## Steps

1. **Set the OpenAI API Key**

Export your OpenAI API key as an environment variable:

```sh
export OPENAI_API_KEY=your_openai_api_key_here
```

2. **Run the Server Using uv**

Start the server with the following command:

```sh
uv run main.py
```

This will launch the FastAPI server using the workflow defined in `main.py`.

3. **Access the Application**

Open your browser and go to:

```
http://localhost:8000
```

You will see the LlamaIndex Artifact app UI, where you can interact with the workflow.

## Notes

- By default, the server uses the code artifact workflow. If you want to use the document artifact workflow, edit `main.py` and uncomment the following line:

```python
# from examples.artifact.document_workflow import ArtifactWorkflow
```

and comment out the code workflow import.

- The UI provides starter questions to help you get started, or you can enter your own requests.

- The workflow will guide you through planning and generating code or documents based on your input.
Loading
Loading