Skip to content

Commit 4e9bcda

Browse files
authored
Merge pull request #71 from cloudera/new-templates-dev
UI Issues that have been resolved by the PR: Evaluate button in top section is disabled always (now it is fixed) Re-evaluate does not work properly The AiAssitant icon has been added for the Generate Custom Prompt button and the position is moved to the top right MaxToken has been removed from Parameters section
2 parents 262115e + 40518b3 commit 4e9bcda

File tree

9 files changed

+118
-26
lines changed

9 files changed

+118
-26
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*******************************************************************************
2+
* CLOUDERA APPLIED MACHINE LEARNING PROTOTYPE (AMP)
3+
* (C) Cloudera, Inc. 2024
4+
* All rights reserved.
5+
*
6+
* Applicable Open Source License: Apache 2.0
7+
*
8+
* NOTE: Cloudera open source products are modular software products
9+
* made up of hundreds of individual components, each of which was
10+
* individually copyrighted. Each Cloudera open source product is a
11+
* collective work under U.S. Copyright Law. Your license to use the
12+
* collective work is as provided in your written agreement with
13+
* Cloudera. Used apart from the collective work, this file is
14+
* licensed for your use pursuant to the open source license
15+
* identified above.
16+
*
17+
* This code is provided to you pursuant a written agreement with
18+
* (i) Cloudera, Inc. or (ii) a third-party authorized to distribute
19+
* this code. If you do not have a written agreement with Cloudera nor
20+
* with an authorized and properly licensed third party, you do not
21+
* have any rights to access nor to use this code.
22+
*
23+
* Absent a written agreement with Cloudera, Inc. ("Cloudera") to the
24+
* contrary, A) CLOUDERA PROVIDES THIS CODE TO YOU WITHOUT WARRANTIES OF ANY
25+
* KIND; (B) CLOUDERA DISCLAIMS ANY AND ALL EXPRESS AND IMPLIED
26+
* WARRANTIES WITH RESPECT TO THIS CODE, INCLUDING BUT NOT LIMITED TO
27+
* IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND
28+
* FITNESS FOR A PARTICULAR PURPOSE; (C) CLOUDERA IS NOT LIABLE TO YOU,
29+
* AND WILL NOT DEFEND, INDEMNIFY, NOR HOLD YOU HARMLESS FOR ANY CLAIMS
30+
* ARISING FROM OR RELATED TO THE CODE; AND (D)WITH RESPECT TO YOUR EXERCISE
31+
* OF ANY RIGHTS GRANTED TO YOU FOR THE CODE, CLOUDERA IS NOT LIABLE FOR ANY
32+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR
33+
* CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT LIMITED TO, DAMAGES
34+
* RELATED TO LOST REVENUE, LOST PROFITS, LOSS OF INCOME, LOSS OF
35+
* BUSINESS ADVANTAGE OR UNAVAILABILITY, OR LOSS OR CORRUPTION OF
36+
* DATA.
37+
******************************************************************************/
38+
import React from "react";
39+
40+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
41+
const AiAssistantIcon = (props: any) =>
42+
/*#__PURE__*/ React.createElement(
43+
"svg",
44+
{
45+
viewBox: "0 0 24 24",
46+
fill: "none",
47+
width: "1em",
48+
height: "1em",
49+
className: "cdp-icon-ai-assistant",
50+
...props,
51+
},
52+
/*#__PURE__*/ React.createElement("path", {
53+
d: "M2 7.207l3.838-1.383L7.207 2 8.58 5.824l3.833 1.383-3.833 1.378-1.374 3.83-1.396-3.83-3.812-1.378zM3.5 18.174l2.82-1.016 1.006-2.81 1.01 2.81 2.816 1.016-2.817 1.012L7.325 22 6.3 19.186l-2.8-1.012zM8.865 13.06l4.842-1.745 1.726-4.823 1.732 4.823L22 13.059l-4.835 1.737-1.732 4.83-1.76-4.83-4.808-1.737z",
54+
fill: "currentColor",
55+
}),
56+
);
57+
58+
export default AiAssistantIcon;

app/client/src/pages/DataGenerator/Configure.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ export const StyledTextArea = styled(Input.TextArea)`
2626
`;
2727

