Skip to content
Merged
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
6ade24f
updating instructions for retail
uma-kumar Jul 1, 2025
abc150e
Merge branch 'oracle-livelabs:main' into main
uma-kumar Jul 1, 2025
4226cb3
updates to healthcare markdown
uma-kumar Jul 7, 2025
2b077c7
Merge branch 'oracle-livelabs:main' into main
uma-kumar Jul 7, 2025
2ec433f
retail lab 1
uma-kumar Jul 28, 2025
95e723b
Merge branch 'oracle-livelabs:main' into main
uma-kumar Jul 28, 2025
36af7c2
screenshots for lab 1 and intro video
uma-kumar Jul 30, 2025
596d247
Merge branch 'main' of https://github.com/uma-kumar/developer
uma-kumar Jul 30, 2025
4826291
lab 4 screenshots
uma-kumar Jul 31, 2025
b772dc5
Merge branch 'oracle-livelabs:main' into main
uma-kumar Jul 31, 2025
7a699c7
fix lab 4 and manifest files for retail and healthcare
uma-kumar Aug 5, 2025
c630448
Merge branch 'main' of https://github.com/uma-kumar/developer
uma-kumar Aug 5, 2025
a939711
Merge branch 'oracle-livelabs:main' into main
uma-kumar Aug 6, 2025
388f6da
Merge branch 'oracle-livelabs:main' into main
uma-kumar Aug 11, 2025
07e1ab7
Merge branch 'oracle-livelabs:main' into main
uma-kumar Aug 12, 2025
95cae0c
lab 1 screenshots
uma-kumar Aug 12, 2025
40853bb
Merge branch 'oracle-livelabs:main' into main
uma-kumar Aug 13, 2025
1dc3d26
Merge branch 'oracle-livelabs:main' into main
uma-kumar Aug 15, 2025
5f51bbe
incorporated feedback from Retail experts
uma-kumar Aug 15, 2025
156b696
Merge branch 'oracle-livelabs:main' into main
uma-kumar Aug 20, 2025
02802e6
lab 1 markdown- healthcare
uma-kumar Aug 20, 2025
ad5948d
Merge branch 'oracle-livelabs:main' into main
uma-kumar Aug 27, 2025
a23cfcd
lab 4 and 1 updates
uma-kumar Aug 27, 2025
a8ae0da
lab 4 and 1 updates
uma-kumar Aug 27, 2025
9f6f1a5
lab 4 and 1 updates
uma-kumar Aug 27, 2025
66b5bc9
retail lab 4
uma-kumar Aug 27, 2025
b5513f1
Merge branch 'oracle-livelabs:main' into main
uma-kumar Aug 28, 2025
7dae58e
healthcare lab 4
uma-kumar Aug 28, 2025
52e9c56
take out graph
uma-kumar Aug 29, 2025
e5affc2
Merge branch 'oracle-livelabs:main' into main
uma-kumar Aug 29, 2025
83fb4a9
Merge branch 'main' of https://github.com/uma-kumar/developer
uma-kumar Aug 29, 2025
244c35d
Merge branch 'oracle-livelabs:main' into main
uma-kumar Sep 2, 2025
9ffee0f
changes implemented from UAT
uma-kumar Sep 2, 2025
2556a8a
Merge branch 'oracle-livelabs:main' into main
uma-kumar Sep 3, 2025
2817b4c
Merge branch 'oracle-livelabs:main' into main
uma-kumar Sep 9, 2025
cee3ba7
Merge branch 'oracle-livelabs:main' into main
uma-kumar Sep 10, 2025
8e7f0b5
Merge branch 'oracle-livelabs:main' into main
uma-kumar Sep 13, 2025
0f01517
created folder for energy and updates to lab 1
uma-kumar Sep 13, 2025
b32f41b
Merge branch 'oracle-livelabs:main' into main
uma-kumar Sep 16, 2025
fb4cfc1
energy and utilities lab 4 update
uma-kumar Sep 16, 2025
1d20456
Merge branch 'oracle-livelabs:main' into main
uma-kumar Sep 18, 2025
6808744
added graph to retail, healthcare, and e&u. updated retail lab 4
uma-kumar Sep 18, 2025
6cb6fac
manufacturing lab 4 and high tech lab 1
uma-kumar Sep 19, 2025
98bc8a1
Merge branch 'oracle-livelabs:main' into main
uma-kumar Sep 22, 2025
2e71d87
Merge branch 'oracle-livelabs:main' into main
uma-kumar Sep 24, 2025
93bd59e
manufacturing and graph for other industries
uma-kumar Sep 24, 2025
d3c06e1
Merge branch 'oracle-livelabs:main' into main
uma-kumar Oct 2, 2025
ce99435
high tech lab 4
uma-kumar Oct 2, 2025
2c1018e
getting rid of unnecessary comments
uma-kumar Oct 2, 2025
4069032
Merge branch 'oracle-livelabs:main' into main
uma-kumar Oct 6, 2025
405ccd1
manufacturing lab 1
uma-kumar Oct 6, 2025
4b0a809
Merge branch 'oracle-livelabs:main' into main
uma-kumar Oct 9, 2025
f0d6a8c
final markdown changes
uma-kumar Oct 9, 2025
9adb26c
Merge branch 'oracle-livelabs:main' into main
uma-kumar Oct 10, 2025
b2d8700
gaming markdown
uma-kumar Oct 10, 2025
75035f3
Merge branch 'main' of https://github.com/uma-kumar/developer
uma-kumar Dec 1, 2025
78b6133
creating lab changes for ai experience
uma-kumar Dec 1, 2025
58277d5
Merge branch 'oracle-livelabs:main' into main
uma-kumar Dec 5, 2025
a672904
updated intro.md
uma-kumar Dec 5, 2025
638258d
bolding sections
uma-kumar Dec 5, 2025
80e3878
Merge branch 'oracle-livelabs:main' into main
uma-kumar Jan 15, 2026
821f6ee
updating grammar for fsi, energy and mcp labs
uma-kumar Jan 15, 2026
7cf8540
Merge branch 'oracle-livelabs:main' into main
uma-kumar Jan 20, 2026
7e5ad60
updated task numbering and juptyer login info for energy ai exp
uma-kumar Jan 20, 2026
1f4d7a5
blocking sensitive info
uma-kumar Jan 21, 2026
ec6daae
Merge branch 'oracle-livelabs:main' into main
uma-kumar Jan 26, 2026
3bdcea2
adding view login info to mcp lab
uma-kumar Jan 26, 2026
9c97b16
Merge branch 'oracle-livelabs:main' into main
uma-kumar Jan 30, 2026
3eb4765
fixing rag question
uma-kumar Jan 30, 2026
0c87a3b
Merge branch 'oracle-livelabs:main' into main
uma-kumar Feb 2, 2026
bad66c6
updating grammar and spelling for retail, mfg and healthcare
uma-kumar Feb 2, 2026
ff6d26b
Update build.md
uma-kumar Feb 3, 2026
f7f2bf0
Merge branch 'main' of https://github.com/uma-kumar/developer
uma-kumar May 27, 2026
64523ce
typo in lab 1
uma-kumar Jun 5, 2026
a9a3435
fixing formatting issues
uma-kumar Jun 5, 2026
db5be7d
Merge branch 'oracle-livelabs:main' into main
uma-kumar Jun 25, 2026
88e0f68
adding construction engineering folder
uma-kumar Jun 25, 2026
7eed00d
Merge branch 'main' of https://github.com/uma-kumar/developer
uma-kumar Jun 25, 2026
5e87eed
construction engineering overhaul
deionlocklear Jun 29, 2026
b74f0c8
ConEng changes to lab 1
tayzheng Jul 1, 2026
295f52d
image and format check
tayzheng Jul 1, 2026
4fa4566
Merge pull request #1 from uma-kumar/Taylor-Edits-Lab-1
tayzheng Jul 1, 2026
f3536fa
updates
deionlocklear Jul 1, 2026
66ced24
Merge branch 'oracle-livelabs:main' into main
deionlocklear Jul 1, 2026
2ef5477
updates
deionlocklear Jul 1, 2026
0c48016
Merge branch 'main' into deion
deionlocklear Jul 1, 2026
13d5b95
Merge pull request #2 from uma-kumar/deion
uma-kumar Jul 1, 2026
9dc975c
Merge branch 'oracle-livelabs:main' into Taylor-Edits-Lab-1
tayzheng Jul 6, 2026
c1d3184
Merge pull request #3 from uma-kumar/Taylor-Edits-Lab-1
tayzheng Jul 6, 2026
22f6f98
format edits
tayzheng Jul 6, 2026
1532dff
Merge branch 'main' into Taylor-Edits-Lab-1
tayzheng Jul 6, 2026
e996471
Merge pull request #4 from uma-kumar/Taylor-Edits-Lab-1
tayzheng Jul 6, 2026
75eba32
formatting lab 1
uma-kumar Jul 6, 2026
d1dfdce
updates to lab4
deionlocklear Jul 7, 2026
b495faf
Update build.md
deionlocklear Jul 7, 2026
f7710ee
Merge pull request #5 from uma-kumar/deion
deionlocklear Jul 7, 2026
d7d30af
updated screenshots
deionlocklear Jul 9, 2026
d3b87ab
Merge pull request #6 from uma-kumar/deion
deionlocklear Jul 9, 2026
58c6329
updates
deionlocklear Jul 10, 2026
5830573
Merge pull request #7 from uma-kumar/deion
deionlocklear Jul 10, 2026
4943d5c
lab 1 updates
uma-kumar Jul 10, 2026
e4c3a8f
validation checks
uma-kumar Jul 10, 2026
0018c5e
Merge branch 'oracle-livelabs:main' into main
uma-kumar Jul 13, 2026
b04af0b
introduction updates
uma-kumar Jul 13, 2026
f40d921
Merge branch 'oracle-livelabs:main' into main
uma-kumar Jul 16, 2026
c13a553
markdown updates from feedback session: Lab 1
uma-kumar Jul 16, 2026
be6de68
updates
deionlocklear Jul 17, 2026
b123489
Merge pull request #8 from uma-kumar/deion
deionlocklear Jul 17, 2026
39c0d44
Merge branch 'oracle-livelabs:main' into main
uma-kumar Jul 20, 2026
c44135c
Merge branch 'oracle-livelabs:main' into main
uma-kumar Aug 5, 2026
0c13356
fix for notebook folder
uma-kumar Aug 5, 2026
42b241a
Merge branch 'oracle-livelabs:main' into main
uma-kumar Aug 5, 2026
3d2d773
instructions update lab 9
uma-kumar Aug 5, 2026
f4e33e8
markdown updates construction engineering
uma-kumar Aug 12, 2026
28011ac
lab 1 updates
uma-kumar Aug 13, 2026
56cde19
Merge branch 'oracle-livelabs:main' into main
uma-kumar Aug 14, 2026
ff25ca1
update model for task 6 and 9
uma-kumar Aug 14, 2026
b9f84fa
question 9
uma-kumar Aug 15, 2026
e3f960c
question 6 fix
uma-kumar Aug 15, 2026
83631dc
Merge branch 'oracle-livelabs:main' into main
uma-kumar Aug 25, 2026
ab1077b
update LLM in build lab for finance megalab
uma-kumar Aug 25, 2026
898af74
Merge branch 'main' of https://github.com/uma-kumar/developer
uma-kumar Aug 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
320 changes: 241 additions & 79 deletions dev-ai-app-dev-finance/build/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,41 +172,143 @@ With customer profiles in place, you will use OCI Generative AI to generate pers
Here’s what we’ll do:
- **Fetch Mock Loan Data**: Retrieve all mock loan data and combine them with customer data.
- **Build a Prompt**: Construct a structured prompt that combines the customer’s profile with loan requests instructing the LLM to evaluate and recommend a loan (APPROVE, REQUEST INFO, DENY) based solely on this data.
- **Use OCI Generative AI**: Send the prompt to the `meta.llama-3.2-90b-vision-instruct` model via OCI’s inference client, which will process the input and generate a response.
- **Use OCI Generative AI**: Send the prompt to the `cohere.command-r-plus-08-2024` model via OCI’s inference client, which will process the input and generate a response.
- **Format the Output**: Display the recommendations with styled headers and lists, covering evaluation, top picks, and explanations—making it easy to read and understand.

