Skip to content

Commit 74133a4

Browse files
committed
feat: implement Personal Financial AI Agent with LaTeX documentation and CI/CD integration
- Added GitHub Actions workflow for LaTeX document checks on main, develop, and relazione branches. - Updated .gitignore to exclude LaTeX build artifacts. - Created initial LaTeX files including main document, bibliography, and sections for abstract, introduction, architecture, implementation, RAG, interface, demo, and conclusion. - Developed a structured approach for retrieval-augmented generation in financial advisory. - Implemented a Streamlit-based web application for user interaction and financial profile management. - Established comprehensive testing infrastructure with unit and integration tests. - Configured Docker for containerized deployment and streamlined installation instructions.
1 parent 86f6683 commit 74133a4

File tree

12 files changed

+704
-16
lines changed

12 files changed

+704
-16
lines changed

.github/workflows/check-latex-document.yaml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ on:
55
branches:
66
- main
77
- develop
8+
- relazione
89
push:
910
branches:
1011
- main
11-
- develop
12+
- relazione
1213
workflow_dispatch:
1314

1415
jobs:
@@ -18,22 +19,22 @@ jobs:
1819
- name: Set up Git repository
1920
uses: actions/checkout@v4
2021

21-
# - name: Compile main LaTeX document
22-
# uses: xu-cheng/latex-action@v3
23-
# with:
24-
# working_directory: latex
25-
# root_file: main.tex
22+
- name: Compile main LaTeX document
23+
uses: xu-cheng/latex-action@v3
24+
with:
25+
working_directory: latex
26+
root_file: main.tex
2627

27-
# - name: Check if PDF was created
28-
# run: |
29-
# ls -la
30-
# ls -la latex
31-
# if [ -f "latex/main.pdf" ]; then
32-
# echo "PDF built successfully."
33-
# else
34-
# echo "PDF build failed." >&2
35-
# exit 1
36-
# fi
28+
- name: Check if PDF was created
29+
run: |
30+
ls -la
31+
ls -la latex
32+
if [ -f "latex/main.pdf" ]; then
33+
echo "PDF built successfully."
34+
else
35+
echo "PDF build failed." >&2
36+
exit 1
37+
fi
3738
3839
# - name: Commit and push pdf
3940
# run: |

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,20 @@ qdrant_storage/
7070
*.temp
7171
tmp/
7272
temp/
73+
74+
# Latex
75+
**/*.synctex.gz
76+
**/*.log
77+
**/*.dvi
78+
**/*.bbl
79+
**/main.pdf
80+
**/*.blg
81+
**/*.aux
82+
**/*.log
83+
**/*.out
84+
**/*.bcf
85+
**/*.run.xml
86+
**/comment.cut
87+
**/main.out
88+
**/*.fdb_latexmk
89+
**/*.fls

latex/bibliography.bib

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@article{lewis2019retrieval,
2+
title={Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks},
3+
author={Lewis, Patrick and Perez, Ethan and Piktus, Aleksandra and Schwenk, Holger and Schwab, Diarmuid and Kiela, Douwe and Riedel, Sebastian},
4+
journal={arXiv preprint arXiv:2005.11401},
5+
year={2019}
6+
}
7+
8+
@article{brown2020language,
9+
title={Language Models are Few-Shot Learners},
10+
author={Brown, Tom B and Mann, Benjamin and Ryder, Nick and Subbiah, Melanie and Kaplan, Jared D and Dhariwal, Prafulla and Neelakantan, Arvind and Shyam, Pranav and Sastry, Girish and Askell, Amanda and others},
11+
journal={arXiv preprint arXiv:2005.14165},
12+
year={2020}
13+
}