2828
export const USECASE_OPTIONS = [
29+
// { label: 'Lending Dataset', value: 'lending_dataset' },
30+
// { label: 'Credit Card History', value: 'credit_card_history' },
31+
// { label: 'Housing Dataset', value: 'housing_dataset' },
2932
{ label: 'Code Generation', value: 'code_generation' },
3033
{ label: 'Text to SQL', value: 'text2sql' },
31-
{ label: 'Custom', value: 'custom' }
34+
{ label: 'Custom', value: 'custom' },
35+
3236
];
3337

3438
export const WORKFLOW_OPTIONS = [

app/client/src/pages/DataGenerator/CustomPromptButton.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useMutation } from "@tanstack/react-query";
44
import styled from "styled-components";
55
import { fetchCustomPrompt } from "./hooks";
66
import Loading from "../Evaluator/Loading";
7+
import AiAssistantIcon from "./AiAssistantIcon";
78

89
interface Props {
910
model_id: string;
@@ -45,6 +46,12 @@ const StyledFlex = styled(Flex)`
4546
flex-direction: row-reverse;
4647
`;
4748

49+
const StyledIcon = styled.div`
50+
svg {
51+
font-size: 20px;
52+
}
53+
`;
54+
4855

4956
const CustomPromptButton: React.FC<Props> = ({ model_id, inference_type, caii_endpoint, use_case, example_path, setPrompt }) => {
5057
const [form] = Form.useForm();
@@ -92,13 +99,19 @@ const CustomPromptButton: React.FC<Props> = ({ model_id, inference_type, caii_en
9299

93100
return (
94101
<>
95-
<Button onClick={() => setShowModal(true)} style={{ marginLeft: '8px' }}>Generate Custom Prompt</Button>
102+
<Button type="link"
103+
onClick={() => setShowModal(true)}
104+
style={{ marginLeft: '8px' }}
105+
icon={
106+
<StyledIcon><AiAssistantIcon /></StyledIcon>
107+
}>Generate Prompt</Button>
96108
{showModal &&
97109
(
98110
<StyledModal
99111
visible={showModal}
100112
okText={`Generate`}
101113
title={`Generate Custom Prompt`}
114+
onClose={() => setShowModal(false)}
102115
footer={
103116
<Row>
104117
<Col sm={12} />

app/client/src/pages/DataGenerator/Parameters.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ const Parameters = () => {
185185
</Col>
186186
</Row>
187187
</StyledFormItem>
188-
<StyledFormItem
188+
{/* <StyledFormItem
189189
name={['model_parameters', ModelParameters.MAX_TOKENS]}
190190
label={<ParamLabel>{LABELS[ModelParameters.MAX_TOKENS]}</ParamLabel>}
191191
labelCol={{ span: 24 }}
@@ -215,7 +215,7 @@ const Parameters = () => {
215215
/>
216216
</Col>
217217
</Row>
218-
</StyledFormItem>
218+
</StyledFormItem> */}
219219
</>
220220

221221
)

app/client/src/pages/DataGenerator/Prompt.tsx

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ const FormLabel = styled(Title)`
2626
const StyledFormItem = styled(Form.Item)`
2727
margin-bottom: 0px;
2828
`;
29+
30+
const StyledPromptFormItem = styled(StyledFormItem)`
31+
label {
32+
width: 100%;
33+
}
34+
`;
35+
2936
const RestoreDefaultBtn = styled(Button)`
3037
max-width: fit-content;
3138
`;
@@ -191,22 +198,37 @@ const Prompt = () => {
191198
<LeftCol span={17}>
192199
<Flex vertical gap={14}>
193200
<div>
194-
<StyledFormItem
201+
<StyledPromptFormItem
195202
name='custom_prompt'
196203
label={
197-
<FormLabel level={4}>
204+
<div style={{ width: '100%', height: '32px', display: 'flex' }}>
205+
<FormLabel level={4} style={{ width: '240px'}}>
198206
<Space>
199207
<>{'Prompt'}</>
200208
<TooltipIcon message={'Enter a prompt to describe your dataset'}/>
201209
</Space>
202210
</FormLabel>
211+
<Flex style={{ flexDirection: 'row-reverse', width: '100%' }}>
212+
{(form.getFieldValue('use_case') === Usecases.CUSTOM.toLowerCase() ||
213+
workflow_type === WorkflowType.CUSTOM_DATA_GENERATION) &&
214+
<CustomPromptButton
215+
model_id={model_id}
216+
inference_type={inference_type}
217+
caii_endpoint={caii_endpoint}
218+
use_case={useCase}
219+
example_path={form.getFieldValue('example_path') || null}
220+
setPrompt={setPrompt}
221+
/>
222+
}
223+
</Flex>
224+
</div>
203225
}
204226
labelCol={{ span: 24 }}
205227
wrapperCol={{ span: 24 }}
206228
shouldUpdate
207229
>
208230
<StyledTextArea autoSize placeholder={'Enter a prompt'}/>
209-
</StyledFormItem>
231+
</StyledPromptFormItem>
210232
<RestoreDefaultBtn
211233
onClick={() => {
212234
return Modal.warning({
@@ -229,21 +251,10 @@ const Prompt = () => {
229251
),
230252
maskClosable: true,
231253
})
232-
}}
233-
>
234-
{'Restore'}
254+
}}>
255+
{'Restore'}
235256
</RestoreDefaultBtn>
236-
{(form.getFieldValue('use_case') === Usecases.CUSTOM.toLowerCase() ||
237-
workflow_type === WorkflowType.CUSTOM_DATA_GENERATION) &&
238-
<CustomPromptButton
239-
model_id={model_id}
240-
inference_type={inference_type}
241-
caii_endpoint={caii_endpoint}
242-
use_case={useCase}
243-
example_path={form.getFieldValue('example_path') || null}
244-
setPrompt={setPrompt}
245-
/>
246-
}
257+
247258
</div>
248259
{((workflow_type === WorkflowType.CUSTOM_DATA_GENERATION && !isEmpty(doc_paths)) ||
249260
(workflow_type === WorkflowType.SUPERVISED_FINE_TUNING && !isEmpty(doc_paths))) &&

app/client/src/pages/DataGenerator/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { ModelProviders, ModelProvidersDropdownOpts } from './types';
22

33
export const MODEL_PROVIDER_LABELS = {
44
[ModelProviders.BEDROCK]: 'AWS Bedrock',
5-
[ModelProviders.CAII]: 'Cloudera AI Inference Service'
5+
[ModelProviders.CAII]: 'Cloudera AI Inference Service',
6+
[ModelProviders.GOOGLE_GEMINI]: 'Google Gemini',
7+
[ModelProviders.AZURE_OPENAI]: 'Azure OpenAI',
68
};
79

810
export const MIN_SEED_INSTRUCTIONS = 1

app/client/src/pages/DataGenerator/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export enum Usecases {
1616

1717
export enum ModelProviders {
1818
BEDROCK = 'aws_bedrock',
19-
CAII = 'CAII'
19+
CAII = 'CAII',
20+
AZURE_OPENAI = 'AZURE_OPENAI',
21+
GOOGLE_GEMINI = 'GOOGLE_GEMINI',
2022
}
2123

2224
export type ModelProvidersDropdownOpts = { label: string, value: ModelProviders }[];

app/client/src/pages/Evaluator/ReevaluatorPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ const ReevaluatorPage: React.FC = () => {
5151
}, [evaluate]);
5252

5353
const evaluateDataset = async (formData: unknown) => {
54-
const response = await fetch(`${BASE_API_URL}/synthesis/evaluate`, {
54+
const url = dataset.technique === 'freeforms' ?
55+
`${BASE_API_URL}/synthesis/evaluate` : `${BASE_API_URL}/synthesis/evaluate_freeform`;
56+
const response = await fetch(url, {
5557
method: 'POST',
5658
headers: {
5759
'Content-Type': 'application/json',

app/client/src/pages/Home/EvaluateButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const EvaluateButton: React.FC = () => {
1717
const {data, isLoading} = useDatasets();
1818

1919
useEffect(() => {
20-
if(!isEmpty(data?.datasets)) {
21-
setDatasets(data?.datasets);
20+
if(!isEmpty(data?.data)) {
21+
setDatasets(data?.data);
2222
}
2323
}, [data]);
2424

0 commit comments

Comments
 (0)