class SimilaritySearch implements Approvable, Tool, Transient

Traits

Properties

protected Approval|bool|null $approvalRequirement from  InteractsWithApprovals
protected string|null $description
protected bool $rerank
protected Closure|array|string|null $rerankBy
protected int|null $rerankLimit

Methods

requireApproval(string|null $reason = null)

Indicate that the tool requires approval before execution.

withoutApproval()

Indicate that the tool may execute without approval.

Approval|null
shouldRequestApproval(Request $request)

Determine whether the tool should request approval for the given request.

Approval|bool
needsApproval(Request $request)

Determine whether the tool needs approval for the given request.

__construct(Closure $using)

Create a new similarity search tool instance.

usingModel(string $model, string $column, float $minSimilarity = 0.6, int $limit = 15, Closure|null $query = null)

Create a new similarity search tool instance.

Stringable|string
description()

Get the description of the tool's purpose.

Stringable|string
handle(Request $request)

Execute the tool.

withDescription(string $description)

Set the tool's description.

rerank(Closure|array|string $by, int|null $limit = null)

Indicate that the results should be reranked.

array
schema(JsonSchema $schema)

Get the tool's schema definition.

Details

InteractsWithApprovals requireApproval(string|null $reason = null)

Indicate that the tool requires approval before execution.

Parameters

string|null $reason

Return Value

InteractsWithApprovals

InteractsWithApprovals withoutApproval()

Indicate that the tool may execute without approval.

Return Value

InteractsWithApprovals

Approval|null shouldRequestApproval(Request $request)

Determine whether the tool should request approval for the given request.

Parameters

Request $request

Return Value

Approval|null

at line 153
protected Approval|bool needsApproval(Request $request)

Determine whether the tool needs approval for the given request.

Parameters

Request $request

Return Value

Approval|bool

at line 34
__construct(Closure $using)

Create a new similarity search tool instance.

Parameters

Closure $using

at line 46
static SimilaritySearch usingModel(string $model, string $column, float $minSimilarity = 0.6, int $limit = 15, Closure|null $query = null)

Create a new similarity search tool instance.

Parameters

string $model
string $column
float $minSimilarity
int $limit
Closure|null $query

Return Value

SimilaritySearch

Exceptions

InvalidArgumentException

at line 81
Stringable|string description()

Get the description of the tool's purpose.

Return Value

Stringable|string

at line 89
Stringable|string handle(Request $request)

Execute the tool.

Parameters

Request $request

Return Value

Stringable|string

at line 118
SimilaritySearch withDescription(string $description)

Set the tool's description.

Parameters

string $description

Return Value

SimilaritySearch

at line 128
SimilaritySearch rerank(Closure|array|string $by, int|null $limit = null)

Indicate that the results should be reranked.

Parameters

Closure|array|string $by
int|null $limit

Return Value

SimilaritySearch

at line 140
array schema(JsonSchema $schema)

Get the tool's schema definition.

Parameters

JsonSchema $schema

Return Value

array