Dijital bir bankada hesap bakiyelerini uyduran bir destek botu sadece işe yaramaz değil, aynı zamanda tehlikelidir. Finansal görüşmeler kesin sayılar, doğrulanmış alıcılar ve her iddia için bir denetim izi gerektirir. Büyük dil modelleri sohbet konusunda mükemmeldir ancak halüsinasyon görürler. Bir kullanıcı “Hesabımda ne kadar kaldı?” diye sorduğunda, model hayal gücüne değil, bir veri tabanına başvurmalıdır. İşte Function Calling tam olarak bunu sağlar ve bu yapının temelini oluşturur.

Google'ın Gemma 4 modeli, geliştiricilere karmaşık talimatları takip edebilen ve bölgesel lehçeler de dahil olmak üzere doğal diyaloglar sürdürebilen yetenekli, 31 milyar parametreli bir model sunar. Google AI Studio ile eşleştirildiğinde; araçları tanımlayabileceğiniz, uç durumları test edebileceğiniz ve bir sunucuya dokunmadan önce çalışan JavaScript kodlarını dışa aktarabileceğiniz hızlı bir prototipleme ortamına dönüşür. Buradaki hedef; hesap bakiyelerini kontrol eden, işlem durumlarını takip eden ve faturaları ödeyen bir fintech destek ajanı oluşturmaktır. En önemlisi, kullanıcı Nijerya Pidgin dilinde konuştuğunda, finansal gerçekleri asla uydurmadan tonu eşleyerek aynı dilde yanıt verir.

Finansal Botlar İçin Function Calling Neden Önemlidir

Function calling olmadan, bir dil modeli her soruyu yaratıcı bir yazım egzersizi olarak ele alır. Ondan bir bakiye isterseniz, eğitim verilerindeki kalıplardan yola çıkarak kulağa makul gelen bir rakam uydurabilir. Gerçek para söz konusu olduğunda bu hata biçimi kabul edilemez.

Function calling akışı tersine çevirir. Modelin görevi bakiyeyi bilmek değildir. Görevi niyeti tanımak, doğru aracı seçmek ve parametreleri çıkarmaktır. Bir kullanıcı “Bakiyemi kontrol et” yazdığında, Gemma 4, account_id içeren bir get_balance çağrısı gibi yapılandırılmış bir JSON isteği oluşturur. Backend sisteminiz bu çağrıyı ana bankacılık sistemine karşı yürütür, gerçek rakamı alır ve bunu konuşmaya geri besler. Model, insanla iletişim kuracak cümleyi ancak ondan sonra oluşturur. Her cevap, bir backend aracına yapılan çağrıdan gelir. Model harici bir mantıkla sınırlandırıldığı için halüsinasyonlar API sınırında durur.

Bu desen aynı zamanda net denetim izleri oluşturur. Her araç isteği ve buna karşılık gelen sonuç mesaj geçmişine kaydedilir. Düzenleyiciler ve risk ekipleri, bir bakiyenin tam olarak ne zaman kontrol edildiğini ve kullanıcının hangi rakamı aldığını inceleyebilir.

Google AI Studio'da Ajan Tasarımı

İş akışı Google AI Studio içinde başlar. Diyalog ve talimat takibi için optimize edilmiş olan gemma-4-31b-it instruct-tuned varyantını seçin.

Ardından, kesin sınırlar koyan sistem talimatları yazın. Dijital bir banka için ton profesyonel, doğrudan ve sakin olmalıdır. Ancak talimatlar daha da ileri gitmelidir. Modele, hesap verilerini asla tahmin etmeyeceğini, bir işlem durumunu asla varsaymayacağını ve araç sonucunu onaylamadan asla bir fatura ödemesini tamamlamayacağını açıkça söyleyin. Eğer kullanıcı Nijerya Pidgin dilinde yazarsa, model Nijerya Pidgin dilinde yanıt vermelidir. Kullanıcı İngilizceye geçerse, model onu takip eder. Sistem istemi (system prompt), güven ve güvenlik politikasını sade bir dille kodladığınız yerdir.

Sonra araç şemalarını (tool schemas) tanımlayın. Bunları model ile backend'iniz arasındaki sözleşmeler olarak düşünün. En az üç tanesine ihtiyacınız var:

  1. get_balance
    Parametreler: account_id (string, gerekli)
    Döndürür: mevcut bakiye ve para birimi.

  2. get_transaction_status
    Parametreler: transaction_reference (string, gerekli)
    Döndürür: beklemede, tamamlandı veya başarısız gibi durumlar ve bir zaman damgası.

  3. pay_bill
    Parametreler: biller_code (string, gerekli), amount (number, gerekli), account_pin (akışınıza bağlı olarak isteğe bağlı string)
    Döndürür: onay referansı veya hata mesajı.

Her şema; fonksiyon adını, açıklamasını ve parametre özelliklerini tanımlayan standart bir JSON formatı kullanır. Açıklama alanları son derece önemlidir. Modelin her bir aracı ne zaman çağırması gerektiğini anlamasını sağlayacak şekilde yazın. Belirsiz açıklamalar yanlış araç seçimine yol açar, bu nedenle spesifik olun: “Kullanıcı mevcut hesap bakiyesini öğrenmek istediğinde get_balance aracını kullanın. İşlem geçmişi için kullanmayın.”

Tarayıcıda Prototip Oluşturma

Tek bir Express rotası yazmadan önce, tüm konuşma akışını AI Studio'nun sohbet panelinde test edin. Bu, backend tarafında günlerce sürecek yeniden çalışma zahmetinden kurtarır. Nijerya Pidgin dilinde bir sorgu yazın: “Wetin remain inside my account?” Gemma 4'ün doğru bir şekilde get_balance çağrısı yapıp yapmadığını veya eğitim verilerinden cevap vermeye çalışıp çalışmadığını izleyin. Eğer parametreleri yanlış belirlerse —örneğin account_id yerine account_number kullanırsa— şema açıklamasını hemen orada düzeltin.

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