1. Go to this page and download the library: Download thekiharani/laravel-aria library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
thekiharani / laravel-aria example snippets
use NoriaLabs\Aria\Contracts\KnowledgeSource;
use NoriaLabs\Aria\Knowledge\KnowledgeDocument;
class SiteKnowledge implements KnowledgeSource
{
public function documents(): iterable
{
foreach (config('lanes') as $lane) {
yield new KnowledgeDocument(
sourceType: 'lane',
sourceKey: $lane['slug'],
title: $lane['title'],
body: $lane['headline']."\n".$lane['lede'],
sourceUrl: '/'.$lane['slug'],
);
}
}
public function corpus(): string
{
return 'noria-site';
}
}
use NoriaLabs\Aria\Contracts\Persona;
class Aria implements Persona
{
public function instructions(): string
{
return 'You are Aria. Never quote a price unless asked. ...';
}
public function greeting(): ?string
{
return null;
}
}
$response = app(Assistant::class)->reply('Do you do mobile money reconciliation?');
$response->text; // the answer
$response->conversationId; // hold this to continue the thread
class WorkspaceBudget implements BudgetPolicy
{
public function cap(): ?int { return $this->settings->aiCapUsdMicros(); }
public function scope(): ?string { return Tenancy::currentWorkspaceId(); }
}
Aria::useConversationModel(SupportThread::class);
class Ascii implements NoriaLabs\Aria\Contracts\Normaliser
{
public function normalise(string $text): string { /* ... */ }
}
use Laravel\Ai\Embeddings;
use NoriaLabs\Aria\Agents\AriaAgent;
AriaAgent::fake(['Yes, we do.']);
Embeddings::fake();