Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poc(caraml-ai): Set up CaraML AI mockup #109

Merged
merged 4 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions api/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ type UIConfig struct {
StaticPath string `validated:"required"`
IndexPath string `validated:"required"`

ClockworkUIHomepage string `json:"REACT_APP_CLOCKWORK_UI_HOMEPAGE"`
KubeflowUIHomepage string `json:"REACT_APP_KUBEFLOW_UI_HOMEPAGE"`
ClockworkUIHomepage string `json:"REACT_APP_CLOCKWORK_UI_HOMEPAGE"`
KubeflowUIHomepage string `json:"REACT_APP_KUBEFLOW_UI_HOMEPAGE"`
CaramlAIStreamlitHomepage string `json:"REACT_APP_CARAML_AI_STREAMLIT_HOMEPAGE"`

AllowCustomStream bool `json:"REACT_APP_ALLOW_CUSTOM_STREAM"`
AllowCustomTeam bool `json:"REACT_APP_ALLOW_CUSTOM_TEAM"`
Expand Down
9 changes: 5 additions & 4 deletions api/models/v2/application.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package models

type Application struct {
Name string `json:"name" validate:"required"`
Description string `json:"description"`
Homepage string `json:"homepage"`
Configuration *ApplicationConfig `json:"config" validate:"dive"`
Name string `json:"name" validate:"required"`
Description string `json:"description"`
Homepage string `json:"homepage"`
Configuration *ApplicationConfig `json:"config" validate:"dive"`
IsProjectAgnostic bool `json:"is_project_agnostic"`
}

type ApplicationConfig struct {
Expand Down
7 changes: 7 additions & 0 deletions config-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ applications:
homepage: /pipeline
configuration:
iconName: pipelineApp
- name: CaraML AI
description: Gateway for accessing LLM models
homepage: /caraml-ai
isProjectAgnostic: true
configuration:
iconName: timelionApp


database:
host: "localhost"
Expand Down
8 changes: 8 additions & 0 deletions ui/packages/app/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Route, Routes } from "react-router-dom";
import AppRoutes from "./AppRoutes";
import { PrivateLayout } from "./PrivateLayout";
import config from "./config";
import { CaraMLAIPage } from "./caraml_ai/CaraMLAIPage";

const App = () => (
<EuiProvider>
Expand All @@ -29,6 +30,13 @@ const App = () => (
</Route>

<Route path="/pages/404" element={<Page404 />} />

{
config.CARAML_AI_STREAMLIT_HOMEPAGE &&
<Route element={<PrivateLayout />}>
<Route path="/caraml-ai" element={<CaraMLAIPage />} />
</Route>
}
</Routes>
<Toast />
</AuthProvider>
Expand Down
3 changes: 2 additions & 1 deletion ui/packages/app/src/PrivateLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const PrivateLayout = () => {
{({ currentApp }) => (
<Header
onProjectSelect={pId =>
navigate(urlJoin(currentApp?.homepage, "projects", pId))
// Return user to /projects/:projectId (MLP project landing page) if app is project agnostic
navigate(urlJoin(currentApp?.is_project_agnostic ? "" : currentApp?.homepage, "projects", pId))
}
docLinks={config.DOC_LINKS}
/>
Expand Down
24 changes: 24 additions & 0 deletions ui/packages/app/src/caraml_ai/CaraMLAIPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from "react";
import { EuiPageTemplate } from "@elastic/eui";
import config from "./../config";

export const CaraMLAIPage = () => {
const iframe = `<iframe src=${config.CARAML_AI_STREAMLIT_HOMEPAGE} style="height: 80vh; width: 100%;"></iframe>`

function Iframe(props) {
return (<div dangerouslySetInnerHTML={ {__html: props.iframe?props.iframe:""}} />);
}
return (
<EuiPageTemplate restrictWidth="90%" panelled={false}>
<EuiPageTemplate.Header
bottomBorder={false}
iconType="timelionApp"
pageTitle="CaraML AI"
/>

<EuiPageTemplate.Section paddingSize="none">
<Iframe iframe={iframe} />
</EuiPageTemplate.Section>
</EuiPageTemplate>
);
};
2 changes: 1 addition & 1 deletion ui/packages/app/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const config = {
MAX_AUTHZ_CACHE_EXPIRY_MINUTES: parseInt(
getEnv("REACT_APP_MAX_AUTHZ_CACHE_EXPIRY_MINUTES") || "0"
),

CLOCKWORK_UI_HOMEPAGE: getEnv("REACT_APP_CLOCKWORK_UI_HOMEPAGE"),
KUBEFLOW_UI_HOMEPAGE: getEnv("REACT_APP_KUBEFLOW_UI_HOMEPAGE"),
CARAML_AI_STREAMLIT_HOMEPAGE: getEnv("REACT_APP_CARAML_AI_STREAMLIT_HOMEPAGE"),
ALLOW_CUSTOM_STREAM:
getEnv("REACT_APP_ALLOW_CUSTOM_STREAM") != null
? getEnv("REACT_APP_ALLOW_CUSTOM_STREAM")
Expand Down
5 changes: 2 additions & 3 deletions ui/packages/lib/src/components/nav_drawer/NavDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ export const NavDrawer = ({ docLinks }) => {
className: isAppActive
? "euiTreeView__node---small---active"
: "euiTreeView__node---small",

callback: () =>
!children || !currentProject
a.is_project_agnostic ? (window.location.href = a.homepage) : (!children || !currentProject
? (window.location.href = !!currentProject
? urlJoin(a.homepage, "projects", currentProject.id)
: a.homepage)
: {},
: {}),
children: children
};
});
Expand Down
Loading