Skip to content

Commit

Permalink
Issue #1064: added edit on maching learning
Browse files Browse the repository at this point in the history
  • Loading branch information
lorev101 committed Aug 7, 2024
1 parent 3d1d00c commit 55251a9
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 26 deletions.
8 changes: 4 additions & 4 deletions js-packages/admin-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,11 @@ export default function App() {
</Route>
</Route>
<Route path="embedding-models" element={<EmbeddingModels />} />
<Route path="embedding-models/create/new" element={<EmbeddingModelCreate />} />
<Route path="embedding-models/:embeddingModelsId" element={<EmbeddingModel />} />
<Route path="embedding-models/new" element={<EmbeddingModelCreate />} />
<Route path="embedding-models/:embeddingModelsId" element={<EmbeddingModelCreate />} />
<Route path="large-languages-models" element={<LargeLanguageModels />} />
<Route path="large-languages-models/:largeLanguagesModelsId" element={<LargeLanguageModelE />} />
<Route path="large-languages-models/create/new" element={<LargeLanguageModel />} />
<Route path="large-languages-models/new" element={<LargeLanguageModel />} />
<Route path="large-languages-models/:largeLanguageModelId" element={<LargeLanguageModel />} />
<Route path="wizard">
<Route path="web-crawler" element={<WebCrawlerWizard />} />
</Route>
Expand Down
11 changes: 7 additions & 4 deletions js-packages/admin-ui/src/components/EmbeddingModelCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { useToast } from "./ToastProvider";
import { useCreateOrUpdateEmbeddingModelMutation, useEmbeddingModelQuery } from "../graphql-generated";
import { ContainerFluid, CustomButtom, MainTitle, TextInput, fromFieldValidators, useForm } from "./Form";
import React from "react";
import { EmbeddingModelQuery } from "./EmbeddingModel";
import { EmbeddingModelsQuery } from "./EmbeddingModels";

gql`
mutation CreateOrUpdateEmbeddingModel($apiKey: String, $apiUrl: String!, $description: String!, $name: String!) {
embeddingModel(embeddingModelDTO: { name: $name, apiKey: $apiKey, apiUrl: $apiUrl, description: $description }) {
mutation CreateOrUpdateEmbeddingModel($id: ID, $apiKey: String, $apiUrl: String!, $description: String!, $name: String!) {
embeddingModel(id: $id, embeddingModelDTO: { name: $name, apiKey: $apiKey, apiUrl: $apiUrl, description: $description }) {
entity {
id
name
Expand All @@ -25,13 +27,14 @@ export function EmbeddingModelCreate() {
skip: !embeddingModelsId || embeddingModelsId === "new",
});
const [createOrUpdateEmbeddingModelsMutate] = useCreateOrUpdateEmbeddingModelMutation({
refetchQueries: [],
refetchQueries: [EmbeddingModelsQuery, EmbeddingModelQuery],
onCompleted(data) {
if (data.embeddingModel?.entity) {
if (embeddingModelsId === "new") {
navigate(`/embedding-models/`, { replace: true });
showToast({ displayType: "success", title: "Models created", content: data.embeddingModel.entity.name ?? "" });
} else {
navigate(`/embedding-models/`, { replace: true });
showToast({ displayType: "info", title: "Models updated", content: data.embeddingModel.entity.name ?? "" });
}
}
Expand All @@ -50,7 +53,7 @@ export function EmbeddingModelCreate() {
originalValues: modelQuery.data?.embeddingModel,
isLoading: modelQuery.loading || modelQuery.loading,
onSubmit(data) {
createOrUpdateEmbeddingModelsMutate({ variables: { ...data } });
createOrUpdateEmbeddingModelsMutate({ variables: { id: embeddingModelsId !== "new" ? embeddingModelsId : undefined, ...data } });
},
getValidationMessages: fromFieldValidators(null),
});
Expand Down
2 changes: 1 addition & 1 deletion js-packages/admin-ui/src/components/EmbeddingModels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function EmbeddingModels() {
field: (data) => data?.embeddingModels,
}}
viewAdd={true}
onCreatePath="create/new/"
onCreatePath="new/"
onDelete={(model) => {
if (model?.id) deleteModelsMutate({ variables: { id: model.id } });
}}
Expand Down
2 changes: 1 addition & 1 deletion js-packages/admin-ui/src/components/LargeLanguageModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useLargeLanguageModelQuery } from "../graphql-generated";
import { ContainerFluid, MainTitle, TextInput } from "./Form";
import React from "react";

const LargeLanguageModel = gql`
export const LargeLanguageModelQ = gql`
query LargeLanguageModel($id: ID!) {
largeLanguageModel(id: $id) {
name
Expand Down
21 changes: 17 additions & 4 deletions js-packages/admin-ui/src/components/LargeLanguageModelCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ import { useCreateOrUpdateLargeLanguageModelMutation, useLargeLanguageModelQuery
import { ContainerFluid, CustomButtom, MainTitle, TextInput, fromFieldValidators, useForm } from "./Form";
import React from "react";
import { CodeInput } from "./CodeInput";
import { LargeLanguageModelsQuery } from "./LargeLanguageModels";
import { LargeLanguageModelQ } from "./LargeLanguageModel";

gql`
mutation CreateOrUpdateLargeLanguageModel($apiKey: String, $apiUrl: String!, $description: String!, $name: String!, $jsonConfig: String) {
const create = gql`
mutation CreateOrUpdateLargeLanguageModel(
$id: ID
$apiKey: String
$apiUrl: String!
$description: String!
$name: String!
$jsonConfig: String
) {
largeLanguageModel(
id: $id
largeLanguageModelDTO: { name: $name, apiKey: $apiKey, apiUrl: $apiUrl, description: $description, jsonConfig: $jsonConfig }
) {
entity {
Expand All @@ -28,13 +38,14 @@ export function LargeLanguageModel() {
skip: !largeLanguageModelId || largeLanguageModelId === "new",
});
const [createOrUpdateEmbeddingModelsMutate] = useCreateOrUpdateLargeLanguageModelMutation({
refetchQueries: [],
refetchQueries: [create, LargeLanguageModelsQuery, LargeLanguageModelQ],
onCompleted(data) {
if (data.largeLanguageModel?.entity) {
if (largeLanguageModelId === "new") {
navigate(`/large-languages-models/`, { replace: true });
showToast({ displayType: "success", title: "Models created", content: data.largeLanguageModel.entity.name ?? "" });
} else {
navigate(`/large-languages-models/`, { replace: true });
showToast({ displayType: "info", title: "Models updated", content: data.largeLanguageModel.entity.name ?? "" });
}
}
Expand All @@ -54,7 +65,9 @@ export function LargeLanguageModel() {
originalValues: modelQuery.data?.largeLanguageModel,
isLoading: modelQuery.loading || modelQuery.loading,
onSubmit(data) {
createOrUpdateEmbeddingModelsMutate({ variables: { ...data } });
createOrUpdateEmbeddingModelsMutate({
variables: { id: largeLanguageModelId !== "new" ? largeLanguageModelId : undefined, ...data },
});
},
getValidationMessages: fromFieldValidators(null),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function LargeLanguageModels() {
queryResult: largeLanguageModels,
field: (data) => data?.largeLanguageModels,
}}
onCreatePath="create/new/"
onCreatePath="new/"
onDelete={(model) => {
if (model?.id) deleteModelsMutate({ variables: { id: model.id } });
}}
Expand Down
16 changes: 8 additions & 8 deletions js-packages/admin-ui/src/components/SideNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ export function SideNavigation({ isSideMenuOpen }: { isSideMenuOpen: boolean })
/>
<SideNavigationItem IsChildren={true} setSelect={setSelect} elementSelect={select} label="Logs" path="/logs" />
</SideNavigationCollapsible>
<SideNavigationItem
IsChildren={false}
setSelect={setSelect}
elementSelect={select}
label="Maching Learning"
path="maching-learning"
/>
<SideNavigationCollapsible label="Embedding models">
<SideNavigationCollapsible label="Machine Learning">
<SideNavigationItem
IsChildren={false}
setSelect={setSelect}
elementSelect={select}
label="Hugging Face Integration"
path="maching-learning"
/>
<SideNavigationItem
IsChildren={true}
setSelect={setSelect}
Expand Down
12 changes: 9 additions & 3 deletions js-packages/admin-ui/src/graphql-generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4983,6 +4983,7 @@ export type EmbeddingModelQueryVariables = Exact<{
export type EmbeddingModelQuery = { __typename?: 'Query', embeddingModel?: { __typename?: 'EmbeddingModel', name?: string | null, description?: string | null, apiUrl?: string | null, apiKey?: string | null } | null };

export type CreateOrUpdateEmbeddingModelMutationVariables = Exact<{
id?: InputMaybe<Scalars['ID']>;
apiKey?: InputMaybe<Scalars['String']>;
apiUrl: Scalars['String'];
description: Scalars['String'];
Expand Down Expand Up @@ -5176,6 +5177,7 @@ export type LargeLanguageModelQueryVariables = Exact<{
export type LargeLanguageModelQuery = { __typename?: 'Query', largeLanguageModel?: { __typename?: 'LargeLanguageModel', name?: string | null, description?: string | null, apiUrl?: string | null, apiKey?: string | null } | null };

export type CreateOrUpdateLargeLanguageModelMutationVariables = Exact<{
id?: InputMaybe<Scalars['ID']>;
apiKey?: InputMaybe<Scalars['String']>;
apiUrl: Scalars['String'];
description: Scalars['String'];
Expand Down Expand Up @@ -9919,8 +9921,9 @@ export type EmbeddingModelQueryHookResult = ReturnType<typeof useEmbeddingModelQ
export type EmbeddingModelLazyQueryHookResult = ReturnType<typeof useEmbeddingModelLazyQuery>;
export type EmbeddingModelQueryResult = Apollo.QueryResult<EmbeddingModelQuery, EmbeddingModelQueryVariables>;
export const CreateOrUpdateEmbeddingModelDocument = gql`
mutation CreateOrUpdateEmbeddingModel($apiKey: String, $apiUrl: String!, $description: String!, $name: String!) {
mutation CreateOrUpdateEmbeddingModel($id: ID, $apiKey: String, $apiUrl: String!, $description: String!, $name: String!) {
embeddingModel(
id: $id
embeddingModelDTO: {name: $name, apiKey: $apiKey, apiUrl: $apiUrl, description: $description}
) {
entity {
Expand All @@ -9945,6 +9948,7 @@ export type CreateOrUpdateEmbeddingModelMutationFn = Apollo.MutationFunction<Cre
* @example
* const [createOrUpdateEmbeddingModelMutation, { data, loading, error }] = useCreateOrUpdateEmbeddingModelMutation({
* variables: {
* id: // value for 'id'
* apiKey: // value for 'apiKey'
* apiUrl: // value for 'apiUrl'
* description: // value for 'description'
Expand Down Expand Up @@ -10946,8 +10950,9 @@ export type LargeLanguageModelQueryHookResult = ReturnType<typeof useLargeLangua
export type LargeLanguageModelLazyQueryHookResult = ReturnType<typeof useLargeLanguageModelLazyQuery>;
export type LargeLanguageModelQueryResult = Apollo.QueryResult<LargeLanguageModelQuery, LargeLanguageModelQueryVariables>;
export const CreateOrUpdateLargeLanguageModelDocument = gql`
mutation CreateOrUpdateLargeLanguageModel($apiKey: String, $apiUrl: String!, $description: String!, $name: String!, $jsonConfig: String) {
mutation CreateOrUpdateLargeLanguageModel($id: ID, $apiKey: String, $apiUrl: String!, $description: String!, $name: String!, $jsonConfig: String) {
largeLanguageModel(
id: $id
largeLanguageModelDTO: {name: $name, apiKey: $apiKey, apiUrl: $apiUrl, description: $description, jsonConfig: $jsonConfig}
) {
entity {
Expand All @@ -10972,6 +10977,7 @@ export type CreateOrUpdateLargeLanguageModelMutationFn = Apollo.MutationFunction
* @example
* const [createOrUpdateLargeLanguageModelMutation, { data, loading, error }] = useCreateOrUpdateLargeLanguageModelMutation({
* variables: {
* id: // value for 'id'
* apiKey: // value for 'apiKey'
* apiUrl: // value for 'apiUrl'
* description: // value for 'description'
Expand Down Expand Up @@ -14304,4 +14310,4 @@ export function useCreateYouTubeDataSourceMutation(baseOptions?: Apollo.Mutation
export type CreateYouTubeDataSourceMutationHookResult = ReturnType<typeof useCreateYouTubeDataSourceMutation>;
export type CreateYouTubeDataSourceMutationResult = Apollo.MutationResult<CreateYouTubeDataSourceMutation>;
export type CreateYouTubeDataSourceMutationOptions = Apollo.BaseMutationOptions<CreateYouTubeDataSourceMutation, CreateYouTubeDataSourceMutationVariables>;
// Generated on 2024-08-07T15:32:59+02:00
// Generated on 2024-08-07T17:25:10+02:00

0 comments on commit 55251a9

Please sign in to comment.