← Tutti i progettiAll projects
🦷
Case study · Agente AI con le API di ClaudeAI agent on the Claude API

Assistente RAG dello studio dentisticoDental clinic RAG assistant

La segreteria virtuale di uno studio dentistico fittizio: risponde alle domande dei pazienti usando solo i documenti dello studio, cita la fonte di ogni informazione e dice "non lo so" quando la risposta non c'è.The virtual front desk of a fictitious dental clinic: it answers patients' questions using only the clinic's documents, cites the source of every fact and says "I don't know" when the answer isn't there.

Claude API · Haiku 5.5Ricerca BM25BM25 retrievalCloudflare WorkersPrivacy by designItaliano e ingleseItalian and English
Prova l'assistenteTry the assistant → Gratuito, senza account. Lo studio e i documenti sono inventati.Free, no sign-up. The clinic and its documents are made up.
9documenti dello studioclinic documents
4frammenti per rispostapassages per answer
<0,1 ¢costo per domandacost per question
0conversazioni salvateconversations stored

Cosa faWhat it does

Come funzionaHow it works

1OscuramentoMaskingTelefono, email, codice fiscale, IBAN e carte vengono oscurati nel browser, prima dell'invio.Phone numbers, emails, tax codes, IBANs and cards are masked in the browser, before sending.
2RicercaRetrievalI documenti sono divisi in frammenti; una ricerca BM25 trova i 4 più pertinenti alla domanda.Documents are split into passages; a BM25 search finds the 4 most relevant to the question.
3PromptPromptI frammenti numerati vanno a Claude con regole precise: solo da lì, fonte citata, niente consigli medici.The numbered passages go to Claude with strict rules: only from them, cited sources, no medical advice.
4RispostaAnswerClaude Haiku risponde citando i numeri, che diventano link ai documenti.Claude Haiku answers citing the numbers, which become links to the documents.
5ControlliChecksUna risposta vuota o interrotta viene sostituita da un messaggio sicuro fisso.An empty or interrupted answer is replaced by a fixed safe message.

Come l'ho costruitoHow I built it

L'ho costruito in vibecoding con Claude, subito dopo il corso "Building with the Claude API" di Anthropic Academy. Ho deciso io i requisiti (studio fittizio, risposte solo dai documenti, fonti citate, privacy, costi minimi), Claude ha scritto codice e test, io ho creato l'account Anthropic, impostato credito e limiti e dato l'ok alla pubblicazione. La pagina è HTML e JavaScript senza framework; la chiamata a Claude passa da un Worker di Cloudflare, così la chiave API resta sul server.I built it through vibe coding with Claude, right after Anthropic Academy's "Building with the Claude API" course. I set the requirements (fictitious clinic, answers only from documents, cited sources, privacy, minimal costs), Claude wrote the code and tests, and I created the Anthropic account, set credit and limits and approved the release. The page is plain HTML and JavaScript; the call to Claude goes through a Cloudflare Worker, so the API key stays on the server.

Scelte tecnicheTechnical choices

BM25 invece degli embeddingBM25 instead of embeddings

Con una decina di documenti una ricerca per parole chiave, con stemming leggero e sinonimi in italiano, trova i frammenti giusti senza database vettoriali né costi aggiuntivi. Lo stesso codice gira nel browser e sul server.With about ten documents, a keyword search with light Italian stemming and synonyms finds the right passages without vector databases or extra costs. The same code runs in the browser and on the server.

Citazioni verificabiliVerifiable citations

Claude cita i frammenti con numeri tra parentesi; il server collega ogni numero al documento d'origine e la pagina lo apre evidenziando il passaggio usato.Claude cites passages with bracketed numbers; the server maps each number to its source document and the page opens it with the passage highlighted.

Costi sotto controlloCosts under control

Modello Haiku, credito prepagato senza ricarica automatica, tetto di spesa mensile di 1 dollaro e massimo 8 domande al minuto per visitatore: anche un abuso non può costare più di così.Haiku model, prepaid credit with no auto-reload, a $1 monthly spend cap and at most 8 questions per minute per visitor: even abuse can't cost more than that.

Difese contro le istruzioni nascosteDefences against injected instructions

Documenti e domande sono trattati come materiale da consultare: le istruzioni scritte dentro un documento caricato vengono ignorate. I documenti dei visitatori sono etichettati e non si mescolano con quelli dello studio.Documents and questions are treated as material to consult: instructions written inside an uploaded document are ignored. Visitors' documents are labelled and never mixed with the clinic's.

Privacy e dati sanitariPrivacy and health data

Cosa ho verificatoWhat I tested

Un problema trovato in produzioneA problem found in production

Al primo rilascio alcune risposte arrivavano vuote o troncate dopo poche parole. Il motivo: il modello Haiku 5.5 ragiona prima di rispondere e quel ragionamento consumava tutto il limite di token impostato. Ho aggiunto alla risposta del server i dati di diagnostica (motivo dello stop, tipi di blocco, token usati), alzato il limite e previsto un messaggio sicuro fisso per ogni risposta vuota, interrotta o troncata.On the first release some answers came back empty or cut off after a few words. The reason: Haiku 5.5 reasons before answering, and that reasoning used up the whole token limit. I added diagnostics to the server response (stop reason, block types, tokens used), raised the limit and added a fixed safe message for any empty, interrupted or truncated answer.