Skip to content

Commit 09c363a

Browse files
poc(caraml-ai): Set up CaraML AI mockup (caraml-dev#109)
* Update mlp app to serve new configs * Add temporary caraml ai mockup ui * Add isProjectAgnostic flag to CaraML AI app * Fix navigation when a user selects a project while in a project agnostic app
1 parent a234b6b commit 09c363a

File tree

8 files changed

+52
-11
lines changed

8 files changed

+52
-11
lines changed

api/config/config.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ type UIConfig struct {
119119
StaticPath string `validated:"required"`
120120
IndexPath string `validated:"required"`
121121

122-
ClockworkUIHomepage string `json:"REACT_APP_CLOCKWORK_UI_HOMEPAGE"`
123-
KubeflowUIHomepage string `json:"REACT_APP_KUBEFLOW_UI_HOMEPAGE"`
122+
ClockworkUIHomepage string `json:"REACT_APP_CLOCKWORK_UI_HOMEPAGE"`
123+
KubeflowUIHomepage string `json:"REACT_APP_KUBEFLOW_UI_HOMEPAGE"`
124+
CaramlAIStreamlitHomepage string `json:"REACT_APP_CARAML_AI_STREAMLIT_HOMEPAGE"`
124125

125126
AllowCustomStream bool `json:"REACT_APP_ALLOW_CUSTOM_STREAM"`
126127
AllowCustomTeam bool `json:"REACT_APP_ALLOW_CUSTOM_TEAM"`

api/models/v2/application.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package models
22

33
type Application struct {
4-
Name string `json:"name" validate:"required"`
5-
Description string `json:"description"`
6-
Homepage string `json:"homepage"`
7-
Configuration *ApplicationConfig `json:"config" validate:"dive"`
4+
Name string `json:"name" validate:"required"`
5+
Description string `json:"description"`
6+
Homepage string `json:"homepage"`
7+
Configuration *ApplicationConfig `json:"config" validate:"dive"`
8+
IsProjectAgnostic bool `json:"is_project_agnostic"`
89
}
910

1011
type ApplicationConfig struct {

config-dev.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ applications:
4747
homepage: /pipeline
4848
configuration:
4949
iconName: pipelineApp
50+
- name: CaraML AI
51+
description: Gateway for accessing LLM models
52+
homepage: /caraml-ai
53+
isProjectAgnostic: true
54+
configuration:
55+
iconName: timelionApp
56+
5057

5158
database:
5259
host: "localhost"

ui/packages/app/src/App.js

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Route, Routes } from "react-router-dom";
1212
import AppRoutes from "./AppRoutes";
1313
import { PrivateLayout } from "./PrivateLayout";
1414
import config from "./config";
15+
import { CaraMLAIPage } from "./caraml_ai/CaraMLAIPage";
1516

1617
const App = () => (
1718
<EuiProvider>
@@ -29,6 +30,13 @@ const App = () => (
2930
</Route>
3031

3132
<Route path="/pages/404" element={<Page404 />} />
33+
34+
{
35+
config.CARAML_AI_STREAMLIT_HOMEPAGE &&
36+
<Route element={<PrivateLayout />}>
37+
<Route path="/caraml-ai" element={<CaraMLAIPage />} />
38+
</Route>
39+
}
3240
</Routes>
3341
<Toast />
3442
</AuthProvider>

ui/packages/app/src/PrivateLayout.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export const PrivateLayout = () => {
2020
{({ currentApp }) => (
2121
<Header
2222
onProjectSelect={pId =>
23-
navigate(urlJoin(currentApp?.homepage, "projects", pId))
23+
// Return user to /projects/:projectId (MLP project landing page) if app is project agnostic
24+
navigate(urlJoin(currentApp?.is_project_agnostic ? "" : currentApp?.homepage, "projects", pId))
2425
}
2526
docLinks={config.DOC_LINKS}
2627
/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from "react";
2+
import { EuiPageTemplate } from "@elastic/eui";
3+
import config from "./../config";
4+
5+
export const CaraMLAIPage = () => {
6+
const iframe = `<iframe src=${config.CARAML_AI_STREAMLIT_HOMEPAGE} style="height: 80vh; width: 100%;"></iframe>`
7+
8+
function Iframe(props) {
9+
return (<div dangerouslySetInnerHTML={ {__html: props.iframe?props.iframe:""}} />);
10+
}
11+
return (
12+
<EuiPageTemplate restrictWidth="90%" panelled={false}>
13+
<EuiPageTemplate.Header
14+
bottomBorder={false}
15+
iconType="timelionApp"
16+
pageTitle="CaraML AI"
17+
/>
18+
19+
<EuiPageTemplate.Section paddingSize="none">
20+
<Iframe iframe={iframe} />
21+
</EuiPageTemplate.Section>
22+
</EuiPageTemplate>
23+
);
24+
};

ui/packages/app/src/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ const config = {
3131
MAX_AUTHZ_CACHE_EXPIRY_MINUTES: parseInt(
3232
getEnv("REACT_APP_MAX_AUTHZ_CACHE_EXPIRY_MINUTES") || "0"
3333
),
34-
3534
CLOCKWORK_UI_HOMEPAGE: getEnv("REACT_APP_CLOCKWORK_UI_HOMEPAGE"),
3635
KUBEFLOW_UI_HOMEPAGE: getEnv("REACT_APP_KUBEFLOW_UI_HOMEPAGE"),
36+
CARAML_AI_STREAMLIT_HOMEPAGE: getEnv("REACT_APP_CARAML_AI_STREAMLIT_HOMEPAGE"),
3737
ALLOW_CUSTOM_STREAM:
3838
getEnv("REACT_APP_ALLOW_CUSTOM_STREAM") != null
3939
? getEnv("REACT_APP_ALLOW_CUSTOM_STREAM")

ui/packages/lib/src/components/nav_drawer/NavDrawer.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,12 @@ export const NavDrawer = ({ docLinks }) => {
5555
className: isAppActive
5656
? "euiTreeView__node---small---active"
5757
: "euiTreeView__node---small",
58-
5958
callback: () =>
60-
!children || !currentProject
59+
a.is_project_agnostic ? (window.location.href = a.homepage) : (!children || !currentProject
6160
? (window.location.href = !!currentProject
6261
? urlJoin(a.homepage, "projects", currentProject.id)
6362
: a.homepage)
64-
: {},
63+
: {}),
6564
children: children
6665
};
6766
});

0 commit comments

Comments
 (0)