Bot pendukung yang mengarang saldo akun tidak hanya tidak berguna di bank digital. Itu berbahaya. Percakapan finansial menuntut angka yang tepat, penerima yang terverifikasi, dan jejak audit untuk setiap klaim. Model bahasa besar sangat mahir dalam percakapan, tetapi mereka berhalusinasi. Ketika seorang pengguna bertanya, “Berapa sisa saldo akun saya?”, model harus mengakses basis data, bukan imajinasi. Itulah tepatnya yang ditegakkan oleh function calling, dan itu adalah inti dari pembuatan ini.
Gemma 4 dari Google memberikan pengembang model 31 miliar parameter yang mumpuni yang dapat mengikuti instruksi kompleks dan melakukan dialog alami, termasuk dalam dialek regional. Dipasangkan dengan Google AI Studio, ia menjadi lingkungan pembuatan prototipe cepat di mana Anda dapat menentukan alat (tools), menguji kasus ekstrem (edge cases), dan mengekspor JavaScript yang berfungsi sebelum Anda menyentuh server. Tujuannya di sini adalah agen pendukung fintech yang memeriksa saldo akun, melacak status transaksi, dan membayar tagihan. Yang terpenting, ia merespons dalam Pidgin Nigeria jika pengguna melakukannya, menyesuaikan nada tanpa pernah mengimprovisasi fakta finansial.
Mengapa Function Calling Penting untuk Bot Finansial
Tanpa function calling, model bahasa memperlakukan setiap pertanyaan sebagai latihan menulis kreatif. Tanyakan saldo kepadanya dan ia mungkin mengarang angka yang terdengar masuk akal yang diambil dari pola dalam data pelatihannya. Mode kegagalan seperti itu tidak dapat diterima ketika uang sungguhan terlibat.
Function calling membalikkan alur tersebut. Tugas model bukanlah untuk mengetahui saldo. Tugasnya adalah mengenali niat (intent), memilih alat yang benar, dan mengekstrak parameter. Ketika pengguna menulis “Periksa saldo saya,” Gemma 4 mengeluarkan permintaan JSON terstruktur—seperti panggilan ke get_balance dengan account_id. Backend Anda mengeksekusi panggilan tersebut terhadap sistem perbankan inti, mendapatkan angka aslinya, dan memasukkannya kembali ke dalam percakapan. Hanya setelah itu model menghasilkan kalimat yang ditujukan kepada manusia. Setiap jawaban berasal dari panggilan alat ke backend. Karena model dibatasi oleh logika eksternal, halusinasi berhenti di batas API.
Pola ini juga menciptakan jejak audit yang jelas. Setiap permintaan alat dan hasil yang sesuai dicatat dalam riwayat pesan. Regulator dan tim risiko dapat memeriksa secara tepat kapan saldo diperiksa dan angka berapa yang diterima pengguna.
Merancang Agen di Google AI Studio
Alur kerja dimulai di dalam Google AI Studio. Pilih gemma-4-31b-it, varian instruct-tuned yang dioptimalkan untuk dialog dan pengikut instruksi.
Selanjutnya, tulis instruksi sistem yang menetapkan batasan yang tegas. Untuk bank digital, nadanya harus profesional, langsung, dan tenang. Namun instruksi tersebut harus lebih jauh lagi. Beritahu model secara eksplisit bahwa ia tidak pernah memperkirakan data akun, tidak pernah berasumsi tentang status transaksi, dan tidak pernah menyelesaikan pembayaran tagihan tanpa mengonfirmasi hasil alat. Jika pengguna menulis dalam Pidgin Nigeria, model harus membalas dalam Pidgin Nigeria. Jika pengguna beralih ke bahasa Inggris, model akan mengikutinya. System prompt adalah tempat Anda menyandikan kebijakan kepercayaan dan keamanan dalam bahasa yang lugas.
Kemudian tentukan skema alat (tool schemas). Anggap ini sebagai kontrak antara model dan backend Anda. Anda membutuhkan setidaknya tiga:
get_balance
Parameter:account_id(string, wajib)
Mengembalikan: saldo saat ini dan mata uang.get_transaction_status
Parameter:transaction_reference(string, wajib)
Mengembalikan: status seperti pending, completed, atau failed, ditambah stempel waktu (timestamp).pay_bill
Parameter:biller_code(string, wajib),amount(number, wajib),account_pin(string, opsional tergantung alur Anda)
Mengembalikan: referensi konfirmasi atau pesan kesalahan.
Setiap skema menggunakan format JSON standar yang menjelaskan nama fungsi, deskripsi, dan properti parameter. Bidang deskripsi sangatlah penting. Tulislah agar model memahami kapan harus memanggil setiap alat. Deskripsi yang ambigu menyebabkan pemilihan alat yang salah, jadi bersikaplah spesifik: “Gunakan get_balance saat pengguna ingin mengetahui saldo akun mereka saat ini. Jangan gunakan untuk riwayat transaksi.”
Pembuatan Prototipe di Browser
Sebelum Anda menulis satu rute Express pun, uji seluruh alur percakapan di dalam panel obrolan AI Studio. Ini menghemat berhari-hari pengerjaan ulang backend. Ketik kueri dalam Pidgin Nigeria: “Wetin remain inside my account?” Perhatikan apakah Gemma 4 mengeluarkan panggilan get_balance dengan benar atau apakah ia mencoba menjawab dari data pelatihan. Jika ia salah dalam parameter—mungkin menggunakan account_number alih-alih account_id—Anda dapat memperbaiki deskripsi skema langsung di sana.
Test the failure modes too. Ask for a transaction status without providing a reference number. A well-instructed model should either ask the user for the missing parameter or call the tool with what it has and let the backend return a validation error. You want to see these behaviors in the sandbox, not in production.
Once the prompts and schemas behave correctly, export the JavaScript code. AI Studio generates a clean snippet that structures the API request with your system prompt, user message, and tool definitions. This becomes the foundation of your backend logic.
Wiring Up the Express Backend
Take the exported code and drop it into an Express application. The architecture is straightforward, but the execution loop is the critical piece.
Set up a POST endpoint—perhaps /chat—that accepts the user’s message and any session history. Forward these to the Gemma 4 endpoint, which you can hit via an OpenAI-compatible API or Google’s own inference endpoint depending on your hosting choice.
The response from the model falls into one of two categories. Either it is a final text message, or it contains a tool_call requesting data. When you receive a tool call, execute the corresponding function against your backend. Query the database for the balance. Hit the payment processor for the bill status. Append the tool result to the conversation history as a new message with the role tool, and send the entire updated array back to Gemma 4.
Repeat this loop until the model returns a final text answer. That answer will be grounded in the real data you supplied. Express makes this easy to coordinate because each pass through the loop is just another HTTP request, and you can async/await the tool execution cleanly.
During early development, back these tool calls with mock data. A simple JavaScript object mapping sample account IDs to balances is enough to prove the loop works. The point is to validate the interaction pattern before integrating with brittle third-party banking APIs.
From Prototype to Production
A working prototype is not production banking infrastructure, but the path from one to the other is clear.
Replace the mock data with real core banking APIs. Connect your get_balance tool to the ledger system over REST or gRPC. Hook pay_bill into your actual payment switch. When you do this, you do not need to change the model or the conversation logic; you only swap the implementation of the tool handlers.
Add Redis for session management. Conversational state in banking is sensitive and regulated. You need to store message histories securely, expire them after a set timeout, and ensure that a user’s session cannot leak across requests. Redis handles this with TTL policies and fast key lookups.
When traffic grows, moveInference to vLLM. AI Studio is excellent for prototyping, but self-hosted inference with vLLM on GPU clusters gives you control over latency, batching, and cost at scale. Gemma 4 runs efficiently under vLLM, and the tool-calling behavior remains identical.
The Real Takeaway
Building a trustworthy fintech agent is less about model size and more about architectural constraints. Gemma 4 provides enough reasoning power to parse code-switched Nigerian Pidgin and route complex intents, but the safety comes from the tool loop. Every balance is fetched live. Every bill payment is confirmed by an external system. Nothing is invented.
Start in the browser with AI Studio, harden the logic in an Express loop, and swap in real banking infrastructure once the conversation flows are bulletproof. That is how you ship a bot people can actually trust with their money.
Source: Building a Full Gemma 4 Google AI Studio Project: A Fintech Support Agent
Optional learning community: GyaanSetu AI on Telegram
