Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion .github/build-packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Symfony\Component\Finder\Finder;

$finder = (new Finder())
->in([__DIR__.'/../src/*/'])
->in([__DIR__.'/../src/*/', __DIR__.'/../examples/', __DIR__.'/../demo/'])
->depth(0)
->name('composer.json')
;
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,18 @@ jobs:
- name: Build root packages
run: php .github/build-packages.php

- name: Link examples
working-directory: examples
run: ../link

- name: Install examples dependencies
uses: ramsey/composer-install@v3
with:
working-directory: examples

- name: Run PHPStan on examples
run: |
cd examples/ && $COMPOSER_UP && ../link && $PHPSTAN
working-directory: examples
run: $PHPSTAN

- name: Run PHPStan on packages
run: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ jobs:
- name: Install root dependencies
uses: ramsey/composer-install@v3

- name: Install examples dependencies
- name: Build root packages
run: php .github/build-packages.php

- name: Install root dependencies
uses: ramsey/composer-install@v3
with:
working-directory: examples

- name: Link examples
working-directory: examples
run: ../link

- name: Run commands examples
run: php examples/commands/stores.php
working-directory: examples
run: php commands/stores.php

demo:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions examples/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"symfony/ai-agent": "@dev",
"symfony/ai-platform": "@dev",
"symfony/ai-store": "@dev",
"symfony/ai-brave-tool": "@dev",
"symfony/cache": "^7.3|^8.0",
"symfony/console": "^7.3|^8.0",
"symfony/css-selector": "^7.3|^8.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/toolbox/brave.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*/

