mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 04:55:20 +02:00
Fix transactions tool call for chat
This commit is contained in:
parent
bacab94a1b
commit
5baf258a32
1 changed files with 3 additions and 2 deletions
|
@ -134,7 +134,8 @@ class Assistant::Function::GetTransactions < Assistant::Function
|
||||||
def call(params = {})
|
def call(params = {})
|
||||||
search_params = params.except("order", "page")
|
search_params = params.except("order", "page")
|
||||||
|
|
||||||
transactions_query = family.transactions.visible.search(search_params)
|
search = Transaction::Search.new(family, filters: search_params)
|
||||||
|
transactions_query = search.transactions_scope
|
||||||
pagy_query = params["order"] == "asc" ? transactions_query.chronological : transactions_query.reverse_chronological
|
pagy_query = params["order"] == "asc" ? transactions_query.chronological : transactions_query.reverse_chronological
|
||||||
|
|
||||||
# By default, we give a small page size to force the AI to use filters effectively and save on tokens
|
# By default, we give a small page size to force the AI to use filters effectively and save on tokens
|
||||||
|
@ -149,7 +150,7 @@ class Assistant::Function::GetTransactions < Assistant::Function
|
||||||
limit: default_page_size
|
limit: default_page_size
|
||||||
)
|
)
|
||||||
|
|
||||||
totals = family.income_statement.totals(transactions_scope: transactions_query)
|
totals = search.totals
|
||||||
|
|
||||||
normalized_transactions = paginated_transactions.map do |txn|
|
normalized_transactions = paginated_transactions.map do |txn|
|
||||||
entry = txn.entry
|
entry = txn.entry
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue