optimization-hashira commited on
Commit
a059241
·
1 Parent(s): 3f43e82

docker improvements

Browse files
Files changed (8) hide show
  1. .gitignore +4 -1
  2. Dockerfile +48 -0
  3. Dockerfile.fastapi +0 -14
  4. Dockerfile.streamlit +0 -15
  5. README.md +12 -11
  6. docker-compose.yaml +0 -138
  7. requirements.txt +2 -1
  8. supervisord.conf +82 -0
.gitignore CHANGED
@@ -3,4 +3,7 @@ agents/__pycache__/*
3
  data_ingestion/__pycache__/*
4
  faiss_index_store
5
  orchestrator/__pycache__
6
-
 
 
 
 
3
  data_ingestion/__pycache__/*
4
  faiss_index_store
5
  orchestrator/__pycache__
6
+ supervisord.log
7
+ *.log
8
+ Dockerfile.*
9
+ docker-compose.yaml
Dockerfile ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install system dependencies (including ffmpeg for audio)
6
+ RUN apt-get update && \
7
+ apt-get install -y --no-install-recommends \
8
+ build-essential \
9
+ gcc \
10
+ ffmpeg \
11
+ supervisor && \ # Install supervisor system package
12
+ apt-get clean && \
13
+ rm -rf /var/lib/apt/lists/*
14
+
15
+ COPY requirements.txt .
16
+ RUN pip install --no-cache-dir -r requirements.txt
17
+
18
+ # Copy all application code
19
+ # Ensure these paths correctly copy all your necessary modules
20
+ COPY ./agents /app/agents
21
+ COPY ./data_ingestion /app/data_ingestion
22
+ COPY ./orchestrator /app/orchestrator
23
+ COPY ./streamlit /app/streamlit
24
+ COPY ./example_portfolio.json /app/example_portfolio.json # For orchestrator and streamlit
25
+
26
+ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
27
+
28
+
29
+ ENV GEMINI_MODEL_NAME="gemini-1.5-flash-latest"
30
+ ENV WHISPER_MODEL_SIZE="small"
31
+ ENV FAISS_INDEX_PATH="/app/faiss_index_store"
32
+
33
+
34
+ ENV AGENT_API_URL="http://localhost:8001"
35
+ ENV AGENT_SCRAPING_URL="http://localhost:8002"
36
+ ENV AGENT_RETRIEVER_URL="http://localhost:8003"
37
+ ENV AGENT_ANALYSIS_URL="http://localhost:8004"
38
+ ENV AGENT_LANGUAGE_URL="http://localhost:8005"
39
+ ENV AGENT_VOICE_URL="http://localhost:8006"
40
+ ENV ORCHESTRATOR_URL="http://localhost:8000"
41
+
42
+ RUN mkdir -p /app/faiss_index_store && \
43
+ chown -R nobody:nogroup /app/faiss_index_store || true # Example, adjust user/group as needed
44
+
45
+
46
+ EXPOSE 8501
47
+
48
+ CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
Dockerfile.fastapi DELETED
@@ -1,14 +0,0 @@
1
- FROM python:3.10
2
-
3
- WORKDIR /app
4
-
5
- COPY requirements.txt .
6
-
7
- RUN apt-get update && apt-get install -y --no-install-recommends build-essential gcc && \
8
- pip install --no-cache-dir -r requirements.txt
9
-
10
- COPY . .
11
-
12
- EXPOSE 8000
13
-
14
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Dockerfile.streamlit DELETED
@@ -1,15 +0,0 @@
1
- FROM python:3.10-slim
2
-
3
- WORKDIR /app
4
-
5
- COPY requirements.txt .
6
-
7
- RUN apt-get update && apt-get install -y --no-install-recommends build-essential gcc ffmpeg && \
8
- pip install --no-cache-dir -r requirements.txt
9
-
10
- COPY streamlit ./streamlit
11
- COPY example_portfolio.json .
12
-
13
- EXPOSE 8501
14
-
15
- CMD ["streamlit", "run", "streamlit/app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,15 +1,14 @@
1
  ---
2
- title: AI Financial Assistant
3
- emoji: 📈
4
- colorFrom: blue
5
- colorTo: green
6
  sdk: docker
7
- app_port: 8501
8
  pinned: false
9
-
10
  ---
11
 
12
- # AI Financial Assistant - Morning Market Brief
13
 
14
  This application provides a voice-interactive morning market brief. It uses several AI agents for:
15
  - Speech-to-Text (STT)
@@ -21,6 +20,8 @@ This application provides a voice-interactive morning market brief. It uses seve
21
  - Language Generation (LLM)
22
  - Text-to-Speech (TTS)
23
 
 
 
24
  ## How to Use
25
  1. The application will start automatically once the Space is built.
26
  2. Access the public URL provided by Hugging Face Spaces.
@@ -30,10 +31,10 @@ This application provides a voice-interactive morning market brief. It uses seve
30
  ## Environment Variables (Secrets)
31
  The following secrets **must be set in your Hugging Face Space settings** for the application to function correctly:
32
 
33
- - `FMP_API_KEY`: Your FinancialModelingPrep API key.
34
- - `ALPHAVANTAGE_API_KEY`: Your Alpha Vantage API key.
35
- - `GOOGLE_API_KEY`: Your Google API key for Gemini.
36
  - `GEMINI_MODEL_NAME` (Optional): Defaults to `gemini-1.5-flash-latest` if not set.
37
  - `WHISPER_MODEL_SIZE` (Optional): Defaults to `small` if not set.
38
 
39
- The `FAISS_INDEX_PATH` is configured internally to use `/app/faiss_index_store` and leverages a Docker named volume `faiss_index_volume` for persistence of the FAISS index during the Space's operational lifecycle.
 
1
  ---
2
+ title: AI Financial Assistant (Single Container)
3
+ emoji: ⚙️
4
+ colorFrom: orange
5
+ colorTo: red
6
  sdk: docker
7
+ app_port: 8501
8
  pinned: false
 
9
  ---
10
 
11
+ # AI Financial Assistant - Morning Market Brief (Single Container)
12
 
13
  This application provides a voice-interactive morning market brief. It uses several AI agents for:
14
  - Speech-to-Text (STT)
 
20
  - Language Generation (LLM)
21
  - Text-to-Speech (TTS)
22
 
23
+ All services run within a single Docker container managed by Supervisord.
24
+
25
  ## How to Use
26
  1. The application will start automatically once the Space is built.
27
  2. Access the public URL provided by Hugging Face Spaces.
 
31
  ## Environment Variables (Secrets)
32
  The following secrets **must be set in your Hugging Face Space settings** for the application to function correctly:
33
 
34
+ - `FMP_API_KEY`
35
+ - `ALPHAVANTAGE_API_KEY`
36
+ - `GOOGLE_API_KEY`
37
  - `GEMINI_MODEL_NAME` (Optional): Defaults to `gemini-1.5-flash-latest` if not set.
38
  - `WHISPER_MODEL_SIZE` (Optional): Defaults to `small` if not set.
39
 
40
+ The `FAISS_INDEX_PATH` is configured internally to `/app/faiss_index_store`. Note that in this single-container setup on HF Spaces, this path might be ephemeral unless specific persistent storage is configured for the Space.
docker-compose.yaml DELETED
@@ -1,138 +0,0 @@
1
- version: '3.8'
2
-
3
- services:
4
- api_agent:
5
- build:
6
- context: .
7
- dockerfile: Dockerfile.fastapi
8
- command: uvicorn agents.api_agent:app --host 0.0.0.0 --port 8001
9
- volumes:
10
- - .:/app
11
- ports:
12
- - "8001:8001"
13
- environment:
14
- - FMP_API_KEY=${FMP_API_KEY}
15
- - ALPHAVANTAGE_API_KEY=${ALPHAVANTAGE_API_KEY}
16
- networks:
17
- - agent_network
18
-
19
- scraping_agent:
20
- build:
21
- context: .
22
- dockerfile: Dockerfile.fastapi
23
- command: uvicorn agents.scraping_agent:app --host 0.0.0.0 --port 8002
24
- volumes:
25
- - .:/app
26
- ports:
27
- - "8002:8002"
28
- environment:
29
- - FMP_API_KEY=${FMP_API_KEY}
30
- networks:
31
- - agent_network
32
-
33
- retriever_agent:
34
- build:
35
- context: .
36
- dockerfile: Dockerfile.fastapi
37
- command: uvicorn agents.retriever_agent:app --host 0.0.0.0 --port 8003
38
- volumes:
39
- - .:/app
40
- - faiss_index_volume:/app/faiss_index_store
41
- ports:
42
- - "8003:8003"
43
- environment:
44
- - FAISS_INDEX_PATH=/app/faiss_index_store
45
- networks:
46
- - agent_network
47
-
48
- analysis_agent:
49
- build:
50
- context: .
51
- dockerfile: Dockerfile.fastapi
52
- command: uvicorn agents.analysis_agent:app --host 0.0.0.0 --port 8004
53
- volumes:
54
- - .:/app
55
- ports:
56
- - "8004:8004"
57
- networks:
58
- - agent_network
59
-
60
- language_agent:
61
- build:
62
- context: .
63
- dockerfile: Dockerfile.fastapi
64
- command: uvicorn agents.language_agent:app --host 0.0.0.0 --port 8005
65
- volumes:
66
- - .:/app
67
- ports:
68
- - "8005:8005"
69
- environment:
70
- - GOOGLE_API_KEY=${GOOGLE_API_KEY}
71
- - GEMINI_MODEL_NAME=${GEMINI_MODEL_NAME:-gemini-1.5-flash-latest}
72
- networks:
73
- - agent_network
74
-
75
- voice_agent:
76
- build:
77
- context: .
78
- dockerfile: Dockerfile.fastapi
79
- command: uvicorn agents.voice_agent:app --host 0.0.0.0 --port 8006
80
- volumes:
81
- - .:/app
82
- ports:
83
- - "8006:8006"
84
- environment:
85
- - WHISPER_MODEL_SIZE=${WHISPER_MODEL_SIZE:-small}
86
- networks:
87
- - agent_network
88
-
89
- orchestrator:
90
- build:
91
- context: .
92
- dockerfile: Dockerfile.fastapi
93
- command: uvicorn orchestrator.main:app --host 0.0.0.0 --port 8000
94
- volumes:
95
- - .:/app
96
- - ./example_portfolio.json:/app/example_portfolio.json
97
- ports:
98
- - "8000:8000"
99
- environment:
100
- - AGENT_API_URL=http://api_agent:8001
101
- - AGENT_SCRAPING_URL=http://scraping_agent:8002
102
- - AGENT_RETRIEVER_URL=http://retriever_agent:8003
103
- - AGENT_ANALYSIS_URL=http://analysis_agent:8004
104
- - AGENT_LANGUAGE_URL=http://language_agent:8005
105
- - AGENT_VOICE_URL=http://voice_agent:8006
106
- depends_on:
107
- - api_agent
108
- - scraping_agent
109
- - retriever_agent
110
- - analysis_agent
111
- - language_agent
112
- - voice_agent
113
- networks:
114
- - agent_network
115
-
116
- streamlit_app:
117
- build:
118
- context: .
119
- dockerfile: Dockerfile.streamlit
120
- command: streamlit run streamlit/app.py --server.port=8501 --server.address=0.0.0.0 --browser.gatherUsageStats=false
121
- volumes:
122
- - ./streamlit:/app/streamlit
123
- - ./example_portfolio.json:/app/example_portfolio.json
124
- ports:
125
- - "8501:8501"
126
- environment:
127
- - ORCHESTRATOR_URL=http://orchestrator:8000
128
- depends_on:
129
- - orchestrator
130
- networks:
131
- - agent_network
132
-
133
- volumes:
134
- faiss_index_volume:
135
-
136
- networks:
137
- agent_network:
138
- driver: bridge
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -15,4 +15,5 @@ faster-whisper
15
  python-multipart
16
  langgraph
17
  streamlit
18
- streamlit-mic-recorder
 
 
15
  python-multipart
16
  langgraph
17
  streamlit
18
+ streamlit-mic-recorder
19
+ supervisor
supervisord.conf ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [supervisord]
2
+ nodaemon=true ; run supervisord in the foreground
3
+
4
+ [program:api_agent]
5
+ command=uvicorn agents.api_agent:app --host 0.0.0.0 --port 8001
6
+ directory=/app
7
+ autostart=true
8
+ autorestart=true
9
+ stdout_logfile=/dev/stdout
10
+ stdout_logfile_maxbytes=0
11
+ stderr_logfile=/dev/stderr
12
+ stderr_logfile_maxbytes=0
13
+
14
+ [program:scraping_agent]
15
+ command=uvicorn agents.scraping_agent:app --host 0.0.0.0 --port 8002
16
+ directory=/app
17
+ autostart=true
18
+ autorestart=true
19
+ stdout_logfile=/dev/stdout
20
+ stdout_logfile_maxbytes=0
21
+ stderr_logfile=/dev/stderr
22
+ stderr_logfile_maxbytes=0
23
+
24
+ [program:retriever_agent]
25
+ command=uvicorn agents.retriever_agent:app --host 0.0.0.0 --port 8003
26
+ directory=/app
27
+ autostart=true
28
+ autorestart=true
29
+ stdout_logfile=/dev/stdout
30
+ stdout_logfile_maxbytes=0
31
+ stderr_logfile=/dev/stderr
32
+ stderr_logfile_maxbytes=0
33
+
34
+ [program:analysis_agent]
35
+ command=uvicorn agents.analysis_agent:app --host 0.0.0.0 --port 8004
36
+ directory=/app
37
+ autostart=true
38
+ autorestart=true
39
+ stdout_logfile=/dev/stdout
40
+ stdout_logfile_maxbytes=0
41
+ stderr_logfile=/dev/stderr
42
+ stderr_logfile_maxbytes=0
43
+
44
+ [program:language_agent]
45
+ command=uvicorn agents.language_agent:app --host 0.0.0.0 --port 8005
46
+ directory=/app
47
+ autostart=true
48
+ autorestart=true
49
+ stdout_logfile=/dev/stdout
50
+ stdout_logfile_maxbytes=0
51
+ stderr_logfile=/dev/stderr
52
+ stderr_logfile_maxbytes=0
53
+
54
+ [program:voice_agent]
55
+ command=uvicorn agents.voice_agent:app --host 0.0.0.0 --port 8006
56
+ directory=/app
57
+ autostart=true
58
+ autorestart=true
59
+ stdout_logfile=/dev/stdout
60
+ stdout_logfile_maxbytes=0
61
+ stderr_logfile=/dev/stderr
62
+ stderr_logfile_maxbytes=0
63
+
64
+ [program:orchestrator]
65
+ command=uvicorn orchestrator.main:app --host 0.0.0.0 --port 8000
66
+ directory=/app
67
+ autostart=true
68
+ autorestart=true
69
+ stdout_logfile=/dev/stdout
70
+ stdout_logfile_maxbytes=0
71
+ stderr_logfile=/dev/stderr
72
+ stderr_logfile_maxbytes=0
73
+
74
+ [program:streamlit_app]
75
+ command=streamlit run streamlit/app.py --server.port=8501 --server.address=0.0.0.0 --browser.gatherUsageStats=false
76
+ directory=/app
77
+ autostart=true
78
+ autorestart=true
79
+ stdout_logfile=/dev/stdout
80
+ stdout_logfile_maxbytes=0
81
+ stderr_logfile=/dev/stderr
82
+ stderr_logfile_maxbytes=0