Skip to content

Commit 0b5bdd2

Browse files
committed
Add financial profiles and conversation prompts for retail banking
1 parent 98d9cd2 commit 0b5bdd2

19 files changed

+10091
-315
lines changed

Usage_Examples/basic_usage.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66
import json
77
from dotenv import load_dotenv
8-
8+
TEMPLATE_NAME= "templates/financial_retail_banking/"
99
# Add parent directory to path to import the library
1010
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
1111

@@ -26,12 +26,12 @@ def main():
2626
# Configure the library
2727
missing = wsd.set_config(
2828
API_KEY=api_key, # Use API key from environment variable
29-
template_client_prompt="templates/financial01/prompts/financial_client_01.j2",
30-
template_advisor_prompt="templates/financial01/prompts/financial_advisor_01.j2",
31-
file_profiles="templates/financial01/profiles/financial_sample01_5.json",
32-
file_output="templates/financial01/outputs/test_dataset01_5.json",
33-
model_client="gpt-4o-mini",
34-
model_advisor="gpt-4o-mini",
29+
template_client_prompt=TEMPLATE_NAME + "prompts/financial_client_01.j2",
30+
template_advisor_prompt=TEMPLATE_NAME + "prompts/financial_advisor_01.j2",
31+
file_profiles=TEMPLATE_NAME + "profiles/retail_banking_5.json",
32+
file_output=TEMPLATE_NAME + "outputs/test_dataset01_5b.json",
33+
model_client="gpt-4o",
34+
model_advisor="gpt-4o",
3535
# Optional parameters with custom values
3636
temperature_client=0.8,
3737
max_recommended_questions=10

templates/financial01/outputs/test_dataset01_5.json

Lines changed: 43 additions & 302 deletions
Large diffs are not rendered by default.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
"""
2+
Create a Retail Banking Conversation Dataset
3+
===========================================
4+
5+
This module demonstrates how to use the WizardSData library to generate
6+
synthetic conversational datasets for retail banking scenarios.
7+
8+
Example:
9+
To run this script directly::
10+
11+
$ python create_dataset.py
12+
13+
Notes:
14+
- Requires an OPENAI_API_KEY in config.env
15+
- Uses the financial retail banking templates
16+
- Creates a dataset based on the retail_banking_160.json profiles
17+
"""
18+
import os
19+
import sys
20+
import json
21+
from dotenv import load_dotenv
22+
23+
# Define the template directory
24+
TEMPLATE_NAME = "templates/financial_retail_banking/"
25+
26+
# Add parent directory to path to import the library
27+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
28+
29+
import wizardsdata as wsd
30+
31+
def main():
32+
"""
33+
Generate a retail banking conversation dataset using WizardSData.
34+
35+
This function demonstrates the complete workflow from configuration to generation
36+
of financial conversations between clients and advisors.
37+
38+
Steps:
39+
1. Load API credentials from environment
40+
2. Configure the WizardSData library
41+
3. Validate the configuration
42+
4. Generate conversations
43+
5. Report results
44+
45+
Returns:
46+
None
47+
48+
Raises:
49+
EnvironmentError: If the OPENAI_API_KEY is not found in environment variables
50+
"""
51+
# Load environment variables from config.env
52+
env_path = os.path.join(os.path.dirname(__file__), '../..', 'config.env')
53+
load_dotenv(env_path)
54+
55+
# Get API key from environment
56+
api_key = os.getenv("OPENAI_API_KEY")
57+
if not api_key:
58+
print("ERROR: OPENAI_API_KEY not found in environment variables. Check your config.env file.")
59+
return
60+
61+
# Configure the library with required parameters
62+
missing = wsd.set_config(
63+
# Authentication settings
64+
API_KEY=api_key,
65+
66+
# Template paths define conversation behavior
67+
template_client_prompt=TEMPLATE_NAME + "prompts/financial_client_01.j2",
68+
template_advisor_prompt=TEMPLATE_NAME + "prompts/financial_advisor_01.j2",
69+
70+
# Input/Output file paths
71+
file_profiles=TEMPLATE_NAME + "profiles/retail_banking_1.json",
72+
file_output=TEMPLATE_NAME + "outputs/retail_banking_dataset_11.json",
73+
74+
# Model configuration
75+
model_client="gpt-4o",
76+
model_advisor="gpt-4o",
77+
78+
# Conversation parameters
79+
temperature_client=0.8,
80+
max_recommended_questions=4
81+
)
82+
83+
# Check for missing parameters
84+
if missing:
85+
print(f"Missing configuration parameters: {', '.join(missing)}")
86+
return
87+
88+
# Display current configuration
89+
config = wsd.get_config()
90+
print("Current configuration:")
91+
# Mask API key for security when printing
92+
masked_config = {**config, "API_KEY": "********" if "API_KEY" in config else None}
93+
print(json.dumps(masked_config, indent=2))
94+
95+
# Check if configuration is valid
96+
if not wsd.is_config_valid():
97+
print("Configuration is not valid.")
98+
return
99+
100+
# Start generating conversations
101+
print("Starting conversation generation...")
102+
success = wsd.start_generation()
103+
104+
if success:
105+
print("Conversations generated successfully!")
106+
else:
107+
print("Failed to generate conversations.")
108+
109+
110+
if __name__ == "__main__":
111+
main()
6 KB
Binary file not shown.

templates/financial_retail_banking/outputs/retail_banking_dataset_1.json

Lines changed: 5679 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[
2+
{
3+
"id_conversation": "c27ad6cc-363a-4036-ac5b-57df17495f1f",
4+
"topic": "Pay off mortgage within the next 5 years",
5+
"sequence": 0,
6+
"rol1": "Hi there!",
7+
"rol2": "Hello! It's great to meet you. How can I assist you today with your mortgage or financial planning needs? Are you looking to buy a home, refinance, or something else?"
8+
},
9+
{
10+
"id_conversation": "c27ad6cc-363a-4036-ac5b-57df17495f1f",
11+
"topic": "Pay off mortgage within the next 5 years",
12+
"sequence": 2,
13+
"rol1": "I'm looking to pay off my mortgage within the next 5 years. Any tips?",
14+
"rol2": "That's a great goal! Paying off your mortgage early can save you a lot in interest payments and give you financial freedom. To better tailor my advice, could you tell me a bit more about your current mortgage situation? For example, what's the remaining balance, interest rate, and monthly payment? Also, do you have any other financial commitments or goals that I should consider when giving advice?"
15+
},
16+
{
17+
"id_conversation": "c27ad6cc-363a-4036-ac5b-57df17495f1f",
18+
"topic": "Pay off mortgage within the next 5 years",
19+
"sequence": 4,
20+
"rol1": "Sure! I have about \u20ac150,000 left on my mortgage with a 3% interest rate. My monthly payment is around \u20ac1,000. Besides paying off the mortgage, I'm mainly focused on maintaining my savings and tech stocks.",
21+
"rol2": ""
22+
}
23+
]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[
2+
{
3+
"id_conversation": "80467d7f-6b59-4814-ac22-3447d19f5348",
4+
"topic": "Pay off mortgage within the next 5 years",
5+
"sequence": 0,
6+
"rol1": "Hi there!",
7+
"rol2": "Hello! It's great to meet you. How can I assist you with your mortgage needs today? Are you looking to buy a home, refinance, or something else?"
8+
},
9+
{
10+
"id_conversation": "80467d7f-6b59-4814-ac22-3447d19f5348",
11+
"topic": "Pay off mortgage within the next 5 years",
12+
"sequence": 2,
13+
"rol1": "I'm looking to pay off my mortgage in the next 5 years. Any advice on how I can improve my saving and investment strategy to achieve that?",
14+
"rol2": "That sounds like a great goal! Paying off your mortgage early can save you a lot in interest and give you financial freedom. To give you the best advice, I need to understand a bit more about your current financial situation. Could you tell me about your current mortgage balance, interest rate, and any other financial commitments you have? Additionally, how much are you currently saving or investing each month?"
15+
},
16+
{
17+
"id_conversation": "80467d7f-6b59-4814-ac22-3447d19f5348",
18+
"topic": "Pay off mortgage within the next 5 years",
19+
"sequence": 4,
20+
"rol1": "Sure! My current mortgage balance is about \u20ac120,000 with a 3% interest rate. I don't have any other major financial commitments right now. I save around \u20ac500 monthly and also have some tech stocks.",
21+
"rol2": "Thanks for sharing that information. Here are a few steps you might consider to help pay off your mortgage in the next 5 years:\n\n1. **Increase Monthly Payments:** If possible, increase your monthly mortgage payments. Even a small increase can significantly reduce the term of your loan and the interest paid over time. You might want to allocate some of your monthly savings towards this.\n\n2. **Lump Sum Payments:** Consider making lump sum payments whenever you have extra cash, such as bonuses or tax refunds. This can directly reduce your principal balance.\n\n3. **Investment Strategy:** Assess your tech stocks' performance and risk. If they are performing well, you might consider selling a portion to pay down your mortgage, especially if the returns are lower than the interest saved by paying off the mortgage early.\n\n4. **Budget Review:** Review your budget to identify areas where you can cut back and redirect those funds to your mortgage.\n\n5. **Emergency Fund:** Ensure you maintain an emergency fund to avoid financial strain if unexpected expenses arise. This will prevent you from having to take on new debt.\n\n6. **Consult Your Lender:** Check if there are any penalties for early repayment on your mortgage. Some lenders charge fees for paying off a mortgage early, which could affect your strategy.\n\n7. **Automate Payments:** Set up automatic transfers to ensure you're consistently making higher payments without having to think about it each month.\n\nWould you like more details on any of these steps, or is there anything else you're considering?"
22+
},
23+
{
24+
"id_conversation": "80467d7f-6b59-4814-ac22-3447d19f5348",
25+
"topic": "Pay off mortgage within the next 5 years",
26+
"sequence": 6,
27+
"rol1": "Increasing monthly payments sounds like a good start. I'm also curious about how to manage my tech stocks. Should I sell some to pay off the mortgage faster?",
28+
"rol2": ""
29+
}
30+
]

0 commit comments

Comments
 (0)