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

Fix categorize_transactions to account for variations in LLM response, added docs #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

varunsharma27
Copy link

@varunsharma27 varunsharma27 commented Oct 11, 2024

Nice project, was just playing around with it but faced issues. Fixed in this PR, added docs to help others.

Comment on lines 299 to +304
"def categorize_transactions(transaction_names, llm):\n",
" response = llm.invoke(\"Can you add an appropriate category to the following expenses. For example: Spotify AB by Adyen - Entertainment, Beta Boulders Ams Amsterdam Nld - Sport, etc.. Categories should be less than 4 words. \" + transaction_names)\n",
" response = response.split('\\n')\n",
" original_response = llm.invoke(\"Can you add an appropriate category to the following expenses. For example: Spotify AB by Adyen - Entertainment, Beta Boulders Ams Amsterdam Nld - Sport, etc.. Categories should be less than 4 words. \" + transaction_names)\n",
" response = original_response.split('\\n')\n",
"\n",
" # Keep only the lines in between blank lines (removing the explaination lines at the beginning and end of the response)\n",
" blank_indexes = [index for index in range(len(response)) if response[index] == '']\n",
" if len(blank_indexes) == 1:\n",
" response = response[(blank_indexes[0] + 1):]\n",
" else:\n",
" response = response[(blank_indexes[0] + 1) : blank_indexes[1]]\n",
" # Keep only the lines with categories (removing the explaination lines at the beginning and end of the response)\n",
" response = [item for item in response if item != '' and ' - ' in item]\n",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix categorize_transactions to account for variations in LLM response

@varunsharma27 varunsharma27 changed the title Improvements Fix categorize_transactions to account for variations in LLM response, added docs Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant