Skip to content
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

refactor: introduce attribute namespace for AsTool #89

Merged
merged 1 commit into from
Oct 2, 2024
Merged
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 src/Exception/InvalidToolImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PhpLlm\LlmChain\Exception;

use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;

final class InvalidToolImplementation extends \InvalidArgumentException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace PhpLlm\LlmChain\ToolBox;
namespace PhpLlm\LlmChain\ToolBox\Attribute;

#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
final readonly class AsTool
Expand Down
2 changes: 1 addition & 1 deletion src/ToolBox/Tool/Clock.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PhpLlm\LlmChain\ToolBox\Tool;

use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;
use Symfony\Component\Clock\ClockInterface;

#[AsTool('clock', description: 'Provides the current date and time.')]
Expand Down
2 changes: 1 addition & 1 deletion src/ToolBox/Tool/OpenMeteo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PhpLlm\LlmChain\ToolBox\Tool;

use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;
use Symfony\Contracts\HttpClient\HttpClientInterface;

#[AsTool(name: 'weather', description: 'get the current weather for a location')]
Expand Down
2 changes: 1 addition & 1 deletion src/ToolBox/Tool/SerpApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PhpLlm\LlmChain\ToolBox\Tool;

use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;
use Symfony\Contracts\HttpClient\HttpClientInterface;

#[AsTool(name: 'serpapi', description: 'search for information on the internet')]
Expand Down
2 changes: 1 addition & 1 deletion src/ToolBox/Tool/SimilaritySearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use PhpLlm\LlmChain\Document\Document;
use PhpLlm\LlmChain\EmbeddingsModel;
use PhpLlm\LlmChain\Store\VectorStoreInterface;
use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;

#[AsTool('similarity_search', description: 'Searches for documents similar to a query or sentence.')]
final class SimilaritySearch
Expand Down
2 changes: 1 addition & 1 deletion src/ToolBox/Tool/Wikipedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PhpLlm\LlmChain\ToolBox\Tool;

use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;
use Symfony\Contracts\HttpClient\HttpClientInterface;

#[AsTool('wikipedia_search', description: 'Searches Wikipedia for a given query', method: 'search')]
Expand Down
2 changes: 1 addition & 1 deletion src/ToolBox/Tool/YouTubeTranscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PhpLlm\LlmChain\ToolBox\Tool;

use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;
use Symfony\Component\CssSelector\CssSelectorConverter;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Contracts\HttpClient\HttpClientInterface;
Expand Down
1 change: 1 addition & 0 deletions src/ToolBox/ToolAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace PhpLlm\LlmChain\ToolBox;

use PhpLlm\LlmChain\Exception\InvalidToolImplementation;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;

final readonly class ToolAnalyzer
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ToolBox/ParameterAnalyzerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PhpLlm\LlmChain\Tests\ToolBox\Tool\ToolOptionalParam;
use PhpLlm\LlmChain\Tests\ToolBox\Tool\ToolRequiredParams;
use PhpLlm\LlmChain\Tests\ToolBox\Tool\ToolWithToolParameterAttribute;
use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;
use PhpLlm\LlmChain\ToolBox\Metadata;
use PhpLlm\LlmChain\ToolBox\ParameterAnalyzer;
use PHPUnit\Framework\Attributes\CoversClass;
Expand Down
2 changes: 1 addition & 1 deletion tests/ToolBox/Tool/ToolMultiple.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PhpLlm\LlmChain\Tests\ToolBox\Tool;

use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;

#[AsTool('tool_hello_world', 'Function to say hello', method: 'hello')]
#[AsTool('tool_required_params', 'Function to say a number', method: 'bar')]
Expand Down
2 changes: 1 addition & 1 deletion tests/ToolBox/Tool/ToolNoParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PhpLlm\LlmChain\Tests\ToolBox\Tool;

use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;

#[AsTool('tool_no_params', 'A tool without parameters')]
final class ToolNoParams
Expand Down
2 changes: 1 addition & 1 deletion tests/ToolBox/Tool/ToolOptionalParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PhpLlm\LlmChain\Tests\ToolBox\Tool;

use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;

#[AsTool('tool_optional_param', 'A tool with one optional parameter', method: 'bar')]
final class ToolOptionalParam
Expand Down
2 changes: 1 addition & 1 deletion tests/ToolBox/Tool/ToolRequiredParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PhpLlm\LlmChain\Tests\ToolBox\Tool;

use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;

#[AsTool('tool_required_params', 'A tool with required parameters', method: 'bar')]
final class ToolRequiredParams
Expand Down
2 changes: 1 addition & 1 deletion tests/ToolBox/Tool/ToolWithToolParameterAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PhpLlm\LlmChain\Tests\ToolBox\Tool;

use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\ToolParameter;

#[AsTool('tool_with_ToolParameter_attribute', 'A tool which has a parameter with described with #[ToolParameter] attribute')]
Expand Down
2 changes: 1 addition & 1 deletion tests/ToolBox/ToolAnalyzerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PhpLlm\LlmChain\Tests\ToolBox\Tool\ToolMultiple;
use PhpLlm\LlmChain\Tests\ToolBox\Tool\ToolRequiredParams;
use PhpLlm\LlmChain\Tests\ToolBox\Tool\ToolWrong;
use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;
use PhpLlm\LlmChain\ToolBox\Metadata;
use PhpLlm\LlmChain\ToolBox\ParameterAnalyzer;
use PhpLlm\LlmChain\ToolBox\ToolAnalyzer;
Expand Down
2 changes: 1 addition & 1 deletion tests/ToolBox/ToolBoxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PhpLlm\LlmChain\Tests\ToolBox\Tool\ToolNoParams;
use PhpLlm\LlmChain\Tests\ToolBox\Tool\ToolOptionalParam;
use PhpLlm\LlmChain\Tests\ToolBox\Tool\ToolRequiredParams;
use PhpLlm\LlmChain\ToolBox\AsTool;
use PhpLlm\LlmChain\ToolBox\Attribute\AsTool;
use PhpLlm\LlmChain\ToolBox\Metadata;
use PhpLlm\LlmChain\ToolBox\ParameterAnalyzer;
use PhpLlm\LlmChain\ToolBox\ToolAnalyzer;
Expand Down