Skip to content

Commit e1e9fd3

Browse files
authored
Cicd friendly extensions (#430)
* Add extension hooks for routes and provide echo example Signed-off-by: Trevor Grant <[email protected]> * add files Signed-off-by: Trevor Grant <[email protected]> * making extensions more ci cd friendly Signed-off-by: Trevor Grant <[email protected]> * testing echo Signed-off-by: Trevor Grant <[email protected]> * I think it's actually working now :O Signed-off-by: Trevor Grant <[email protected]> --------- Signed-off-by: Trevor Grant <[email protected]>
1 parent 6cd525e commit e1e9fd3

File tree

18 files changed

+161
-392
lines changed

18 files changed

+161
-392
lines changed

webapp/Deploying_on_Firebase.md

Lines changed: 0 additions & 198 deletions
This file was deleted.

webapp/EXTENSION_EXAMPLE.md

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ The new endpoint will be available at `POST /extensions/echo` and will be merged
4949

5050
## 2) Add the Echo page
5151

52-
Create `webapp/packages/webui/src/pages/EchoPage.jsx`:
52+
Create `webapp/packages/webui/src/extensions/echo/EchoPage.jsx`:
5353

5454
```jsx
5555
import React, { useState } from 'react';
5656
import { Box, Button, Stack, TextField, Typography } from '@mui/material';
57-
import config from '../config';
57+
import config from '../../config';
5858

5959
const EchoPage = () => {
6060
const [value, setValue] = useState('');
@@ -107,11 +107,29 @@ const EchoPage = () => {
107107
export default EchoPage;
108108
```
109109
110+
Also add the EchoCard.
111+
Create `webapp/packages/webui/src/extensions/echo/EchoCard.jsx`:
112+
```jsx
113+
// webapp/packages/webui/src/extensions/echo/EchoCard.jsx
114+
import CampaignIcon from '@mui/icons-material/Campaign';
115+
116+
export const card = {
117+
id: 'echo',
118+
title: 'Echo Chamber',
119+
description: 'An example of a custom card that links to a new page and API.',
120+
buttonText: 'Try It',
121+
icon: <CampaignIcon />,
122+
iconColor: 'primary.main',
123+
onAction: ({ navigate }) => navigate('/echo'),
124+
};
125+
126+
```
127+
110128
## 3) Extend the frontend routes
111129
112-
Append the new route inside `webapp/packages/webui/src/extensions/echo.routes.js`:
130+
Append the new route inside `webapp/packages/webui/src/extensions/echo.routes.jsx`:
113131
114-
```javascript
132+
```jsx
115133
import EchoPage from '../../pages/EchoPage';
116134

117135
export const route = {
@@ -125,20 +143,34 @@ All routes defined here are merged with `src/config/routesConfig.jsx`, so the Ec
125143
126144
## 4) Register the Echo card
127145
128-
Create `webapp/packages/webui/src/extensions/echo.card.js`:
146+
Create `webapp/packages/webui/src/extensions/echo.card.jsx`:
129147
130-
```javascript
131-
import CampaignIcon from '@mui/icons-material/Campaign';
148+
```jsx
149+
import React from 'react';
150+
import { Button, Card, CardActions, CardContent, Typography } from '@mui/material';
151+
import { Link } from 'react-router-dom';
132152

133-
export const card = {
134-
id: 'echo',
135-
title: 'Echo',
136-
description: 'Send text to the Echo API and see it mirrored back.',
137-
buttonText: 'Open Echo',
138-
icon: <CampaignIcon />,
139-
defaultOrder: 7,
140-
onAction: ({ navigate }) => navigate('/echo'),
141-
};
153+
const EchoCard = () => {
154+
return (
155+
<Card>
156+
<CardContent>
157+
<Typography variant="h5" component="div">
158+
Echo Extension
159+
</Typography>
160+
<Typography sx={{ mt: 1.5 }} color="text.secondary">
161+
An example of a custom card that links to a new page and API.
162+
</Typography>
163+
</CardContent>
164+
<CardActions>
165+
<Button component={Link} to="/echo" size="small">
166+
Try It
167+
</Button>
168+
</CardActions>
169+
</Card>
170+
);
171+
};
172+
173+
export default EchoCard;
142174
```
143175
144176
(Optional) If you want to control the card’s order or grouping, add an entry to `CARD_CONFIG_OVERRIDES` (for example via `.env` or `window.__CARD_CONFIG_OVERRIDES__`).
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from fastapi import APIRouter
2+
from pydantic import BaseModel
3+
4+
router = APIRouter()
5+
6+
7+
class EchoRequest(BaseModel):
8+
message: str
9+
10+
11+
@router.post("/echo")
12+
async def echo(request: EchoRequest):
13+
return {"echo": request.message}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from config.routes_config import RouterConfig
2+
3+
ROUTER_CONFIG_MODE = "append"
4+
ROUTER_CONFIGS = [
5+
{
6+
"router": "extensions.echo_router:router",
7+
"prefix": "/extensions", # becomes /extensions/echo
8+
"tags": ["echo-demo"],
9+
}
10+
]

webapp/packages/api/user-service/main.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
import litellm
1414
import traceback
1515
import httpx
16-
import firebase_admin
1716
import yaml
18-
from firebase_admin import credentials, auth
1917
from fastapi.security import OAuth2PasswordBearer
2018

2119
from services.database_service import get_database_service, DatabaseService
@@ -46,17 +44,6 @@
4644
from agent_factory.remote_mcp_client import RemoteMCPClient
4745

4846

49-
# --- Firebase Admin SDK Initialization ---
50-
if settings.APP_ENV == "firebase":
51-
try:
52-
# In a Cloud Function environment, GOOGLE_APPLICATION_CREDENTIALS is set automatically.
53-
# For local emulation, you'd need to set this env var to your service account key file.
54-
cred = credentials.ApplicationDefault()
55-
firebase_admin.initialize_app(cred)
56-
print("Firebase Admin SDK initialized successfully.")
57-
except Exception as e:
58-
print(f"Error initializing Firebase Admin SDK: {e}")
59-
6047
app = FastAPI()
6148
router = APIRouter()
6249

@@ -804,7 +791,6 @@ async def delete_demo_app(demo_id: str, db: DatabaseService = Depends(get_db), u
804791

805792
# This is an unseemly hack to adapt FastAPI to Google Cloud Functions.
806793
# TODO refactor all of this into microservices.
807-
from firebase_functions import https_fn, options
808794
from a2wsgi import ASGIMiddleware
809795

810796
wsgi_app = ASGIMiddleware(app)

0 commit comments

Comments
 (0)