Skip to content

Commit 34fb761

Browse files
authored
Revert "Feature/ag UI (#59)" (#62)
This reverts commit 7b6579c.
1 parent 7b6579c commit 34fb761

36 files changed

+1547
-429
lines changed

.github/workflows/deploy.yml

Lines changed: 97 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ on:
99
env:
1010
REGISTRY: crretoxmas2024.azurecr.io
1111
NAMESPACE: reto-xmas-2025-goland-ia-backend
12+
ROLLOUT_TIMEOUT: 60s
13+
READY_CHECK_RETRIES: 20
14+
READY_CHECK_SLEEP: 15
1215

1316
jobs:
1417
build-and-deploy:
1518
runs-on: ubuntu-latest
19+
timeout-minutes: 15
1620
strategy:
1721
fail-fast: false
1822
matrix:
@@ -25,7 +29,7 @@ jobs:
2529
path: ./RAGManager
2630
image: reto-xmas-2025-goland-ia-backend-rag-manager
2731
deployment: rag-manager
28-
32+
2933
steps:
3034
- name: Checkout code
3135
uses: actions/checkout@v4
@@ -51,6 +55,7 @@ jobs:
5155
${{ env.REGISTRY }}/${{ matrix.service.image }}:${{ github.sha }}
5256
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ matrix.service.image }}:buildcache
5357
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ matrix.service.image }}:buildcache,mode=max
58+
provenance: false
5459

5560
- name: Set up kubectl
5661
uses: azure/setup-kubectl@v3
@@ -63,28 +68,78 @@ jobs:
6368
echo "${{ secrets.KUBECONFIG }}" | base64 -d > $HOME/.kube/config
6469
chmod 600 $HOME/.kube/config
6570
66-
- name: Restart deployment
71+
- name: Update deployment image
6772
run: |
68-
kubectl rollout restart deployment/${{ matrix.service.deployment }} -n ${{ env.NAMESPACE }}
69-
kubectl rollout status deployment/${{ matrix.service.deployment }} -n ${{ env.NAMESPACE }} --timeout=5m
73+
kubectl set image deployment/${{ matrix.service.deployment }} \
74+
api=${{ env.REGISTRY }}/${{ matrix.service.image }}:${{ github.sha }} \
75+
-n ${{ env.NAMESPACE }}
7076
71-
- name: Verify deployment
77+
- name: Wait for deployment to be ready (robust)
7278
run: |
73-
echo "✅ Deployment successful for ${{ matrix.service.name }}"
74-
kubectl get pods -n ${{ env.NAMESPACE }} -l app=${{ matrix.service.deployment }}
79+
set -e
80+
81+
echo "Checking rollout status (non-blocking)..."
82+
kubectl rollout status deployment/${{ matrix.service.deployment }} \
83+
-n ${{ env.NAMESPACE }} \
84+
--timeout=${{ env.ROLLOUT_TIMEOUT }} || true
85+
86+
echo "Waiting for available replicas..."
87+
88+
for i in $(seq 1 $READY_CHECK_RETRIES); do
89+
DESIRED=$(kubectl get deployment/${{ matrix.service.deployment }} -n ${{ env.NAMESPACE }} -o jsonpath='{.spec.replicas}')
90+
AVAILABLE=$(kubectl get deployment/${{ matrix.service.deployment }} -n ${{ env.NAMESPACE }} -o jsonpath='{.status.availableReplicas}')
91+
92+
echo "Attempt $i: $AVAILABLE / $DESIRED replicas available"
93+
94+
if [ "$AVAILABLE" = "$DESIRED" ]; then
95+
echo "Deployment is ready"
96+
exit 0
97+
fi
98+
99+
sleep $READY_CHECK_SLEEP
100+
done
101+
102+
echo "Deployment did not become ready in time"
103+
kubectl describe deployment/${{ matrix.service.deployment }} -n ${{ env.NAMESPACE }}
104+
exit 1
105+
106+
- name: Verify pods
107+
if: success()
108+
run: |
109+
kubectl get pods -n ${{ env.NAMESPACE }} -l app=${{ matrix.service.deployment }} -o wide
110+
111+
- name: Get logs on failure
112+
if: failure()
113+
run: |
114+
echo "=== Deployment ==="
115+
kubectl describe deployment/${{ matrix.service.deployment }} -n ${{ env.NAMESPACE }}
116+
117+
echo "=== Pods ==="
118+
kubectl get pods -n ${{ env.NAMESPACE }} -l app=${{ matrix.service.deployment }} -o wide
119+
120+
echo "=== Pod Logs ==="
121+
kubectl logs -n ${{ env.NAMESPACE }} \
122+
-l app=${{ matrix.service.deployment }} \
123+
--tail=100 \
124+
--all-containers=true \
125+
--prefix=true || true
75126
76127
- name: Deployment Summary
77128
if: always()
78129
run: |
79-
echo "### 🚀 Deployment Summary" >> $GITHUB_STEP_SUMMARY
130+
STATUS="${{ job.status }}"
131+
132+
echo "### Deployment - ${{ matrix.service.name }}" >> $GITHUB_STEP_SUMMARY
80133
echo "" >> $GITHUB_STEP_SUMMARY
81-
echo "**Service:** ${{ matrix.service.name }}" >> $GITHUB_STEP_SUMMARY
82-
echo "**Image:** ${{ env.REGISTRY }}/${{ matrix.service.image }}:${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
83-
echo "**Status:** ${{ job.status }}" >> $GITHUB_STEP_SUMMARY
134+
echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY
135+
echo "|----------|-------|" >> $GITHUB_STEP_SUMMARY
136+
echo "| Image | \`${{ env.REGISTRY }}/${{ matrix.service.image }}:${{ github.sha }}\` |" >> $GITHUB_STEP_SUMMARY
137+
echo "| Status | $STATUS |" >> $GITHUB_STEP_SUMMARY
84138
echo "" >> $GITHUB_STEP_SUMMARY
139+
85140
echo "#### Pods:" >> $GITHUB_STEP_SUMMARY
86141
echo '```' >> $GITHUB_STEP_SUMMARY
87-
kubectl get pods -n ${{ env.NAMESPACE }} -l app=${{ matrix.service.deployment }} >> $GITHUB_STEP_SUMMARY
142+
kubectl get pods -n ${{ env.NAMESPACE }} -l app=${{ matrix.service.deployment }} >> $GITHUB_STEP_SUMMARY || true
88143
echo '```' >> $GITHUB_STEP_SUMMARY
89144
90145
notify-success:
@@ -95,8 +150,34 @@ jobs:
95150
steps:
96151
- name: Success Summary
97152
run: |
98-
echo "### ✅ Deployment Successful!" >> $GITHUB_STEP_SUMMARY
153+
echo "### All Services Deployed" >> $GITHUB_STEP_SUMMARY
99154
echo "" >> $GITHUB_STEP_SUMMARY
100-
echo "All services deployed successfully:" >> $GITHUB_STEP_SUMMARY
101-
echo "- 🌐 DocsManager: https://goland-ia-backend-docs-manager.reto-ucu.net" >> $GITHUB_STEP_SUMMARY
102-
echo "- 🌐 RAGManager: https://goland-ia-backend-rag-manager.reto-ucu.net" >> $GITHUB_STEP_SUMMARY
155+
echo "**Live URLs:**" >> $GITHUB_STEP_SUMMARY
156+
echo "- [DocsManager](https://goland-ia-backend-docs-manager.reto-ucu.net/docs)" >> $GITHUB_STEP_SUMMARY
157+
echo "- [RAGManager](https://goland-ia-backend-rag-manager.reto-ucu.net/docs)" >> $GITHUB_STEP_SUMMARY
158+
159+
- name: Notificar a Discord (deploy exitoso)
160+
run: |
161+
curl -H "Content-Type: application/json" \
162+
-X POST \
163+
-d "{\"content\": \"✅ **Deploy exitoso**\\n\\n**Servicio:** \\\\`${{ matrix.service.name }}\\\\`\\n**Imagen:** \\\\`${{ env.REGISTRY }}/${{ matrix.service.image }}:${{ github.sha }}\\\\`\\n**Namespace:** \\\\`${{ env.NAMESPACE }}\\\\`\\n**Autor:** ${{ github.actor }}\\n**Commit:** [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})\\n\\n[Ver ejecución en GitHub Actions](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})\\n\\n:rocket: ¡Todo salió bien!\"}" \
164+
https://discord.com/api/webhooks/1449147972330852463/sMs3QYOvQ6oiaPHR4PlBluwNrhWSsVmfm3_Miz6UAFrPxj1SsbqNnHXc5eK9h8ZSaumk
165+
166+
notify-failure:
167+
name: Deployment Failed
168+
runs-on: ubuntu-latest
169+
needs: [build-and-deploy]
170+
if: failure()
171+
steps:
172+
- name: Failure Summary
173+
run: |
174+
echo "### Deployment Failed" >> $GITHUB_STEP_SUMMARY
175+
echo "" >> $GITHUB_STEP_SUMMARY
176+
echo "Please check deployment logs above." >> $GITHUB_STEP_SUMMARY
177+
178+
- name: Notificar a Discord (deploy fallido)
179+
run: |
180+
curl -H "Content-Type: application/json" \
181+
-X POST \
182+
-d "{\"content\": \"❌ **Falló el deploy**\\n\\n**Servicio:** \\\\`${{ matrix.service.name }}\\\\`\\n**Imagen:** \\\\`${{ env.REGISTRY }}/${{ matrix.service.image }}:${{ github.sha }}\\\\`\\n**Namespace:** \\\\`${{ env.NAMESPACE }}\\\\`\\n**Autor:** ${{ github.actor }}\\n**Commit:** [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})\\n\\n[Ver ejecución en GitHub Actions](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})\\n\\n:warning: Revisa los logs para más detalles.\"}" \
183+
https://discord.com/api/webhooks/1449147972330852463/sMs3QYOvQ6oiaPHR4PlBluwNrhWSsVmfm3_Miz6UAFrPxj1SsbqNnHXc5eK9h8ZSaumk

.github/workflows/pr-validation.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: PR Validation
22

33
on:
44
pull_request:
5+
types: [opened]
56
branches:
67
- main
78

@@ -66,6 +67,13 @@ jobs:
6667
severity: 'CRITICAL,HIGH'
6768
exit-code: '0'
6869

70+
- name: SonarQube Scan
71+
uses: sonarsource/sonarqube-scan-action@v2
72+
with:
73+
host: https://sonarqube.reto-ucu.net/
74+
login: ${{ secrets.SONAR_TOKEN }}
75+
projectKey: reto-xmas-2025-goland-ia-backend
76+
6977
pr-summary:
7078
name: PR Summary
7179
runs-on: ubuntu-latest
@@ -96,4 +104,16 @@ jobs:
96104
owner: context.repo.owner,
97105
repo: context.repo.repo,
98106
body: message
99-
});
107+
});
108+
109+
discord-pr-notify:
110+
name: Notificar PR en Discord
111+
runs-on: ubuntu-latest
112+
if: github.event_name == 'pull_request'
113+
steps:
114+
- name: Notificar a Discord (nuevo PR)
115+
run: |
116+
curl -H "Content-Type: application/json" \
117+
-X POST \
118+
-d "{\"content\": \"🔔 Nuevo Pull Request: [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }}) por ${{ github.event.pull_request.user.login }}\"}" \
119+
https://discord.com/api/webhooks/1449147972330852463/sMs3QYOvQ6oiaPHR4PlBluwNrhWSsVmfm3_Miz6UAFrPxj1SsbqNnHXc5eK9h8ZSaumk

DocsManager/.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.14
1+
3.13

DocsManager/Dockerfile

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1-
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
1+
FROM python:3.12-slim
22

33
WORKDIR /app
44

5-
COPY pyproject.toml uv.lock* ./
5+
RUN apt-get update && apt-get install -y \
6+
curl \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
10+
mv /root/.local/bin/uv /usr/local/bin/uv && \
11+
mv /root/.local/bin/uvx /usr/local/bin/uvx
12+
613

7-
RUN uv sync --frozen --no-cache || uv sync --no-cache
814

915
COPY . .
1016

17+
RUN uv sync --no-dev --no-cache \
18+
&& uv pip list \
19+
&& uv pip show fastapi uvicorn
20+
1121
EXPOSE 8000
1222

13-
CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
23+
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
24+
CMD curl -f http://localhost:8000/health || exit 1
25+
26+
CMD ["uv", "run", "--no-sync", "python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from fastapi import APIRouter, Depends
2-
from fastapi.responses import StreamingResponse
32
from sqlalchemy.orm import Session
43

54
from app.core.db_connection import get_db
6-
from ag_ui.core import RunAgentInput
7-
from app.services.chatMessage import process_agent_message
5+
from app.schemas.chatMessage import UserMessageIn, AssistantMessageOut
6+
from app.services.chatMessage import create_user_message
87

98

109
router = APIRouter(
@@ -15,15 +14,19 @@
1514

1615
@router.post(
1716
"/messages",
17+
response_model=AssistantMessageOut
1818
)
19-
async def post_user_message(
20-
payload: RunAgentInput,
19+
def post_user_message(
20+
payload: UserMessageIn,
2121
db: Session = Depends(get_db)
2222
):
23-
"""Handle chat messages using the AG-UI protocol.
24-
25-
This endpoint accepts RunAgentInput and returns a stream of AG-UI events.
26-
"""
27-
return StreamingResponse(
28-
process_agent_message(db, payload)
23+
assistant_msg, session_id = create_user_message(
24+
db=db,
25+
message=payload.message,
26+
session_id=payload.session_id
2927
)
28+
29+
return {
30+
"session_id": session_id,
31+
"message": assistant_msg.message
32+
}

DocsManager/app/core/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from pydantic_settings import BaseSettings, SettingsConfigDict
2-
from pydantic import field_validator, model_validator
2+
from pydantic import field_validator, model_validator, Field
33
from typing import Optional
44
from urllib.parse import quote_plus
55
import logging
@@ -29,7 +29,6 @@ class Settings(BaseSettings):
2929
minio_access_key: str
3030
minio_secret_key: str
3131
minio_bucket: str = "documents"
32-
minio_folder: str = "rag-docs"
3332
minio_use_ssl: bool = True
3433

3534
# Database Configuration (for SQLAlchemy)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from pydantic import BaseModel
2+
from uuid import UUID
3+
from typing import Optional
4+
5+
class UserMessageIn(BaseModel):
6+
session_id: Optional[UUID] = None
7+
message: str
8+
9+
10+
class AssistantMessageOut(BaseModel):
11+
session_id: UUID
12+
message: str

0 commit comments

Comments
 (0)