1. Copy and paste the code in a new cell:

```python
<copy>
# Fetch Mock Loan Data
cursor.execute("SELECT loan_id, loan_provider_name, loan_type, interest_rate, origination_fee, time_to_close, credit_score, debt_to_income_ratio, income, down_payment_percent, is_first_time_home_buyer FROM MOCK_LOAN_DATA")
df_mock_loans = pd.DataFrame(cursor.fetchall(), columns=["LOAN_ID", "LOAN_PROVIDER_NAME", "LOAN_TYPE", "INTEREST_RATE", "ORIGINATION_FEE", "TIME_TO_CLOSE", "CREDIT_SCORE", "DEBT_TO_INCOME_RATIO", "INCOME", "DOWN_PAYMENT_PERCENT", "IS_FIRST_TIME_HOME_BUYER"])
def generate_recommendations(customer_id, customer_json, df_policy_rules):
try:
return_request = customer_json.get("returnRequests", [{}])[0]
recommendation = return_request.get("recommendation", {})
reason = recommendation.get("reason", {})

cursor.execute("""
SELECT p.PRODUCT_NAME
FROM PRODUCTS p
JOIN ORDERITEMS oi ON p.PRODUCT_ID = oi.PRODUCT_ID
JOIN RETURN_REASONS rr ON oi.ORDERITEMS_ID = rr.ORDERITEMS_ID
WHERE rr.REASON_ID = :reason_id
""", {"reason_id": int(reason.get("reasonId", 0))})
product_result = cursor.fetchone()
product_name = product_result[0] if product_result else "Unknown Product"

available_rules_text = "\n".join(
f"{rule['RULE_ID']}: {rule['RULE_CODE']} | "
f"{rule['RULE_DESCRIPTION']} | Applies To: {rule['APPLIES_TO']}"
for rule in df_policy_rules.to_dict(orient="records")
)
customer_profile_text = "\n".join(
f"- {key.replace('_', ' ').title()}: {value}"
for key, value in customer_json.items()
if key not in ["returnRequests", "_metadata"]
)
return_request_text = "\n".join(
f"- {key.replace('_', ' ').title()}: {value}"
for key, value in return_request.items()
if key != "recommendation"
)
reason_text = f"- Return Reason: {reason.get('description', 'N/A')}"

# Generate Recommendations
def generate_recommendations(customer_id, customer_json, df_mock_loans):
loan_app = customer_json.get("loanApplications", [{}])[0]
available_loans_text = "\n".join([f"{loan['LOAN_ID']}: {loan['LOAN_TYPE']} | {loan['INTEREST_RATE']}% interest | Credit Score: {loan['CREDIT_SCORE']} | DTI: {loan['DEBT_TO_INCOME_RATIO']}" for loan in df_mock_loans.to_dict(orient='records')])
customer_profile_text = "\n".join([f"- {key.replace('_', ' ').title()}: {value}" for key, value in {**customer_json, **loan_app}.items() if key not in ["embedding_vector", "ai_response_vector", "chunk_vector"]])
prompt = f"""You are a Retail Decision AI. Use only the supplied context.
Evaluate the return request and recommend APPROVE, REQUEST INFO, or DENY.

prompt = f"""<s>[INST] <<SYS>>You are a Loan Approver AI. Use only the provided context to evaluate the applicant’s profile and recommend loans. Format results as plain text with numbered sections (1. Comprehensive Evaluation, 2. Top 3 Loan Recommendations, 3. Recommendations Explanations, 4. Final Suggestion). Use newlines between sections.</SYS>> [/INST]
[INST]Available Loan Options:\n{available_loans_text}\nApplicant's Full Profile:\n{customer_profile_text}\nTasks:\n1. Comprehensive Evaluation\n2. Top 3 Loan Recommendations\n3. Recommendations Explanations\n4. Final Suggestion</INST>"""
Available Policy Rules:
{available_rules_text}

print("Generating AI response...")
print(" ")

genai_client = oci.generative_ai_inference.GenerativeAiInferenceClient(config=oci.config.from_file(os.getenv("OCI_CONFIG_PATH", "~/.oci/config")), service_endpoint=os.getenv("ENDPOINT"))
chat_detail = oci.generative_ai_inference.models.ChatDetails(
compartment_id=os.getenv("COMPARTMENT_OCID"),
chat_request=oci.generative_ai_inference.models.GenericChatRequest(messages=[oci.generative_ai_inference.models.UserMessage(content=[oci.generative_ai_inference.models.TextContent(text=prompt)])], temperature=0.0, top_p=1.00),
serving_mode=oci.generative_ai_inference.models.OnDemandServingMode(model_id="meta.llama-3.2-90b-vision-instruct")
)
chat_response = genai_client.chat(chat_detail)
recommendations = chat_response.data.chat_response.choices[0].message.content[0].text
Customer Profile:
{customer_profile_text}

Return Request:
{return_request_text}
{reason_text}

Respond with these sections:

Suggested Action
- State APPROVE, REQUEST INFO, or DENY.

Comprehensive Evaluation
- Explain customer history, loyalty, return frequency, receipt, product condition,
return amount, and risk level.

Top 3 Recommendations
- Provide up to three specific recommendations with supporting policy rules.

Recommendations Explanation
- Explain how available evidence supports the recommendation.

Risk Management
- Identify safeguards such as additional evidence, partial refund, or store credit.

Actionable Steps
- List the next actions the customer or reviewer should take.

Keep the response under 500 words and use plain text."""

print("Generating AI response...")

genai_client = oci.generative_ai_inference.GenerativeAiInferenceClient(
config=oci.config.from_file(
os.getenv("OCI_CONFIG_PATH", "~/.oci/config")
),
service_endpoint=os.getenv("ENDPOINT"),
)

return recommendations
# Compatible with the OCI SDK currently installed in this notebook.
models = oci.generative_ai_inference.models
chat_request = models.CohereChatRequest(
api_format="COHERE",
message=prompt,
max_tokens=800,
temperature=0.0,
top_p=1.0,
)
chat_detail = models.ChatDetails(
compartment_id=os.getenv("COMPARTMENT_OCID"),
chat_request=chat_request,
serving_mode=models.OnDemandServingMode(
model_id="cohere.command-r-plus-08-2024"
),
)

recommendations = generate_recommendations(selected_customer_id, customer_json, df_mock_loans)
chat_response = genai_client.chat(chat_detail)
chat_result = chat_response.data.chat_response
return (
getattr(chat_result, "text", None)
or chat_result.choices[0].message.content[0].text
)

except oracledb.DatabaseError as e:
print(f"Database error: {e}")
return None
except Exception as e:
print(f"Unexpected error in generate_recommendations: {e}")
return None


print("Fetching policy rules...")
cursor.execute("""
SELECT rule_id, rule_code, rule_description, applies_to, is_active
FROM RETURN_POLICY_RULES
""")
df_policy_rules = pd.DataFrame(
cursor.fetchall(),
columns=[
"RULE_ID", "RULE_CODE", "RULE_DESCRIPTION",
"APPLIES_TO", "IS_ACTIVE",
],
)

recommendations = generate_recommendations(
selected_customer_id,
customer_json,
df_policy_rules,
)

print("\nAI Recommendation:\n")
print(recommendations)
</copy>
```
Expand Down Expand Up @@ -351,114 +453,174 @@ This step:

