) => {
@@ -64,15 +88,9 @@ const Message = ({ setter }: Props) => {
placeholder="Send message..."
value={inputValue}
onChange={e => setInputValue(e.target.value)}
- onKeyDown={handleKeyPress}
+ onKeyDown={e => canSendMessage && handleKeyPress(e)}
/>
- {/* {
- return (event.target as HTMLElement).classList.toggle('selected')
- }}
- >
*/}
- } onClick={handleClick} />
+ } onClick={handleClick} />
)
}
diff --git a/ui/src/hooks/useAuth.ts b/ui/src/hooks/useAuth.ts
index 225ce41..11b61f3 100644
--- a/ui/src/hooks/useAuth.ts
+++ b/ui/src/hooks/useAuth.ts
@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-import { adminAtom, userAtom, usernameAtom } from '@atoms/index';
+import { adminAtom, userWithTokenAtom, usernameAtom } from '@atoms/index';
import { useAtom } from 'jotai';
import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
@@ -25,7 +25,7 @@ interface User {
}
const useAuth = () => {
- const [user, setUser] = useAtom(userAtom);
+ const [user, setUser] = useAtom(userWithTokenAtom);
const [, setUsername] = useAtom(usernameAtom);
const [, setAdmin] = useAtom(adminAtom);
const navigate = useNavigate()
diff --git a/ui/src/services/Api.ts b/ui/src/services/Api.ts
index 31730ec..4f5e696 100644
--- a/ui/src/services/Api.ts
+++ b/ui/src/services/Api.ts
@@ -13,6 +13,8 @@
// limitations under the License.
import { User } from '@shared/types';
+import { Session } from '@shared/types/session';
+import { Query } from '@shared/types/workflow';
import axios, { AxiosResponse } from 'axios';
@@ -44,36 +46,12 @@ class ApiClient {
return null;
}
- async listSessions(username?: string, mode?: string, last?: number) {
+ async getUsers() {
try {
- const response = await this.client.get('/sessions', {
- params: { last: last, username: username, mode: mode || 'short' }
- })
+ const response = await this.client.get(`/users`)
return this.handleResponse(response)
} catch (error) {
- return this.handleError(error as Error)
- }
- }
-
- async getSession(id?: string, username?: string) {
- try {
- const response = await this.client.get(`/session/${id || '$last'}`, {
- headers: { 'x-username': username || 'guest' }
- })
- return this.handleResponse(response)
- } catch (error) {
- return this.handleError(error as Error)
- }
- }
-
- async getUsers(username?: string) {
- try {
- const response = await this.client.get(`/users`, {
- headers: { 'x-username': username || 'guest' }
- })
- return this.handleResponse(response)
- } catch (error) {
- return this.handleError(error as Error)
+ this.handleError(error as Error)
}
}
@@ -113,14 +91,56 @@ class ApiClient {
}
}
- async submitQuery(id: string, question: string, username?: string) {
+ async getSessions(username?: string) {
+ try {
+ const response = await this.client.get(`/users/${username}/sessions`)
+ return this.handleResponse(response)
+ } catch (error) {
+ return this.handleError(error as Error)
+ }
+ }
+
+ async getSession(username: string, id: string,) {
+ try {
+ const response = await this.client.get(`users/${username}/sessions/${id}`)
+ return this.handleResponse(response)
+ } catch (error) {
+ return this.handleError(error as Error)
+ }
+ }
+
+ async createSession(username: string, session: Session) {
+ try {
+ const response = await this.client.post(`users/${username}/sessions`, session)
+ return this.handleResponse(response)
+ } catch (error) {
+ return this.handleError(error as Error)
+ }
+ }
+
+ async updateSession(username: string, session: Session) {
+ try {
+ const response = await this.client.put(`/users/${username}/sessions/${session.name}`, session)
+ return this.handleResponse(response)
+ } catch (error) {
+ return this.handleError(error as Error)
+ }
+ }
+
+ async deleteSession(username: string, session: Session) {
+ try {
+ const response = await this.client.delete(`/users/${username}/sessions/${session.uid}`)
+ return this.handleResponse(response)
+ } catch (error) {
+ return this.handleError(error as Error)
+ }
+ }
+
+ async inferWorkflow(projectId: string, workflowId: string, query: Query) {
try {
const response = await this.client.post(
- '/pipeline/default/run',
- { session_id: id, question: question },
- {
- headers: { 'x-username': username || 'guest' }
- }
+ `/projects/${projectId}/workflows/${workflowId}/infer`,
+ query
)
return this.handleResponse(response)
} catch (error) {
diff --git a/ui/src/shared/theme.ts b/ui/src/shared/theme.ts
index 6cc98b8..c5d12f7 100644
--- a/ui/src/shared/theme.ts
+++ b/ui/src/shared/theme.ts
@@ -54,7 +54,8 @@ export const colors = {
gray900: '#1A202C',
mint: '#4CD5B1',
- mintDark: '#177D7C'
+ mintLight: '#45cca9',
+ mintDark: '#369e83'
}
diff --git a/ui/src/shared/types.ts b/ui/src/shared/types/index.ts
similarity index 92%
rename from ui/src/shared/types.ts
rename to ui/src/shared/types/index.ts
index fbae21a..3c31c89 100644
--- a/ui/src/shared/types.ts
+++ b/ui/src/shared/types/index.ts
@@ -64,3 +64,10 @@ export type User = {
full_name?: string;
}
+
+export type APIResponse = {
+ //eslint-disable-next-line
+ data: any[]
+ success: boolean
+ error: string
+}
diff --git a/ui/src/shared/types/session.ts b/ui/src/shared/types/session.ts
new file mode 100644
index 0000000..4132b13
--- /dev/null
+++ b/ui/src/shared/types/session.ts
@@ -0,0 +1,27 @@
+// Copyright 2024 Iguazio
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { ChatHistory } from "."
+
+
+export type Session = {
+ uid?: string
+ name: string
+ description: string
+ labels: { [key: string]: string }
+ owner_id?: string
+ workflow_id?: string
+ history?: ChatHistory[]
+ created?: string
+}
diff --git a/ui/src/shared/types/workflow.ts b/ui/src/shared/types/workflow.ts
new file mode 100644
index 0000000..0ec9cbc
--- /dev/null
+++ b/ui/src/shared/types/workflow.ts
@@ -0,0 +1,44 @@
+// Copyright 2024 Iguazio
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+export type Workflow = {
+ name: string
+ uid: string
+ description: string
+ labels: { [key: string]: string }
+ owner_id: string
+ version: string
+ project_id: string
+ workflow_type: WorkflowType
+ deployment: string
+ workflow_function: string
+ configuration: { [key: string]: string }
+ graph: { [key: string]: string }
+}
+
+
+export enum WorkflowType {
+ INGESTION = 'ingestion',
+ APPLICATION = 'application',
+ DATA_PROCESSING = 'data-processing',
+ TRAINING = 'training',
+ EVALUATION = 'evaluation',
+ DEPLOYMENT = 'deployment'
+}
+
+export type Query = {
+ question: string
+ session_id: string
+ data_source: string
+}