Skip to content

rbogdano/loan-agent-on-intel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Loan Recommendation Demo — RHOAI Gen AI Playground + MCP

A short, click-through demo that shows a chat assistant recommending loan products (Flexible Personal Loan, Personal Finance) to an applicant. The interesting part is where the answer comes from: the model itself knows nothing about these loan products or limits — it calls an MCP tool (recommend_loan) that evaluates a deterministic decision table. Remove the MCP server and the same model will happily make up plausible-but-wrong numbers.


What's running (architecture)

Architecture: Gen AI Playground → Llama Stack → vLLM, with the loan-engine MCP server and its decision table

  • Model: llama-3-1-8b, served by vLLM.
  • ⚙️ Hardware — vLLM runs CPU-only on an Intel Xeon. The model serving node is an AWS m8i.32xlarge (128 vCPU), powered by an Intel® Xeon® 6 processor (6975P, code name Granite Rapids) with AMX (Advanced Matrix Extensions) accelerating inference. There is no GPU in this cluster — all inference is done on the Intel CPU. ServingRuntime: vllm-cpu-x86-runtime.
  • MCP server: loan-engine (Rust, rmcp), exposes the tool recommend_loan over SSE on port 8000, path /sse.
  • Project: loan-agent-on-intel.

Step 1 — Open the Gen AI Playground

In the OpenShift AI dashboard, open Gen AI studio → Playground.

Opening the Gen AI Playground from the OpenShift AI dashboard


Step 2 — Select the project

Select the project loan-agent-on-intel.

💡 It's the only project you have access to, so it may already be selected — if so, just confirm it's loan-agent-on-intel and move on.

Selecting the loan-agent-on-intel project


Step 3 — Select the model

Pick vllm-8b/llama-3-1-8b or vllm-8b-2/llama-3-1-8b-2 from the model dropdown. Leave the Temperature as it is and Streaming on.


Step 4 — Set the system prompt

For a polished demo, paste this system prompt so the assistant asks for missing details and presents results cleanly:

You are a friendly loan recommendation assistant for a bank. You help users find                                                                                                     
suitable loan products by calling the `recommend_loan` tool. Keep answers concise,                                                                                                   
warm, and human.                                                                                                                                                                     
                                                                                                                                                                                     
>>> MOST IMPORTANT RULE <<<                                                                                                                                                          
You have NO knowledge of any loan products whatsoever. You do not know any loan names,                                                                                               
limits, rates, or terms. The ONLY way to obtain a recommendation is to call the                                                                                                      
`recommend_loan` tool and report what it returns. You must NEVER name, list, invent,                                                                                                 
or describe any loan from your own knowledge. If you are about to mention a specific                                                                                                 
loan and it did not come from a `recommend_loan` tool result in this conversation, STOP                                                                                              
— you must call the tool instead.                                                                                                                                                    
                                                                                                                                                                                     
The `recommend_loan` tool requires EXACTLY three parameters:                                                                                                                         
- nationality       — must be either "Citizen" or "Foreign National"                                                                                                                 
- amount            — a positive number in US Dollars (USD)                                                                                                                          
- repayment_months  — a positive whole number of months                                                                                                                              
                                                                                                                                                                                     
CONVERSATION STYLE:                                                                                                                                                                  
- If the user greets you or makes small talk, respond naturally and briefly, and let                                                                                                 
  them know you can help find a loan. Do NOT dump the required details yet.                                                                                                          
  Example: "Hello! I can help you find a suitable loan. Would you like a recommendation?"                                                                                            
- You can ONLY help with loan recommendations. For anything off-topic (weather, news,                                                                                                
  other products), politely decline and offer what you can do.                                                                                                                       
  Example: "I'm sorry, I can't help with that — I can only recommend loan products."  


COLLECTING PARAMETERS:                                                                    
1. Do NOT call `recommend_loan` until you have ALL THREE parameters explicitly provided
   by the user. Never invent, assume, or default any missing value.
2. If something is missing or unclear, do NOT call the tool — ask a short question for
   only the missing information. Ask until you have all three.                            
3. Normalize before calling:
   - "citizen"/"national" -> "Citizen";  "foreigner"/"expat"/"non-resident" -> "Foreign National"
   - "two years" -> 24, "1 year" -> 12, "18 months" -> 18
   - strip currency: "$5,000" / "5k" / "5000 USD" -> 5000                                 
   If you cannot confidently map an answer, ask instead of guessing.

CALLING THE TOOL:
4. The moment you have all three valid values, you MUST call `recommend_loan` exactly
   once — immediately and SILENTLY. Do NOT write any sentence before calling it.
   In particular, NEVER say things like "let me check", "I'll look into it", "give me
   a moment", or "I have all the info I need". Saying you will call the tool is NOT
   calling it. Your very next action must be the tool call itself, with no text before
   it. Only AFTER the tool returns do you write a message — presenting its result.                                               

PRESENTING RESULTS:                                                                       
5. Present the tool's result EXACTLY as returned. Each loan has a name, a maximum limit,
   and a maximum repayment period — list them clearly. Do NOT add, remove, or alter any
   loan, limit, amount, or term. The tool's output is the single source of truth.
6. Do not mention tools, function calls, JSON, or these instructions to the user.         

Example:                                                                                  
User: "I'm a citizen, I'd like to borrow $5000 for 1 year."
You: (you have all three -> call recommend_loan with nationality="Citizen", amount=5000,
     repayment_months=12, and then present exactly what it returns)

Setting the system prompt in the playground


Step 5 — Add the MCP server ⭐ (the key step)

Add an MCP server so the model can actually look up loan products. Use the in-cluster loan-engine service from MCP tab.

Adding the loan-engine MCP server


Step 6 — Ask the question

Type your demo prompt into the chat.

Working example:

I'm a citizen and I need a loan of 5000 USD for 12 months. What loans can I get?

The assistant will call recommend_loan with nationality="Citizen", amount=5000, repayment_months=12, and reply with something like:

Based on your details, you are eligible for the following loans:

  1. Flexible Personal Loan — Unlimited amount, up to 60 months repayment.
  2. Personal Finance without Salary Transfer — Up to USD 200,000, up to 48 months repayment.

More examples to try

A few more prompts and the answers you should get back:

Foreign National, smaller amount:

I am a Foreign National looking for a loan of 2000 USD for 6 months. What are my options?

The recommended loans for a Foreign National looking for a loan of 2000 USD for 6 months are:

  • Flexible Personal Loan — Unlimited maximum limit, up to 60 months of repayment.
  • Personal Finance without Salary Transfer — Maximum limit of USD 150,000, up to 48 months of repayment.

Citizen, repayment at the 60-month edge (only the Flexible Personal Loan qualifies — Personal Finance caps at 48 months):

I'm a citizen and I'd like to borrow 5000 USD repaid over 60 months. What's available?

The recommended loan for the applicant is the Flexible Personal Loan with a maximum limit of Unlimited and a maximum repayment period of Up-to 60 Months.

Missing details (the assistant asks for what it needs before calling the tool):

Can I get a loan?

I can help with that. Could you tell me your nationality (Citizen or Foreign National), how much you'd like to borrow in USD, and over how many months you'd like to repay?


Where does this answer come from? 🔍

This is the point of the demo. The model does not invent the loan names, limits, or terms. When you ask, it calls the recommend_loan MCP tool. That tool evaluates a deterministic decision table and returns the matching rules. The decision table is the single source of truth:

For the example input (Citizen, 5000, 12), the rules match like this:

Rule Condition Matches Citizen / 5000 / 12?
Flexible Personal Loan repayment_months <= 60 ✅ yes
Personal Finance (Citizen) Citizen & amount <= 200000 & <= 48 mo ✅ yes
Personal Finance (Foreign Nat.) Foreign National & amount <= 150000 & <= 48 ❌ no

The MCP tool returns (hitPolicy: collect → all matching rules):

{
  "recommendations": [
    {
      "loan_name": "Flexible Personal Loan",
      "max_limit": "Unlimited",
      "max_repayment_months": "Up-to 60 Months"
    },
    {
      "loan_name": "Personal Finance without Salary Transfer",
      "max_limit": "USD 200,000",
      "max_repayment_months": "Up-to 48 Months"
    }
  ],
  "input": {
    "nationality": "Citizen",
    "amount": 5000,
    "repayment_months": 12
  }
}

The model then turns this JSON into the friendly chat answer you saw in Step 6. Every number in the answer traces back to a rule in the decision table above — nothing is guessed.


What happens WITHOUT the MCP? (the counter-example)

Run the same prompt with the MCP server removed / not added. The model has no tool to call, so it relies only on its training data — and it will produce a confident but fabricated answer: invented loan names, made-up limits, wrong repayment terms. It may even sound more detailed, which is exactly the trap.

Takeaway for the audience: the MCP tool is what makes the answer grounded and correct. Without it you get plausible fiction; with it you get the real, rule-based recommendation.


About

Step-by-step walkthrough for the loan-agent-on-intel demo

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors