Skip to content

Commit 9cdc3b4

Browse files
author
Bintou DIOP
committed
Merge branch 'branche-bintou'
2 parents afc0dbc + 3a364f0 commit 9cdc3b4

4 files changed

Lines changed: 100 additions & 3 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: 'Build and Deploy Chainlit Agent to Cloud Run'
2+
3+
on:
4+
push:
5+
branches:
6+
- branche-bintou
7+
workflow_dispatch:
8+
9+
env:
10+
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
11+
REGION: ${{ secrets.GCP_REGION }}
12+
SERVICE: agent-orchestre-finance
13+
AR_HOSTNAME: ${{ secrets.GCP_REGION }}-docker.pkg.dev
14+
AR_REPOSITORY: chainlit-images
15+
16+
jobs:
17+
deploy:
18+
runs-on: 'ubuntu-latest'
19+
20+
permissions:
21+
contents: 'read'
22+
id-token: 'write'
23+
24+
steps:
25+
- name: 'Checkout Code'
26+
uses: 'actions/checkout@v4'
27+
28+
29+
- id: 'auth'
30+
name: 'Authenticate to Google Cloud'
31+
uses: 'google-github-actions/auth@v2'
32+
with:
33+
credentials_json: '${{ secrets.GCP_SA_KEY }}'
34+
35+
36+
- name: 'Create Artifact Registry Repository'
37+
run: |
38+
gcloud artifacts repositories create ${{ env.AR_REPOSITORY }} \
39+
--repository-format=docker \
40+
--location=${{ env.REGION }} \
41+
--description="Repository for Chainlit Agent Docker images" \
42+
--async || true
43+
44+
45+
- name: 'Configure Docker to use Artifact Registry'
46+
run: gcloud auth configure-docker ${{ env.AR_HOSTNAME }} --quiet
47+
48+
49+
- name: 'Build and Push Container'
50+
id: build-image
51+
run: |
52+
IMAGE_TAG="${{ env.AR_HOSTNAME }}/${{ env.PROJECT_ID }}/${{ env.AR_REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}"
53+
54+
echo "Building image: $IMAGE_TAG"
55+
docker build --tag "${IMAGE_TAG}" .
56+
docker push "${IMAGE_TAG}"
57+
echo "IMAGE_URL=${IMAGE_TAG}" >> $GITHUB_OUTPUT
58+
59+
# DÉPLOIEMENT SUR CLOUD RUN
60+
- name: 'Deploy to Cloud Run'
61+
uses: 'google-github-actions/deploy-cloudrun@v2'
62+
with:
63+
service: '${{ env.SERVICE }}'
64+
region: '${{ env.REGION }}'
65+
image: '${{ steps.build-image.outputs.IMAGE_URL }}'
66+
env_vars: |
67+
OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
68+
TAVILY_API_KEY=${{ secrets.TAVILY_API_KEY }}
69+
flags: --allow-unauthenticated
70+
71+
- name: 'Show output URL'
72+
run: |
73+
echo "Déploiement réussi ! URL du service:"
74+
echo "${{ steps.deploy.outputs.url }}"

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM python:3.11-slim
2+
WORKDIR /app
3+
COPY requirements.txt .
4+
RUN pip install --no-cache-dir -r requirements.txt
5+
6+
COPY . .
7+
8+
9+
ENV PORT 8080
10+
EXPOSE 8080
11+
12+
# Commande pour démarrer l'application Chainlit
13+
CMD ["sh", "-c", "chainlit run app_chainlit.py --host 0.0.0.0 --port $PORT"]

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ L'architecture est construite autour de l'outil **LangGraph**, qui gère l'état
2525

2626
* **Python :** Version 3.11
2727
* **Clés API :** Une clé **OpenAI API Key** est obligatoire. Une clé **Tavily API Key** est nécessaire pour la recherche web.
28+
* **Clés Google Cloud** pour le déploiement :
29+
-`GCP_PROJECT_ID` : ID de ton projet Google Cloud
30+
-`GCP_REGION` : Région de déploiement Cloud Run
31+
-`GCP_SA_KEY` : Fichier JSON de ta **Service Account Key**
2832

2933
### 2. Configuration de l'Environnement
3034

@@ -54,10 +58,17 @@ Le processus d'ingestion est géré automatiquement au premier lancement (ou lor
5458

5559
### 5. Lancement de l'Application
5660
Lancez l'interface web via Chainlit :
61+
l'application sera accessible via l'URL affichée dans le terminal (généralement http://localhost:8000).
5762
```bash
5863
chainlit run app_chainlit.py -w
5964
```
60-
L'application sera accessible via l'URL affichée dans le terminal (généralement http://localhost:8000).
65+
66+
### 5. Déploiement sur le cloud
67+
Le projet a été déployé temporairement sur Google Cloud Run via GitHub Actions :
68+
- L’URL de l’application est accessible pour tester l’assistant à distance mais elle sera désactivée après la période de test.https://agent-orchestre-finance-750867412054.europe-west9.run.app/
69+
- logs et erreurs sont monitorés via Cloud Run pour assurer la stabilité durant la période active.
70+
71+
6172
# Instructions de Test
6273
L'Agent Orchestrateur est capable de choisir l'outil approprié. Testez les différents modes :
6374

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# pip install -r requirements.txt
2-
langchain
32
langchain-core
43
langchain_chroma
54
langchain-community
@@ -9,7 +8,7 @@ langgraph
98
langchain_tavily
109
chromadb
1110
pypdf
12-
tavily-python
11+
langchain-tavily
1312
requests
1413

1514
chainlit

0 commit comments

Comments
 (0)