latex/main.tex

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
% Emerald Publishing - Construction Innovation Submission Template
2+
% by Oleksandr Melnyk
3+
% Ver 0.0.4
4+
% Based on: https://www.emeraldgrouppublishing.com/journal/ci#author-guidelines
5+
6+
\documentclass{article}
7+
8+
\usepackage[english]{babel}
9+
10+
% Set page size and margins
11+
% Replace `letterpaper' with `a4paper' for UK/EU standard size
12+
\usepackage[a4paper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
13+
14+
% Useful packages
15+
\usepackage{amssymb}
16+
\usepackage{siunitx}
17+
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}
18+
\usepackage{cleveref}
19+
\usepackage[utf8]{inputenc}
20+
\usepackage[right]{lineno}
21+
\usepackage{csquotes}
22+
\usepackage{booktabs}
23+
\usepackage{longtable}
24+
\usepackage{adjustbox}
25+
\usepackage{graphicx}
26+
\usepackage{array}
27+
\usepackage{url}
28+
\usepackage{titlesec}
29+
%\usepackage[compatibility=false]{caption}
30+
\usepackage{authblk}
31+
\usepackage{xcolor} % Load the xcolor package for color options
32+
\usepackage{listings}
33+
\usepackage{makecell}
34+
35+
\renewcommand{\thetable}{\Roman{table}}
36+
37+
% Define a new format for \subsection
38+
\titleformat{\subsection}
39+
{\mdseries\itshape\large} % Medium series, italic shape, and large font size
40+
{\thesubsection}{1em}{} % Numbering, spacing, and the section title itself
41+
42+
43+
% Emerald Harvard Citation Style
44+
45+
\usepackage[english]{babel}
46+
\usepackage[style=authoryear,backend=biber,natbib=true,maxcitenames=2,uniquelist=false]{biblatex}
47+
\addbibresource{bibliography.bib} % your .bib file
48+
49+
% Customizing biblatex for Harvard style
50+
\DeclareNameAlias{sortname}{family-given}
51+
\DeclareNameAlias{default}{family-given}
52+
53+
\renewbibmacro{in:}{}
54+
\DeclareFieldFormat[article]{title}{\mkbibquote{#1}\addcomma}
55+
\DeclareFieldFormat[book]{title}{\mkbibemph{#1}\addcomma}
56+
\DeclareFieldFormat[bookinbook]{title}{\mkbibemph{#1}\addcomma}
57+
\DeclareFieldFormat[inbook]{title}{\mkbibquote{#1}\addcomma}
58+
\DeclareFieldFormat[incollection]{title}{\mkbibquote{#1}\addcomma}
59+
\DeclareFieldFormat[inproceedings]{title}{\mkbibquote{#1}\addcomma}
60+
\DeclareFieldFormat[manual]{title}{\mkbibemph{#1}\addcomma}
61+
\DeclareFieldFormat[misc]{title}{\mkbibemph{#1}\addcomma}
62+
\DeclareFieldFormat[thesis]{title}{\mkbibemph{#1}\addcomma}
63+
\DeclareFieldFormat[unpublished]{title}{\mkbibquote{#1}\addcomma}
64+
\DeclareFieldFormat[patent]{title}{\mkbibemph{#1}\addcomma}
65+
\DeclareFieldFormat[report]{title}{\mkbibemph{#1}\addcomma}
66+
\DeclareFieldFormat[online]{title}{\mkbibquote{#1}\addcomma}
67+
\DeclareFieldFormat[software]{title}{\mkbibemph{#1}\addcomma}
68+
\DeclareFieldFormat[booklet]{title}{\mkbibemph{#1}\addcomma}
69+
\DeclareFieldFormat[periodical]{title}{\mkbibemph{#1}\addcomma}
70+
\DeclareFieldFormat[standard]{title}{\mkbibemph{#1}\addcomma}
71+
72+
\DeclareFieldFormat[article]{journaltitle}{\iffieldundef{shortjournal}{\mkbibemph{#1}\addcomma}{\mkbibemph{\printfield{shortjournal}}\addcomma}}
73+
\DeclareFieldFormat{volume}{\bibstring{volume}~#1}
74+
\DeclareFieldFormat{number}{\bibstring{number}~#1}
75+
76+
% Definitions for "Vol." and "No."
77+
\DefineBibliographyStrings{english}{
78+
volume = {Vol.},
79+
number = {No.}
80+
}
81+
82+
\renewbibmacro*{volume+number+eid}{%
83+
\printfield{volume}%
84+
\setunit*{\addspace}%
85+
\printfield{number}%
86+
\setunit{\addcomma\space}%
87+
\printfield{eid}}
88+
89+
\renewbibmacro*{journal+issuetitle}{%
90+
\usebibmacro{journal}%
91+
\setunit*{\addcomma\space}%
92+
\usebibmacro{volume+number+eid}%
93+
\setunit{\addcomma\space}%
94+
\usebibmacro{issue+date}}
95+
96+
\renewbibmacro*{publisher+location+date}{%
97+
\printlist{publisher}%
98+
\iflistundef{location}
99+
{\setunit*{\addcomma\space}}
100+
{\setunit*{\addcolon\space}}%
101+
\printlist{location}%
102+
\setunit*{\addcomma\space}%
103+
\usebibmacro{date}}
104+
105+
\renewcommand*{\bibpagespunct}{\addcomma\space}
106+
107+
% Customizing page field format to prevent duplication
108+
% \DeclareFieldFormat{pages}{%
109+
% \mkfirstpage[{\mkpageprefix[page]{#1}}]{#1}}
110+
111+
% Customizing citations for Harvard style
112+
\DeclareCiteCommand{\cite}[\mkbibparens]
113+
{\usebibmacro{prenote}}
114+
{\usebibmacro{citeindex}%
115+
\usebibmacro{cite}}
116+
{\multicitedelim}
117+
{\usebibmacro{postnote}}
118+
119+
\renewbibmacro*{cite:labelyear+extrayear}{%
120+
\iffieldundef{labelyear}
121+
{}
122+
{\printtext[bibhyperref]{%
123+
\printfield{labelyear}%
124+
\printfield{extrayear}}}}
125+
126+
\renewbibmacro*{cite:labeldate+extradate}{%
127+
\iffieldundef{labelyear}
128+
{}
129+
{\printtext[bibhyperref]{%
130+
\printfield{labelyear}%
131+
\printfield{extradate}}}}
132+
133+
\AtEveryBibitem{
134+
\clearfield{month}
135+
\clearfield{day}
136+
\ifentrytype{book}{
137+
\clearlist{location}
138+
}{}
139+
}
140+
141+
% Formatting "et al." in italics followed by a comma
142+
\DefineBibliographyStrings{english}{
143+
andothers = {\textit{et al.},}
144+
}
145+
146+
\DeclareFieldFormat[article]{volume}{\bibstring{jourvol}\addnbspace #1}
147+
\DeclareFieldFormat[article]{number}{\bibstring{number}\addnbspace #1}
148+
\DeclareFieldFormat[article]{volume}{Vol. #1}
149+
\DeclareFieldFormat[article]{number}{No. #1}
150+
% Customizing DOI field format to lowercase "doi"
151+
%\DeclareFieldFormat{doi}{\bibstring{doi}\addcolon\space\url{#1}}
152+
153+
% Customizing URL field format to "available at:"
154+
\DeclareFieldFormat{url}{\bibstring{available at}\addcolon\space\url{#1}}
155+
\DeclareFieldFormat{urldate}{\mkbibparens{accessed \addspace#1}}
156+
157+
% Customizing urldate to match the required format
158+
\DeclareFieldFormat{urldate}{%
159+
\mkbibparens{accessed\space%
160+
\thefield{urlday}\addspace%
161+
\mkbibmonth{\thefield{urlmonth}}\addspace%
162+
\thefield{urlyear}}}
163+
164+
% Configure cleveref
165+
\crefformat{figure}{#2Figure~#1#3}
166+
\Crefformat{figure}{#2Figure~#1#3}
167+
\crefformat{table}{#2Table~#1#3}
168+
\Crefformat{table}{#2Table~#1#3}
169+
\crefformat{section}{#2Section~#1#3}
170+
\Crefformat{section}{#2Section~#1#3}
171+
172+
%%% Flags, colors and comments
173+
\definecolor{dkred}{rgb}{.6,0,0}
174+
\definecolor{dkgreen}{rgb}{0,.5,0}
175+
\newif\ifdraft\drafttrue
176+
\newcommand{\displaycomment}[1]{{#1}} % inline
177+
\newcommand\hl[1]{{\color{dkred} #1}}
178+
\newcommand{\alt}{\uparrow}
179+
\newcommand{\olremark}[2]{{\color{dkgreen}(#1: #2)}}
180+
\newcommand{\varemark}[2]{{\color{dkred}(#1: #2)}}
181+
\newcommand{\ftremark}[2]{{\color{teal}(#1: #2)}}
182+
\newcommand{\pfremark}[2]{{\color{blue}(#1: #2)}}
183+
\newcommand{\fsremark}[2]{{\color{violet}(#1: #2)}}
184+
\newcommand{\acremark}[2]{{\color{purple}(#1: #2)}}
185+
\newcommand{\lnegremark}[2]{{\color{cyan}(#1: #2)}}
186+
\newcommand{\loliremark}[2]{{\color{orange}(#1: #2)}}
187+
\ifdraft
188+
\newcommand{\mmerenda}[1]{\varemark{MM}{#1}}
189+
\newcommand{\scolli}[1]{\olremark{SC}{#1}}
190+
\else
191+
\newcommand{\mmerenda}[1]{}
192+
\newcommand{\scolli}[1]{}
193+
\fi
194+
195+
196+
% Blocks of code
197+
\definecolor{codegreen}{rgb}{0,0.6,0}
198+
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
199+
\definecolor{codepurple}{rgb}{0.58,0,0.82}
200+
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
201+
202+
\lstdefinestyle{mystyle}{
203+
backgroundcolor=\color{backcolour},
204+
commentstyle=\color{codegreen},
205+
keywordstyle=\color{magenta},
206+
numberstyle=\tiny\color{codegray},
207+
stringstyle=\color{codepurple},
208+
basicstyle=\ttfamily\footnotesize,
209+
breakatwhitespace=false,
210+
breaklines=true,
211+
captionpos=b,
212+
keepspaces=true,
213+
numbers=left,
214+
numbersep=5pt,
215+
showspaces=false,
216+
showstringspaces=false,
217+
showtabs=false,
218+
tabsize=2
219+
}
220+
221+
\lstset{style=mystyle}
222+
223+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
224+
%Front Matter
225+
\author[1]{xxx}
226+
\author[2]{xxx}
227+
228+
\affil[1]{
229+
\url{xxx}
230+
}
231+
\affil[2]{
232+
\url{xxx}
233+
}
234+
235+
% Title
236+
\title{Personal Financial AI Agent}
237+
238+
\begin{document}
239+
\maketitle
240+
241+
\input{sections/01_abstract}
242+
\input{sections/02_introduction}
243+
\input{sections/03_architecture}
244+
\input{sections/04_implementation}
245+
\input{sections/05_rag}
246+
\input{sections/06_interface}
247+
\input{sections/07_demo}
248+
\input{sections/08_conclusion}
249+
250+
% \linenumbers % utilizzato per debug
251+
252+
\printbibliography
253+
254+
\end{document}

latex/sections/01_abstract.tex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
\section*{Abstract}
2+
3+
This paper presents the design, implementation, and evaluation of a Personal Financial AI Agent---a machine learning-based system designed to provide intelligent, personalized financial guidance to users. The system leverages large language models (LLMs) and retrieval-augmented generation (RAG) techniques to deliver contextualized financial advice, portfolio recommendations, and analysis. The agent supports multiple LLM providers, namely Ollama for local offline inference, Google Gemini for cloud-based solutions, and OpenAI for industry-standard capabilities, enabling users to choose between privacy-first approaches and feature-rich cloud solutions. A Streamlit-based web interface facilitates interactive conversations in multiple languages, providing an accessible entry point for diverse user bases. The system demonstrates proficiency in financial profile extraction from natural language conversations, comprehensive portfolio analysis, and Monte Carlo simulations for scenario planning and risk assessment. This comprehensive study details the system's architecture, implementation techniques, evaluation methodologies, and provides clear demonstration procedures for practitioners and researchers. The project showcases the practical application of conversational AI and retrieval-augmented generation in the financial advisory domain, demonstrating how modern AI techniques can democratize access to quality financial guidance.
4+
5+
\vspace{1em}
6+
7+
\noindent
8+
\textbf{Keywords:} Financial AI Agent, Large Language Models, Retrieval-Augmented Generation, Portfolio Analysis, Multi-provider LLM Support

latex/sections/02_introduction.tex

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
\section{Introduction}
2+
\label{sec:intro}
3+
4+
\subsection{Motivation and Problem Statement}
5+
6+
The democratization of financial services through digital platforms has created unprecedented opportunities for individuals to manage their wealth independently. However, effective financial planning remains a challenge for most people due to the complexity of modern financial instruments, market dynamics, and the personalized nature of financial goals. Traditional financial advisory services, while expert-driven, are often expensive and accessible only to high-net-worth individuals.
7+
8+
The recent advances in artificial intelligence, particularly in large language models (LLMs) and their ability to understand and generate human language, present a unique opportunity to democratize financial expertise \cite{brown2020language}. LLMs can process vast amounts of financial information, understand user context through natural conversation, and provide tailored recommendations based on individual circumstances. The integration of retrieval-augmented generation (RAG) with domain-specific knowledge further enhances the quality and reliability of AI-driven advisory systems \cite{lewis2019retrieval}.
9+
10+
This work addresses the challenge of creating an intelligent financial advisor system that can engage users in natural language conversations to understand their financial situation, extract relevant financial information from unstructured conversations, and provide evidence-based recommendations using historical financial data. Additionally, the system must respect user privacy through optional local offline inference while adapting to different user preferences for AI providers and languages. The system must validate and present portfolio recommendations with quantitative analysis, ensuring that suggestions are grounded in financial theory and historical evidence rather than abstract or unsupported claims.
11+
12+
\subsection{Contribution}
13+
14+
This project contributes to the field of fintech and applied AI in several ways. First, it presents a multi-provider LLM architecture supporting Ollama, Google Gemini, and OpenAI, enabling vendor-independent deployment. Second, it integrates RAG techniques with structured financial data to improve recommendation quality and factual accuracy. Third, it develops a comprehensive financial profile extraction system that operates through conversational interfaces rather than rigid forms. Fourth, it demonstrates a production-ready web application that illustrates practical AI application in financial services. Finally, it provides detailed evaluation methodologies and comprehensive testing frameworks suitable for financial AI systems.
15+
16+
\subsection{Document Structure}
17+
18+
The remainder of this paper is organized as follows. Section~\ref{sec:architecture} presents the overall system architecture and design principles, including the agent framework, data models, and retrieval systems. Section~\ref{sec:implementation} details the technical implementation of core components, including technology stack, agent design patterns, and configuration mechanisms. Section~\ref{sec:rag} discusses the retrieval-augmented generation system specifically for financial data, covering asset organization, embedding strategies, and integration with the agent. Section~\ref{sec:interface} describes the user interface and interaction design, including the Streamlit framework, conversation flows, and visualization components. Finally, Section~\ref{sec:demo} provides comprehensive instructions for running and testing the system in various configurations, along with troubleshooting guidance.

0 commit comments

Comments
 (0)