```python
<copy>
question = "What 4th loan would James qualify for?"

def vectorize_question(q):
# Fetch loan data needed by the RAG prompt.
cursor.execute("""
SELECT
loan_id,
loan_provider_name,
loan_type,
interest_rate,
origination_fee,
time_to_close,
credit_score,
debt_to_income_ratio,
income,
down_payment_percent,
is_first_time_home_buyer
FROM MOCK_LOAN_DATA
""")

df_mock_loans = pd.DataFrame(
cursor.fetchall(),
columns=[
"LOAN_ID",
"LOAN_PROVIDER_NAME",
"LOAN_TYPE",
"INTEREST_RATE",
"ORIGINATION_FEE",
"TIME_TO_CLOSE",
"CREDIT_SCORE",
"DEBT_TO_INCOME_RATIO",
"INCOME",
"DOWN_PAYMENT_PERCENT",
"IS_FIRST_TIME_HOME_BUYER",
],
)

question = "What 4th loan would James qualify for?"


def vectorize_question(q):
cursor.execute("""
SELECT dbms_vector_chain.utl_to_embedding(
:q,
JSON('{"provider":"database","model":"DEMO_MODEL","dimensions":384}')
) FROM DUAL
""", {'q': q})
)
FROM DUAL
""", {"q": q})
return cursor.fetchone()[0]

print("Processing your question using AI Vector Search across chunked recommendations...")

try:
print("Processing your question using AI Vector Search across chunked recommendations...")

try:
q_vec = vectorize_question(question)

# Retrieve top recommendation chunks (across all sizes) for this customer
cursor.execute("""
SELECT CHUNK_ID, CHUNK_TEXT
FROM LOAN_CHUNK
WHERE CUSTOMER_ID = :cust_id
AND CHUNK_VECTOR IS NOT NULL
ORDER BY VECTOR_DISTANCE(CHUNK_VECTOR, :qv, COSINE)
FETCH FIRST 4 ROWS ONLY
""", {'cust_id': selected_customer_id, 'qv': q_vec})
""", {"cust_id": selected_customer_id, "qv": q_vec})

retrieved = [
(r[0], r[1].read() if isinstance(r[1], oracledb.LOB) else r[1])
for r in cursor.fetchall()
(
row[0],
row[1].read() if isinstance(row[1], oracledb.LOB) else row[1],
)
for row in cursor.fetchall()
]

if not retrieved:
# Fallback to full text as one chunk
retrieved = [(0, recommendations)]

# Prepare clean context for the LLM
cleaned = [re.sub(r'[^\w\s\d.,\-\'"]', ' ', t).strip() for _, t in retrieved]
cleaned = [
re.sub(r"""[^\w\s\d.,\-\'"]""", " ", text).strip()
for _, text in retrieved
]
docs_as_one_string = "\n=========\n".join(cleaned) + "\n=========\n"

# Rebuild available loans + customer profile
available_loans_text = "\n".join(
[f"{loan['LOAN_ID']}: {loan['LOAN_TYPE']} | {loan['INTEREST_RATE']}% interest | "
f"Credit Score: {loan['CREDIT_SCORE']} | DTI: {loan['DEBT_TO_INCOME_RATIO']} | "
f"Origination Fee: ${loan['ORIGINATION_FEE']} | Time to Close: {loan['TIME_TO_CLOSE']} days"
for loan in df_mock_loans.to_dict(orient='records')]
f"{loan['LOAN_ID']}: {loan['LOAN_TYPE']} | "
f"{loan['INTEREST_RATE']}% interest | "
f"Credit Score: {loan['CREDIT_SCORE']} | "
f"DTI: {loan['DEBT_TO_INCOME_RATIO']} | "
f"Income Required: ${loan['INCOME']} | "
f"Origination Fee: ${loan['ORIGINATION_FEE']} | "
f"Time to Close: {loan['TIME_TO_CLOSE']} days"
for loan in df_mock_loans.to_dict(orient="records")
)

loan_app = customer_json.get("loanApplications", [{}])[0]
customer_profile_text = "\n".join(
[f"- {k.replace('_',' ').title()}: {v}"
for k, v in {**customer_json, **loan_app}.items()
if k not in ["embedding_vector","ai_response_vector","chunk_vector"]]
f"- {key.replace('_', ' ').title()}: {value}"
for key, value in {**customer_json, **loan_app}.items()
if key not in [
"embedding_vector",
"ai_response_vector",
"chunk_vector",
]
)

rag_prompt = f"""\
<s>[INST] <<SYS>>
You are AI Loan Guru. Use only the provided context to answer. Do not mention sources outside of the provided context.
Do NOT provide warnings, disclaimers, or exceed the specified response length.
Keep under 300 words. Be specific and actionable. Have the ability to respond in Spanish, French, Italian, German, and Portuguese if asked.
<</SYS>> [/INST]
[INST]
Question: "{question}"
rag_prompt = f"""You are AI Loan Guru.
Use only the provided context.

Question:
{question}

# Context (top chunks from prior AI recommendations):
{docs_as_one_string}
Retrieved Recommendation Context:
{docs_as_one_string}

# Available Loan Options:
{available_loans_text}
Available Loan Options:
{available_loans_text}

# Applicant Profile:
{customer_profile_text}
Applicant Profile:
{customer_profile_text}

Tasks:
1) Provide a direct answer to the question.
2) Briefly justify based on profile + loan options.
[/INST]"""
Tasks:
1. Answer the question directly.
2. Identify the fourth qualifying loan, if one exists.
3. Justify it using credit score, DTI, income, and eligibility requirements.
4. If no fourth loan qualifies, explain why.

Keep the answer under 300 words."""

print("Generating AI response...")

genai_client = oci.generative_ai_inference.GenerativeAiInferenceClient(
config=oci.config.from_file(os.getenv("OCI_CONFIG_PATH","~/.oci/config")),
service_endpoint=os.getenv("ENDPOINT")
config=oci.config.from_file(
os.getenv("OCI_CONFIG_PATH", "~/.oci/config")
),
service_endpoint=os.getenv("ENDPOINT"),
)

chat_detail = oci.generative_ai_inference.models.ChatDetails(
compartment_id=os.getenv("COMPARTMENT_OCID"),
chat_request=oci.generative_ai_inference.models.GenericChatRequest(
messages=[oci.generative_ai_inference.models.UserMessage(
content=[oci.generative_ai_inference.models.TextContent(text=rag_prompt)]
)],
messages=[
oci.generative_ai_inference.models.UserMessage(
content=[
oci.generative_ai_inference.models.TextContent(
text=rag_prompt
)
]
)
],
max_tokens=800,
temperature=0.0,
top_p=0.90
top_p=0.9,
),
serving_mode=oci.generative_ai_inference.models.OnDemandServingMode(
model_id="meta.llama-3.2-90b-vision-instruct"
)
model_id="meta.llama-3.3-70b-instruct"
),
)

chat_response = genai_client.chat(chat_detail)
ai_response = chat_response.data.chat_response.choices[0].message.content[0].text
ai_response = re.sub(r'[^\w\s\d.,\-\'"]', ' ', ai_response)

print("\n🤖 AI Loan Guru Response:")
print("\n🤖 AI Loan Guru Response:\n")
print(ai_response)

# Print which chunks were retrieved (for transparency/debug)
print("\n📑 Retrieved Chunks Used in Response:")
for cid, text in retrieved:
preview = text[:140].replace("\n", " ") + ("..." if len(text) > 140 else "")
print(f"[Chunk {cid}] : {preview}")
for chunk_id, text in retrieved:
preview = text[:140].replace("\n", " ")
if len(text) > 140:
preview += "..."
print(f"[Chunk {chunk_id}] {preview}")

except Exception as e:
except Exception as e:
print(f"RAG flow error: {e}")
</copy>
```
Expand Down
Loading