edoardob90 / finance-tracker-bot

A Telegram bot that helps with your personal finances
0 stars 0 forks source link

Add new records via natural language #13

Closed edoardob90 closed 1 year ago

edoardob90 commented 1 year ago

With OpenAI models that support function calling, we can add a "natural language mode" to add new records. This would really be a great new feature for the bot 🤖

A schematic flow is the following:

  1. When a user enters the /record menu, they can either use the category buttons as usual, or enter a prompt like Paid the bill: 30 euros, electricity, credit card.
  2. A chat completion is requested via OpenAI library, passing a suitable function definition. The returned completion object contains a function_call attribute with the function's name and arguments. The arguments represent the new record. We must keep track of that we're using a LLM to perform the record parsing. We store the resulting record as-is, a JSON string
  3. In the store() function (or a variant): the record is loaded and validated through the RecordSchema. If it's valid, then it's added to the user data storage, as usual

This depends on the changes made in #7 and #11 because we need the classes Record and RecordSchema.

Important additions to make

edoardob90 commented 1 year ago

The mechanism of allowing users is based on a manually edited list of Telegram user IDs added to config.toml. Later, there will be a menu in /settings to allow each user to log in with a secret question.

edoardob90 commented 1 year ago

Linked to #16