Muhandis Online

An AI assistant for a law firm, at 83% lower cost

A law firm in Saudi Arabia has a platform with a public assistant on its site, a client portal and an AI hub for its lawyers. It worked, but the AI bill grew every month beyond what the firm expected. I found where it went, and cut it by 83%.

A law firm in Saudi Arabia (not named)

Taking over the system

Result
Token cost down 83%
Duration
12 days
Platform
A public assistant, a client portal and an AI hub for lawyers

From the project

The AI hub after the fix: what the lawyer has used today against her daily limit (platform name hidden, demo numbers)
The AI hub after the fix: what the lawyer has used today against her daily limit (platform name hidden, demo numbers)
  • A legal memo drafted by the assistant, left for the lawyer to review before use (demo text)
    A legal memo drafted by the assistant, left for the lawyer to review before use (demo text)
  • The legal assistant talks with a visitor and sorts the request before passing it to a lawyer (firm name hidden, demo chat)
    The legal assistant talks with a visitor and sorts the request before passing it to a lawyer (firm name hidden, demo chat)
  • The client portal: invoices due, upcoming hearings and the latest documents (demo data)
    The client portal: invoices due, upcoming hearings and the latest documents (demo data)
  • A case in the client portal: hearings, shared documents and invoices (demo data)
    A case in the client portal: hearings, shared documents and invoices (demo data)

Where the money went

  • The AI hub was open to anyone with the link: text, images, video, audio and PDF analysis, with no sign-in and no record.
  • The public assistant trusted the conversation the browser sent, with no limit on length or on requests.
  • The portal chat saved each raw streamed reply, markers and all, and resent all of it with every question.
  • Any client who signed up could call the model without limit, and every repeated question went to the model.

What I changed

  • The AI hub is now for permitted users only, with a daily limit per user, and every request is written to a usage log.
  • I removed images, video and audio: the firm did not need them, and they cost the most.
  • The server now owns the conversation, with a limit of 10 requests a minute per IP address.
  • Ready answers to repeated questions, which the firm edits itself, and a policy that keeps the assistant on legal matters.
  • I fixed the stream parsing; the firm then chose to move client contact to tickets answered by a lawyer.

How I checked

Tests check that a client account cannot reach the AI chat, that the assistant ignores fake replies sent by the browser, that the 11th request in a minute is refused, and that the daily limit stops a user. The result on the bill: token cost down 83%.

Built with

Python (FastAPI)ReactLLM API

Services in this work

Tell me what you want built.

I reply within one working day, with questions or a first idea of scope and price.