use Symfony\AI\Agent\Agent;
use Symfony\AI\Agent\Bridge\Brave\Brave;
use Symfony\AI\Agent\Toolbox\AgentProcessor;
use Symfony\AI\Agent\Toolbox\Tool\Brave;
use Symfony\AI\Agent\Toolbox\Tool\Crawler;
use Symfony\AI\Agent\Toolbox\Toolbox;
use Symfony\AI\Platform\Bridge\OpenAi\Gpt;
Expand Down
5 changes: 4 additions & 1 deletion link
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ if (!is_dir("$pathToProject/vendor/symfony")) {
$sfPackages = array();

$filesystem = new Filesystem();
$directories = glob(__DIR__.'/src/*', GLOB_ONLYDIR | GLOB_NOSORT);
$braces = array('*', '*/src/Bridge/*');
$directories = array_merge(...array_values(array_map(function ($part) {
return glob(__DIR__.'/src/'.$part, GLOB_ONLYDIR | GLOB_NOSORT);
}, $braces)));

foreach ($directories as $dir) {
if ($filesystem->exists($composer = "$dir/composer.json")) {
Expand Down
3 changes: 3 additions & 0 deletions src/agent/src/Bridge/Brave/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.git* export-ignore
8 changes: 8 additions & 0 deletions src/agent/src/Bridge/Brave/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Please do not submit any Pull Requests here. They will be closed.
---

Please submit your PR here instead:
https://github.com/symfony/ai

This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
20 changes: 20 additions & 0 deletions src/agent/src/Bridge/Brave/.github/close-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Close Pull Request

on:
pull_request_target:
types: [opened]

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Thanks for your Pull Request! We love contributions.

However, you should instead open your PR on the main repository:
https://github.com/symfony/ai

This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
4 changes: 4 additions & 0 deletions src/agent/src/Bridge/Brave/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor/
composer.lock
phpunit.xml
.phpunit.result.cache
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\AI\Agent\Toolbox\Tool;
namespace Symfony\AI\Agent\Bridge\Brave;

use Symfony\AI\Agent\Toolbox\Attribute\AsTool;
use Symfony\AI\Platform\Contract\JsonSchema\Attribute\With;
Expand Down
7 changes: 7 additions & 0 deletions src/agent/src/Bridge/Brave/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CHANGELOG
=========

0.1
---

* Add the bridge
19 changes: 19 additions & 0 deletions src/agent/src/Bridge/Brave/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2025-present Fabien Potencier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@
* file that was distributed with this source code.
*/

namespace Symfony\AI\Agent\Tests\Toolbox\Tool;
namespace Symfony\AI\Agent\Bridge\Brave\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\AI\Agent\Toolbox\Tool\Brave;
use Symfony\AI\Agent\Bridge\Brave\Brave;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\JsonMockResponse;
use Symfony\Component\HttpClient\Response\MockResponse;

final class BraveTest extends TestCase
{
public function testReturnsSearchResults()
{
$result = JsonMockResponse::fromFile(__DIR__.'/../../fixtures/Tool/brave.json');
$result = JsonMockResponse::fromFile(__DIR__.'/fixtures/search-results.json');
$httpClient = new MockHttpClient($result);
$brave = new Brave($httpClient, 'test-api-key');

Expand All @@ -38,7 +37,7 @@ public function testReturnsSearchResults()

public function testPassesCorrectParametersToApi()
{
$result = JsonMockResponse::fromFile(__DIR__.'/../../fixtures/Tool/brave.json');
$result = JsonMockResponse::fromFile(__DIR__.'/fixtures/search-results.json');
$httpClient = new MockHttpClient($result);
$brave = new Brave($httpClient, 'test-api-key', ['extra' => 'option']);

Expand All @@ -52,13 +51,13 @@ public function testPassesCorrectParametersToApi()

$requestOptions = $result->getRequestOptions();
$this->assertArrayHasKey('headers', $requestOptions);
$this->assertIsArray($requestOptions['headers']);
$this->assertContains('X-Subscription-Token: test-api-key', $requestOptions['headers']);
}

public function testHandlesEmptyResults()
{
$result = new MockResponse(json_encode(['web' => ['results' => []]]));
$httpClient = new MockHttpClient($result);
$httpClient = new MockHttpClient(new JsonMockResponse(['web' => ['results' => []]]));
$brave = new Brave($httpClient, 'test-api-key');

$results = $brave('this should return nothing');
Expand Down
53 changes: 53 additions & 0 deletions src/agent/src/Bridge/Brave/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "symfony/ai-brave-tool",
"description": "Brave Search AI tool bridge for Symfony applications.",
"license": "MIT",
"type": "library",
"keywords": [
"ai",
"bridge",
"brave",
"agent",
"tool"
],
"authors": [
{
"name": "Christopher Hertel",
"email": "[email protected]"
},
{
"name": "Oskar Stark",
"email": "[email protected]"
}
],
"require": {
"php": ">=8.2",
"symfony/ai-agent": "@dev",
"symfony/http-client": "^7.3|^8.0"
},
"require-dev": {
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^11.5.13"
},
"autoload": {
"psr-4": {
"Symfony\\AI\\Agent\\Bridge\\Brave\\": ""
}
},
"autoload-dev": {
"psr-4": {
"Symfony\\AI\\Agent\\Bridge\\Brave\\Tests\\": "Tests/"
}
},
"config": {
"sort-packages": true
},
"extra": {
"thanks": {
"name": "symfony/ai",
"url": "https://github.com/symfony/ai"
}
},
"minimum-stability": "dev"
}
16 changes: 16 additions & 0 deletions src/agent/src/Bridge/Brave/phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
includes:
- ../../../../../.phpstan/extension.neon

parameters:
level: max
paths:
- .
excludePaths:
- vendor/
- Tests/fixtures/
ignoreErrors:
-
message: "#^Method .*::test.*\\(\\) has no return type specified\\.$#"
-
identifier: missingType.iterableValue
path: Tests/*
32 changes: 32 additions & 0 deletions src/agent/src/Bridge/Brave/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
failOnDeprecation="true"
failOnRisky="true"
failOnWarning="true"
>
<php>
<ini name="error_reporting" value="-1" />
</php>

<testsuites>
<testsuite name="Symfony Brave AI Tool Test Suite">
<directory>./Tests/</directory>
</testsuite>
</testsuites>

<source ignoreSuppressionOfDeprecations="true">
<include>
<directory>./</directory>
</include>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</source>
</phpunit>
Loading