Skip to content

Commit b12ffa0

Browse files
RheagalFirejulian-rischclaude
authored
feat: add LiteLLM integration with LiteLLMChatGenerator component (#3257)
Co-authored-by: Julian Risch <julian.risch@deepset.ai> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0c57491 commit b12ffa0

13 files changed

Lines changed: 1253 additions & 0 deletions

File tree

.github/labeler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ integration:libreoffice:
178178
- any-glob-to-any-file: "integrations/libreoffice/**/*"
179179
- any-glob-to-any-file: ".github/workflows/libreoffice.yml"
180180

181+
integration:litellm:
182+
- changed-files:
183+
- any-glob-to-any-file: "integrations/litellm/**/*"
184+
- any-glob-to-any-file: ".github/workflows/litellm.yml"
185+
181186
integration:markitdown:
182187
- changed-files:
183188
- any-glob-to-any-file: "integrations/markitdown/**/*"

.github/workflows/litellm.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# This workflow comes from https://github.com/ofek/hatch-mypyc
2+
# https://github.com/ofek/hatch-mypyc/blob/5a198c0ba8660494d02716cfc9d79ce4adfb1442/.github/workflows/test.yml
3+
name: Test / litellm
4+
5+
on:
6+
schedule:
7+
- cron: "0 0 * * *"
8+
pull_request:
9+
paths:
10+
- "integrations/litellm/**"
11+
- "!integrations/litellm/*.md"
12+
- ".github/workflows/litellm.yml"
13+
push:
14+
branches:
15+
- main
16+
paths:
17+
- "integrations/litellm/**"
18+
- "!integrations/litellm/*.md"
19+
- ".github/workflows/litellm.yml"
20+
21+
defaults:
22+
run:
23+
working-directory: integrations/litellm
24+
25+
concurrency:
26+
group: litellm-${{ github.head_ref || github.sha }}
27+
cancel-in-progress: true
28+
29+
env:
30+
PYTHONUNBUFFERED: "1"
31+
FORCE_COLOR: "1"
32+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
33+
TEST_MATRIX_OS: '["ubuntu-latest", "windows-latest", "macos-latest"]'
34+
TEST_MATRIX_PYTHON: '["3.10", "3.14"]'
35+
36+
jobs:
37+
compute-test-matrix:
38+
runs-on: ubuntu-slim
39+
defaults:
40+
run:
41+
working-directory: .
42+
outputs:
43+
os: ${{ steps.set.outputs.os }}
44+
python-version: ${{ steps.set.outputs.python-version }}
45+
steps:
46+
- id: set
47+
run: |
48+
echo 'os=${{ github.event_name == 'push' && '["ubuntu-latest"]' || env.TEST_MATRIX_OS }}' >> "$GITHUB_OUTPUT"
49+
echo 'python-version=${{ github.event_name == 'push' && '["3.10"]' || env.TEST_MATRIX_PYTHON }}' >> "$GITHUB_OUTPUT"
50+
51+
run:
52+
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
53+
needs: compute-test-matrix
54+
permissions:
55+
contents: write
56+
pull-requests: write
57+
runs-on: ${{ matrix.os }}
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
os: ${{ fromJSON(needs.compute-test-matrix.outputs.os) }}
62+
python-version: ${{ fromJSON(needs.compute-test-matrix.outputs.python-version) }}
63+
64+
steps:
65+
- name: Support longpaths
66+
if: matrix.os == 'windows-latest'
67+
working-directory: .
68+
run: git config --system core.longpaths true
69+
70+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
71+
72+
- name: Set up Python ${{ matrix.python-version }}
73+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
74+
with:
75+
python-version: ${{ matrix.python-version }}
76+
77+
- name: Install Hatch
78+
run: |
79+
python -m pip install --upgrade pip
80+
pip install hatch --uploaded-prior-to=P1D
81+
82+
- name: Lint
83+
if: matrix.python-version == '3.10' && runner.os == 'Linux'
84+
run: hatch run fmt-check && hatch run test:types
85+
86+
- name: Run unit tests
87+
run: hatch run test:unit-cov-retry
88+
89+
# On PR: posts coverage comment (directly on same-repo PRs; via artifact for fork PRs). On push to main: stores coverage baseline on data branch.
90+
- name: Store unit tests coverage
91+
id: coverage_comment
92+
if: matrix.python-version == '3.10' && runner.os == 'Linux' && github.event_name != 'schedule'
93+
uses: py-cov-action/python-coverage-comment-action@63f52f4fbbffada6e8dee8ec432de7e01df9ba79 # v3.41
94+
with:
95+
GITHUB_TOKEN: ${{ github.token }}
96+
COVERAGE_PATH: integrations/litellm
97+
SUBPROJECT_ID: litellm
98+
MINIMUM_GREEN: 90
99+
MINIMUM_ORANGE: 60
100+
101+
- name: Upload coverage comment to be posted
102+
if: matrix.python-version == '3.10' && runner.os == 'Linux' && github.event_name == 'pull_request' && steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
103+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
104+
with:
105+
name: coverage-comment-litellm
106+
path: python-coverage-comment-action-litellm.txt
107+
108+
- name: Run integration tests
109+
run: hatch run test:integration-cov-append-retry
110+
111+
- name: Store combined coverage
112+
if: github.event_name == 'push'
113+
uses: py-cov-action/python-coverage-comment-action@63f52f4fbbffada6e8dee8ec432de7e01df9ba79 # v3.41
114+
with:
115+
GITHUB_TOKEN: ${{ github.token }}
116+
COVERAGE_PATH: integrations/litellm
117+
SUBPROJECT_ID: litellm-combined
118+
MINIMUM_GREEN: 90
119+
MINIMUM_ORANGE: 60
120+
121+
- name: Run unit tests with lowest direct dependencies
122+
if: github.event_name != 'push'
123+
run: |
124+
hatch run uv pip compile pyproject.toml --resolution lowest-direct --output-file requirements_lowest_direct.txt
125+
hatch -e test env run -- uv pip install -r requirements_lowest_direct.txt
126+
hatch run test:unit
127+
128+
- name: Nightly - run tests with Haystack main branch
129+
if: github.event_name == 'schedule'
130+
run: |
131+
hatch env prune
132+
hatch -e test env run -- uv pip install git+https://github.com/deepset-ai/haystack.git@main
133+
hatch run test:unit-cov-retry
134+
135+
notify-slack-on-failure:
136+
needs: run
137+
if: failure() && github.event_name == 'schedule'
138+
runs-on: ubuntu-slim
139+
steps:
140+
- uses: deepset-ai/notify-slack-action@3cda73b77a148f16f703274198e7771340cf862b # v1
141+
with:
142+
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL_NOTIFICATIONS }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Please check out our [Contribution Guidelines](CONTRIBUTING.md) for all the deta
6161
| [langfuse-haystack](integrations/langfuse/) | Tracer | [![PyPI - Version](https://img.shields.io/pypi/v/langfuse-haystack.svg?color=orange)](https://pypi.org/project/langfuse-haystack) | [![Test / langfuse](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/langfuse.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/langfuse.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-langfuse/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-langfuse/htmlcov/index.html) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-langfuse-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-langfuse-combined/htmlcov/index.html) |
6262
| [lara-haystack](integrations/lara/) | Translator | [![PyPI - Version](https://img.shields.io/pypi/v/lara-haystack.svg)](https://pypi.org/project/lara-haystack) | [![Test / lara](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/lara.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/lara.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-lara/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-lara/htmlcov/index.html) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-lara-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-lara-combined/htmlcov/index.html) |
6363
| [libreoffice-haystack](integrations/libreoffice/) | Converter | [![PyPI - Version](https://img.shields.io/pypi/v/libreoffice-haystack.svg)](https://pypi.org/project/libreoffice-haystack) | [![Test / libreoffice](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/libreoffice.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/libreoffice.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-libreoffice/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-libreoffice/htmlcov/index.html) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-libreoffice-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-libreoffice-combined/htmlcov/index.html) |
64+
| [litellm-haystack](integrations/litellm/) | Generator | [![PyPI - Version](https://img.shields.io/pypi/v/litellm-haystack.svg)](https://pypi.org/project/litellm-haystack) | [![Test / litellm](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/litellm.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/litellm.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-litellm/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-litellm/htmlcov/index.html) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-litellm-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-litellm-combined/htmlcov/index.html) |
6465
| [llama-cpp-haystack](integrations/llama_cpp/) | Generator | [![PyPI - Version](https://img.shields.io/pypi/v/llama-cpp-haystack.svg?color=orange)](https://pypi.org/project/llama-cpp-haystack) | [![Test / llama-cpp](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/llama_cpp.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/llama_cpp.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-llama_cpp/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-llama_cpp/htmlcov/index.html) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-llama_cpp-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-llama_cpp-combined/htmlcov/index.html) |
6566
| [llama-stack-haystack](integrations/llama_stack/) | Generator | [![PyPI - Version](https://img.shields.io/pypi/v/llama-stack-haystack.svg?color=orange)](https://pypi.org/project/llama-stack-haystack) | [![Test / llama-stack](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/llama_stack.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/llama_stack.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-llama_stack/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-llama_stack/htmlcov/index.html) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-llama_stack-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-llama_stack-combined/htmlcov/index.html) |
6667
| [markitdown-haystack](integrations/markitdown/) | Converter | [![PyPI - Version](https://img.shields.io/pypi/v/markitdown-haystack.svg)](https://pypi.org/project/markitdown-haystack) | [![Test / markitdown](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/markitdown.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/markitdown.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-markitdown/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-markitdown/htmlcov/index.html) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-markitdown-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-markitdown-combined/htmlcov/index.html) |

0 commit comments

Comments
 (0)