1. Go to this page and download the library: Download nahid-hasan/ai-notes 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/ */
nahid-hasan / ai-notes example snippets
// Store a voice note
AINote::fromAudio($request->file('audio'));
// Store a text note
AINote::fromText("Met with client Sarah about renewing the contract.");
// Search semantically — finds related notes even with different wording
AINote::search("contract renewal discussion");
// Ask a question across all your notes
AINote::ask("What did I promise the client?");
use AINote;
// In a controller
public function store(Request $request)
{
$request->validate([
'audio' => '� omit for single-user apps
);
// Note is queued for processing. Returns immediately.
return response()->json([
'note_id' => $note->id,
'status' => $note->status, // "pending"
], 202);
}
$note = AINote::fromText(
"Had a call with John. He wants the proposal by Friday.",
userId: auth()->id(),
title: "John call" // optional
);
use Nahid\AINotesPackage\Models\AINote;
$note = AINote::find($noteId);
echo $note->status;
// "pending" → queued, not started
// "processing" → AI is working on it
// "done" → transcription, summary, and embedding ready
// "failed" → something went wrong, check logs
// Basic search
$results = AINote::search("payment discussion");
// Limit results
$results = AINote::search("contract renewal", 3);
// Scoped to a user
$results = AINote::search("invoice delay", 5, auth()->id());
// Each result has a `distance` score — lower = more relevant (0.0 to 1.0)
foreach ($results as $note) {
echo $note->summary;
echo $note->distance; // e.g. 0.31 = very relevant
}
// Ask a question — searches relevant notes and generates an answer
$answer = AINote::ask("What did I say about the Q4 budget?");
echo $answer;
// Scoped to a user
$answer = AINote::ask("What promises did I make to clients?", userId: auth()->id());
// Control how many notes are used as context (default: 3)
$answer = AINote::ask("Summarize my week", contextLimit: 5, userId: auth()->id());
use Nahid\AINotesPackage\Models\AINote;
// All done notes
AINote::done()->get();
// All pending notes
AINote::pending()->get();
// Notes for a specific user
AINote::where('user_id', $userId)->done()->latest()->get();
// Retry a failed note
$note = AINote::find($id);
$note->update(['status' => 'pending']);
\Nahid\AINotesPackage\Jobs\ProcessNote::dispatch($note);
use Nahid\AINotesPackage\Contracts\AIProvider;
use Nahid\AINotesPackage\Tests\Fakes\FakeAIProvider;
// In your TestCase setUp or individual tests:
app()->bind(AIProvider::class, fn() => FakeAIProvider::make());
config(['ai-notes.queue' => false]); // process synchronously
// Now AINote works without Ollama or Whisper running
$note = AINote::fromText("Test note content");
expect($note->status)->toBe('done');
use Nahid\AINotesPackage\Contracts\AIProvider;
class MistralProvider implements AIProvider
{
public function transcribe(string $audioPath): string
{
// your transcription logic
}
public function summarize(string $text): string
{
// your summarization logic
}
public function embed(string $text): array
{
// your embedding logic — must return float[]
}
}
use Nahid\AINotesPackage\Contracts\AIProvider;
$this->app->bind(AIProvider::class, fn() => new MistralProvider());
// Reset all notes to re-embed them
Nahid\AINotesPackage\Models\AINote::query()->update(['status' => 'pending', 'embedding' => null]);
// Then reprocess each one via the job