Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add my use case - personal finance assistant #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions tool_use/personal-finance-assistant/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Personal Finance Assistant

This use case demonstrates how to build a personal finance assistant using Anthropic's language models. The assistant can help users track their expenses, create budgets, calculate investment returns, and provide personalized financial advice.

## Features

- Expense Tracking: Users can input their expenses, categorize them, and get insights into their spending habits.
- Budgeting: The assistant can help users create and stick to a monthly or yearly budget based on their income and expenses.
- Investment Calculations: Users can input their investment details, and the assistant will calculate potential returns, risks, and provide recommendations.
- Financial Advice: Based on the user's financial situation, the assistant can offer personalized advice on saving, investing, and managing debt.

## Examples

The `examples/` folder contains sample code for implementing different features of the personal finance assistant:

- `budget_tracker.py`: A Python script that demonstrates how to track expenses and create budgets using Anthropic's language models.
- `investment_calculator.js`: A JavaScript file that shows how to calculate investment returns and provide recommendations based on user inputs.

## Usage

To use this use case, you'll need to have access to Anthropic's language models and follow the setup instructions in the main repository. Once set up, you can run the example scripts or integrate the functionality into your own applications.

## Contributing

Contributions to this use case are welcome! If you have ideas for additional features, improvements, or bug fixes, please open an issue or submit a pull request.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions tool_use/personal-finance-assistant/examples/budget_tracker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import anthropic

# Set up the Anthropic API client
client = anthropic.Client("YOUR_API_KEY")

# Define a function to track expenses
def track_expense(description, amount, category):
# Use the Anthropic language model to categorize the expense
response = client.completion(
prompt=f"Categorize the following expense: {description}",
max_tokens=50,
stop_sequences=[],
)
categorized_category = response.result["choice"]

# Store the expense in a database or file
with open("expenses.txt", "a") as f:
f.write(f"{description},{amount},{categorized_category}\n")

print(f"Expense '{description}' of ${amount} categorized as '{categorized_category}'")

# Example usage
track_expense("Grocery shopping at Whole Foods", 75.25, "Food")
track_expense("Paid rent for May", 1200.00, "Housing")
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const anthropic = require("@anthropic/client");

// Set up the Anthropic API client
const client = new anthropic.Client("YOUR_API_KEY");

// Define a function to calculate investment returns
async function calculateInvestmentReturns(initialInvestment, years, expectedReturn) {
const prompt = `
Calculate the potential returns for an initial investment of ${initialInvestment} over ${years} years with an expected annual return of ${expectedReturn}%.

Provide the calculation steps and the final amount in a clear and easy-to-understand format.
`;

const response = await client.complete({
prompt,
maxTokens: 500,
stopSequences: [],
});

console.log(response.result.choice);
}

// Example usage
calculateInvestmentReturns(10000, 10, 7);