All skills
asyrafhussin avatar

/laravel-ai-sdk

@7221662

Laravel AI SDK for building AI-powered features. Use when creating agents, generating images or audio, working with embeddings, vector search, or testing AI features. Triggers on tasks involving laravel/ai, AI agents, tool-calling, structured output, streaming, embeddings, reranking, or AI faking in tests.

Use this Skill: https://skilld.dev/gh/asyrafhussin/agent-skills/laravel-ai-sdk

This session only. Nothing lands on disk.

rulesembed-rerank.md

≈574 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Rerank Documents by Relevance

Impact: MEDIUM (Improve search quality with semantic reranking)

Rerank search results using semantic understanding to surface the most relevant documents. Works with arrays, Eloquent collections, and closures.

Bad Example

// Relying solely on keyword matching — misses semantic relevance
$posts = Post::where('title', 'like', '%PHP%')
    ->orWhere('body', 'like', '%PHP%')
    ->orderBy('created_at', 'desc')
    ->get();
// "PHP frameworks" query returns all posts mentioning PHP, in wrong order

Good Example

// Rerank an array of strings
use Laravel\Ai\Reranking;

$response = Reranking::of([
    'Django is a Python web framework.',
    'Laravel is a PHP web application framework.',
    'React is a JavaScript library for building user interfaces.',
])->rerank('PHP frameworks');

$response->first()->document; // "Laravel is a PHP web application framework."
$response->first()->score;    // 0.95
$response->first()->index;    // 1 (original position)
// Limit results
$response = Reranking::of($documents)
    ->limit(5)
    ->rerank('search query');
// Rerank Eloquent collections — single field
$posts = Post::all()->rerank('body', 'Laravel tutorials');

// Multiple fields (sent as JSON)
$posts = Post::all()->rerank(['title', 'body'], 'Laravel tutorials');

// Custom closure to build the document string
$posts = Post::all()->rerank(
    fn ($post) => $post->title . ': ' . $post->body,
    'Laravel tutorials',
);
// Specify provider and limit
use Laravel\Ai\Enums\Lab;

$reranked = $posts->rerank(
    by: 'content',
    query: 'Laravel tutorials',
    limit: 10,
    provider: Lab::Cohere,
);

Why

  • Semantic relevance: Reranking understands meaning, not just keywords
  • Collection macro: Works directly on Eloquent collections — $posts->rerank(...)
  • Flexible input: Single field, multiple fields, or custom closure
  • Provider support: Cohere and Jina for reranking

Reference: Laravel AI SDK — Reranking

Source: SKILL.md on GitHub

1 warning16d4 checks · Risk MEDIUM
  • Gen Agent Trust Hub16d

    The skill provides a comprehensive guide for the Laravel AI SDK but contains deceptive metadata claiming authorship by the 'Laravel Community' despite being associated with the user 'asyrafhussin'. It also presents an indirect prompt injection surface by documenting patterns for ingesting untrusted data (such as transcripts and external URLs) while granting agents capabilities like file system storage and network access.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 7221662. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 7 months ago
Other metadata
metadata
{
  "author": "Laravel Community",
  "version": "1.0.0",
  "laravelVersion": "13.x",
  "phpVersion": "8.3+"
}

README badge

README badge for asyrafhussin/agent-skills/laravel-ai-sdk