Last active
April 28, 2025 08:48
-
-
Save andrewkkchan/2cc601878ae5e0b9aa35a1a0b4dc729f to your computer and use it in GitHub Desktop.
llama_index_qa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from llama_index.llms.bedrock import Bedrock | |
llm = Bedrock( | |
model_id="anthropic.claude-3-sonnet-20250219-v1:0", | |
temperature=0, | |
) | |
question = ( | |
"I’m a 40-year-old investor with a moderate risk tolerance. " | |
"I have $50,000 to invest, and I would like to grow it over the next 10 years " | |
"for my retirement. Can you run financial simulations (like Monte Carlo) " | |
"to estimate potential returns and recommend suitable fund products?" | |
) | |
prompt = ( | |
"You are a chartered financial planner.\n" | |
"Think step-by-step, run an internal Monte-Carlo simulation " | |
"(10 000 trials, 7 % mean, 15 % σ, 10 yr horizon), then output:\n" | |
"• Simulated median + 10th & 90th percentiles\n" | |
"• Key assumptions/caveats (1-2 sentences)\n" | |
"• 2-3 low-cost funds fit for moderate risk\n" | |
"• Quick next-step checklist\n" | |
"Hide your chain-of-thought. ≤ 250 words.\n\n" | |
f"{question}" | |
) | |
response = llm.complete(prompt) | |
print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment