Skip to content

Commit 9d93d0f

Browse files
feat(brave): add BraveWebSearch integration (#3237)
Co-authored-by: anakin87 <stefanofiorucci@gmail.com>
1 parent 289987e commit 9d93d0f

13 files changed

Lines changed: 955 additions & 0 deletions

File tree

.github/labeler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ integration:astra:
3434
- any-glob-to-any-file: "integrations/astra/**/*"
3535
- any-glob-to-any-file: ".github/workflows/astra.yml"
3636

37+
integration:brave:
38+
- changed-files:
39+
- any-glob-to-any-file: "integrations/brave/**/*"
40+
- any-glob-to-any-file: ".github/workflows/brave.yml"
41+
3742
integration:azure-ai-search:
3843
- changed-files:
3944
- any-glob-to-any-file: "integrations/azure_ai_search/**/*"

.github/workflows/CI_coverage_comment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
- "Test / anthropic"
1010
- "Test / arcadedb"
1111
- "Test / astra"
12+
- "Test / brave"
1213
- "Test / azure_ai_search"
1314
- "Test / azure_doc_intelligence"
1415
- "Test / chonkie"

.github/workflows/brave.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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 / brave
4+
5+
on:
6+
schedule:
7+
- cron: "0 0 * * *"
8+
pull_request:
9+
paths:
10+
- "integrations/brave/**"
11+
- "!integrations/brave/*.md"
12+
- ".github/workflows/brave.yml"
13+
push:
14+
branches:
15+
- main
16+
paths:
17+
- "integrations/brave/**"
18+
- "!integrations/brave/*.md"
19+
- ".github/workflows/brave.yml"
20+
21+
defaults:
22+
run:
23+
working-directory: integrations/brave
24+
25+
concurrency:
26+
group: brave-${{ github.head_ref || github.sha }}
27+
cancel-in-progress: true
28+
29+
env:
30+
PYTHONUNBUFFERED: "1"
31+
FORCE_COLOR: "1"
32+
BRAVE_API_KEY: ${{ secrets.BRAVE_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: pip install hatch
79+
80+
- name: Lint
81+
if: matrix.python-version == '3.10' && runner.os == 'Linux'
82+
run: hatch run fmt-check && hatch run test:types
83+
84+
- name: Run unit tests
85+
run: hatch run test:unit-cov-retry
86+
87+
# 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.
88+
- name: Store unit tests coverage
89+
id: coverage_comment
90+
if: matrix.python-version == '3.10' && runner.os == 'Linux' && github.event_name != 'schedule'
91+
uses: py-cov-action/python-coverage-comment-action@63f52f4fbbffada6e8dee8ec432de7e01df9ba79 # v3.41
92+
with:
93+
GITHUB_TOKEN: ${{ github.token }}
94+
COVERAGE_PATH: integrations/brave
95+
SUBPROJECT_ID: brave
96+
MINIMUM_GREEN: 90
97+
MINIMUM_ORANGE: 60
98+
99+
- name: Upload coverage comment to be posted
100+
if: matrix.python-version == '3.10' && runner.os == 'Linux' && github.event_name == 'pull_request' && steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
101+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
102+
with:
103+
name: coverage-comment-brave
104+
path: python-coverage-comment-action-brave.txt
105+
106+
- name: Run integration tests
107+
run: hatch run test:integration-cov-append-retry
108+
109+
- name: Store combined coverage
110+
if: github.event_name == 'push'
111+
uses: py-cov-action/python-coverage-comment-action@63f52f4fbbffada6e8dee8ec432de7e01df9ba79 # v3.41
112+
with:
113+
GITHUB_TOKEN: ${{ github.token }}
114+
COVERAGE_PATH: integrations/brave
115+
SUBPROJECT_ID: brave-combined
116+
MINIMUM_GREEN: 90
117+
MINIMUM_ORANGE: 60
118+
119+
- name: Run unit tests with lowest direct dependencies
120+
if: github.event_name != 'push'
121+
run: |
122+
hatch run uv pip compile pyproject.toml --resolution lowest-direct --output-file requirements_lowest_direct.txt
123+
hatch -e test env run -- uv pip install -r requirements_lowest_direct.txt
124+
hatch run test:unit
125+
126+
- name: Nightly - run tests with Haystack main branch
127+
if: github.event_name == 'schedule'
128+
run: |
129+
hatch env prune
130+
hatch -e test env run -- uv pip install git+https://github.com/deepset-ai/haystack.git@main
131+
hatch run test:unit-cov-retry
132+
hatch run test:integration-cov-append-retry
133+
134+
notify-slack-on-failure:
135+
needs: run
136+
if: failure() && github.event_name == 'schedule'
137+
runs-on: ubuntu-slim
138+
steps:
139+
- uses: deepset-ai/notify-slack-action@3cda73b77a148f16f703274198e7771340cf862b # v1
140+
with:
141+
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL_NOTIFICATIONS }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Please check out our [Contribution Guidelines](CONTRIBUTING.md) for all the deta
3434
| [astra-haystack](integrations/astra/) | Document Store | [![PyPI - Version](https://img.shields.io/pypi/v/astra-haystack.svg)](https://pypi.org/project/astra-haystack) | [![Test / astra](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/astra.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/astra.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-astra/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-astra/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-astra-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-astra-combined/htmlcov/index.html) |
3535
| [azure-ai-search-haystack](integrations/azure_ai_search/) | Document Store | [![PyPI - Version](https://img.shields.io/pypi/v/azure-ai-search-haystack.svg)](https://pypi.org/project/azure-ai-search-haystack) | [![Test / azure-ai-search](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/azure_ai_search.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/azure_ai_search.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-azure_ai_search/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-azure_ai_search/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-azure_ai_search-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-azure_ai_search-combined/htmlcov/index.html) |
3636
| [azure-doc-intelligence-haystack](integrations/azure_doc_intelligence/) | Converter | [![PyPI - Version](https://img.shields.io/pypi/v/azure-doc-intelligence-haystack.svg)](https://pypi.org/project/azure-doc-intelligence-haystack) | [![Test / azure_doc_intelligence](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/azure_doc_intelligence.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/azure_doc_intelligence.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-azure_doc_intelligence/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-azure_doc_intelligence/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-azure_doc_intelligence-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-azure_doc_intelligence-combined/htmlcov/index.html) |
37+
| [brave-search-haystack](integrations/brave/) | Web Search | [![PyPI - Version](https://img.shields.io/pypi/v/brave-search-haystack.svg)](https://pypi.org/project/brave-search-haystack) | [![Test / brave](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/brave.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/brave.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-brave/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-brave/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-brave-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-brave-combined/htmlcov/index.html) |
3738
| [chonkie-haystack](integrations/chonkie/) | Preprocessor | [![PyPI - Version](https://img.shields.io/pypi/v/chonkie-haystack.svg)](https://pypi.org/project/chonkie-haystack) | [![Test / chonkie](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/chonkie.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/chonkie.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-chonkie/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-chonkie/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-chonkie-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-chonkie-combined/htmlcov/index.html) |
3839
| [chroma-haystack](integrations/chroma/) | Document Store | [![PyPI - Version](https://img.shields.io/pypi/v/chroma-haystack.svg)](https://pypi.org/project/chroma-haystack) | [![Test / chroma](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/chroma.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/chroma.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-chroma/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-chroma/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-chroma-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-chroma-combined/htmlcov/index.html) |
3940
| [cohere-haystack](integrations/cohere/) | Embedder, Generator, Ranker | [![PyPI - Version](https://img.shields.io/pypi/v/cohere-haystack.svg)](https://pypi.org/project/cohere-haystack) | [![Test / cohere](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/cohere.yml/badge.svg)](https://github.com/deepset-ai/haystack-core-integrations/actions/workflows/cohere.yml) | [![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/deepset-ai/haystack-core-integrations/python-coverage-comment-action-data-cohere/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-cohere/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-cohere-combined/endpoint.json&label=)](https://htmlpreview.github.io/?https://github.com/deepset-ai/haystack-core-integrations/blob/python-coverage-comment-action-data-cohere-combined/htmlcov/index.html) |

0 commit comments

Comments
 (0)