code7-leia 0.2.20 → 0.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ import React, { ReactNode } from 'react';
2
+ declare type TextAreaProps = {
3
+ id?: string;
4
+ label?: string;
5
+ placeholder?: string;
6
+ className?: string;
7
+ description?: string;
8
+ helper?: string;
9
+ error?: string;
10
+ color?: '' | 'danger' | 'success';
11
+ size?: 'small' | 'medium' | 'large';
12
+ startIcon?: string | ReactNode;
13
+ endIcon?: string | ReactNode;
14
+ disabled?: boolean;
15
+ marginBottom?: string;
16
+ rows?: number;
17
+ } & React.TextareaHTMLAttributes<HTMLTextAreaElement>;
18
+ declare const TextArea: React.FC<TextAreaProps>;
19
+ export default TextArea;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ declare type ContainerProps = {
3
+ marginBottom?: string;
4
+ };
5
+ export declare const Container: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, ContainerProps>>;
6
+ export declare const InputWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
7
+ export declare const LabelWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, never>>;
8
+ export declare const CustomTextArea: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, never>>;
9
+ export declare const Helper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
10
+ export declare const Error: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
11
+ export {};
@@ -10,6 +10,7 @@ interface Props {
10
10
  description: string;
11
11
  }];
12
12
  token: string;
13
+ env: string;
13
14
  children?: React.ReactNode;
14
15
  }
15
16
  export declare const useSharedProps: () => Props;
@@ -33,6 +33,7 @@ declare type Buttons = {
33
33
  declare type TestArea = {
34
34
  description: string;
35
35
  typeSentence: string;
36
+ typePrompt: string;
36
37
  selectPersona: string;
37
38
  selectPresset: string;
38
39
  emptyState: {
@@ -0,0 +1,3 @@
1
+ export declare const API_TOKEN = "API_TOKEN";
2
+ declare const _default: import("axios").AxiosInstance;
3
+ export default _default;
@@ -1,8 +1,9 @@
1
- export declare const getFilesAction: (id: string, token: string) => {
1
+ export declare const getFilesAction: (id: string, token: string, env: string) => {
2
2
  type: string;
3
3
  payload: {
4
4
  id: string;
5
5
  token: string;
6
+ env: string;
6
7
  };
7
8
  };
8
9
  export declare const getFilesActionSuccess: ({ files }: any) => {
@@ -11,13 +12,14 @@ export declare const getFilesActionSuccess: ({ files }: any) => {
11
12
  files: any;
12
13
  };
13
14
  };
14
- export declare const deleteFilesAction: (name: string, id: string, language: string, token: string) => {
15
+ export declare const deleteFilesAction: (name: string, id: string, language: string, token: string, env: string) => {
15
16
  type: string;
16
17
  payload: {
17
18
  name: string;
18
19
  id: string;
19
20
  language: string;
20
21
  token: string;
22
+ env: string;
21
23
  };
22
24
  };
23
25
  export declare const deleteFilesActionSuccess: ({ files }: any) => {
@@ -26,7 +28,7 @@ export declare const deleteFilesActionSuccess: ({ files }: any) => {
26
28
  files: any;
27
29
  };
28
30
  };
29
- export declare const uploadFilesAction: (file: any, id: string, pressets: string[], language: string, token: string) => {
31
+ export declare const uploadFilesAction: (file: any, id: string, pressets: string[], language: string, token: string, env: string) => {
30
32
  type: string;
31
33
  payload: {
32
34
  file: any;
@@ -34,6 +36,7 @@ export declare const uploadFilesAction: (file: any, id: string, pressets: string
34
36
  pressets: string[];
35
37
  language: string;
36
38
  token: string;
39
+ env: string;
37
40
  };
38
41
  };
39
42
  export declare const uploadFilesActionSuccess: ({ files }: any) => {
@@ -42,23 +45,26 @@ export declare const uploadFilesActionSuccess: ({ files }: any) => {
42
45
  files: any;
43
46
  };
44
47
  };
45
- export declare const trainingAction: (id: string, pressets: string[], language: string, token: string) => {
48
+ export declare const trainingAction: (id: string, pressets: string[], language: string, token: string, env: string) => {
46
49
  type: string;
47
50
  payload: {
48
51
  id: string;
49
52
  pressets: string[];
50
53
  language: string;
51
54
  token: string;
55
+ env: string;
52
56
  };
53
57
  };
54
- export declare const testAction: (question: string, profile: string, presset: string, files_directory: string, token: string) => {
58
+ export declare const testAction: (question: string, prompt: string, profile: string, presset: string, files_directory: string, token: string, env: string) => {
55
59
  type: string;
56
60
  payload: {
57
61
  question: string;
62
+ prompt: string;
58
63
  profile: string;
59
64
  presset: string;
60
65
  files_directory: string;
61
66
  token: string;
67
+ env: string;
62
68
  };
63
69
  };
64
70
  export declare const testActionSuccess: ({ message }: any) => {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.20",
2
+ "version": "0.2.22",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
package/src/Leia.tsx CHANGED
@@ -22,7 +22,7 @@ export const Leia = (props: Props) => {
22
22
  }, [pathname]);
23
23
 
24
24
  return (
25
- <SharedPropsProvider propTags={{ tags: [] }} personas={[{name: '', description: ''}]} {...props}>
25
+ <SharedPropsProvider propTags={{ tags: [] }} env='' personas={[{name: '', description: ''}]} {...props}>
26
26
  <>
27
27
  <Tabs
28
28
  value={activeTab}
@@ -23,7 +23,7 @@ import { SharedPropsProvider, useSharedProps } from '../../contexts/SharedPropsP
23
23
  import { deleteFilesAction, getFilesAction, uploadFilesAction, trainingAction } from '../../store/modules/actions';
24
24
 
25
25
  export const FileArea = () => {
26
- const { id, language, propTags, token } = useSharedProps();
26
+ const { id, language, propTags, token, env } = useSharedProps();
27
27
  const [files, setFiles] = useState<FileData[]>([]);
28
28
  const [initialFiles, setInitialFiles] = useState<FileData[]>([]);
29
29
  const [uploadFile, setUploadFile] = useState<{ content: ArrayBuffer | string; properties: File }>();
@@ -40,7 +40,7 @@ export const FileArea = () => {
40
40
  const tags = propTags ? propTags.tags : [];
41
41
 
42
42
  useEffect(() => {
43
- dispatch(getFilesAction(id, token))
43
+ dispatch(getFilesAction(id, token, env))
44
44
  }, [id])
45
45
 
46
46
  useEffect(() => {
@@ -108,19 +108,19 @@ export const FileArea = () => {
108
108
  }
109
109
 
110
110
  const deleteFile = () => {
111
- dispatch(deleteFilesAction(fileDelete, id, language, token))
111
+ dispatch(deleteFilesAction(fileDelete, id, language, token, env))
112
112
  setModalDelete(false)
113
113
  }
114
114
 
115
115
  const handleUploadFile = () => {
116
- dispatch(uploadFilesAction(uploadFile, id, presset, language, token))
116
+ dispatch(uploadFilesAction(uploadFile, id, presset, language, token, env))
117
117
  setModal(false)
118
118
  setUploadFile(undefined)
119
119
  setPresset([])
120
120
  };
121
121
 
122
122
  const handleTrain = () => {
123
- dispatch(trainingAction(id, presset, language, token))
123
+ dispatch(trainingAction(id, presset, language, token, env))
124
124
  setModalTraining(false)
125
125
  setPresset([])
126
126
  };
@@ -272,7 +272,7 @@ export const FileArea = () => {
272
272
  }
273
273
 
274
274
  return (
275
- <SharedPropsProvider id={id} language={language} token={token} propTags={{ tags: [] }} personas={[{name: '', description: ''}]}>
275
+ <SharedPropsProvider id={id} language={language} token={token} env={env} propTags={{ tags: [] }} personas={[{name: '', description: ''}]}>
276
276
  <S.Container>
277
277
  {renderFiles()}
278
278
  </S.Container>
@@ -0,0 +1,97 @@
1
+ import React, { forwardRef, ReactNode } from 'react';
2
+ import cc from 'classcat';
3
+
4
+ import {
5
+ Container,
6
+ LabelWrapper,
7
+ CustomTextArea,
8
+ InputWrapper,
9
+ Helper,
10
+ Error,
11
+ } from './styles';
12
+
13
+ type TextAreaProps = {
14
+ id?: string;
15
+ label?: string;
16
+ placeholder?: string;
17
+ className?: string;
18
+ description?: string;
19
+ helper?: string;
20
+ error?: string;
21
+ color?: '' | 'danger' | 'success';
22
+ size?: 'small' | 'medium' | 'large';
23
+ startIcon?: string | ReactNode;
24
+ endIcon?: string | ReactNode;
25
+ disabled?: boolean;
26
+ marginBottom?: string;
27
+ rows?: number;
28
+ } & React.TextareaHTMLAttributes<HTMLTextAreaElement>;
29
+
30
+ const TextArea: React.FC<TextAreaProps> = forwardRef<HTMLTextAreaElement, TextAreaProps>(
31
+ (
32
+ {
33
+ id,
34
+ label,
35
+ description,
36
+ helper,
37
+ error,
38
+ placeholder,
39
+ className,
40
+ size = 'medium',
41
+ color = '',
42
+ disabled = false,
43
+ startIcon,
44
+ endIcon,
45
+ marginBottom = '3px',
46
+ rows = 4,
47
+ ...props
48
+ },
49
+ ref
50
+ ) => {
51
+ const selfId = id || `input__${Math.random().toString(36).substr(2, 9)}`;
52
+
53
+ return (
54
+ <Container className={className} marginBottom={marginBottom}>
55
+ {label && (
56
+ <LabelWrapper htmlFor={selfId}>
57
+ <span className="label">{label}</span>
58
+ {description && <span className="description">{description}</span>}
59
+ </LabelWrapper>
60
+ )}
61
+
62
+ <InputWrapper className={cc({ hasLabel: Boolean(label) })}>
63
+ <CustomTextArea
64
+ className={cc([
65
+ 'input',
66
+ size,
67
+ color,
68
+ {
69
+ error: Boolean(error),
70
+ 'has-start-icon': Boolean(startIcon),
71
+ 'has-end-icon': Boolean(endIcon),
72
+ },
73
+ ])}
74
+ id={selfId}
75
+ placeholder={placeholder}
76
+ disabled={disabled}
77
+ rows={rows}
78
+ ref={ref}
79
+ {...props}
80
+ />
81
+ {startIcon && (
82
+ <span className={cc(['icon', 'start-icon'])}>{startIcon}</span>
83
+ )}
84
+ {endIcon && (
85
+ <span className={cc(['icon', 'end-icon'])}>{endIcon}</span>
86
+ )}
87
+ </InputWrapper>
88
+
89
+ {helper && <Helper className={cc(['helper', color])}>{helper}</Helper>}
90
+
91
+ {error && <Error className={cc(['error'])}>{error}</Error>}
92
+ </Container>
93
+ );
94
+ }
95
+ );
96
+
97
+ export default TextArea;
@@ -0,0 +1,169 @@
1
+ import styled from 'styled-components';
2
+
3
+ type ContainerProps = {
4
+ marginBottom?: string;
5
+ };
6
+
7
+ export const Container = styled.div<ContainerProps>`
8
+ display: flex;
9
+ flex-flow: column;
10
+ margin-bottom: ${({ marginBottom }) => marginBottom};
11
+ `;
12
+
13
+ export const InputWrapper = styled.div`
14
+ display: flex;
15
+ align-items: center;
16
+ position: relative;
17
+
18
+ .icon {
19
+ position: absolute;
20
+ color: #5a5d68;
21
+
22
+ &.start-icon {
23
+ left: 12px;
24
+ }
25
+ &.end-icon {
26
+ right: 12px;
27
+ }
28
+ }
29
+
30
+ & .pass-view {
31
+ position: absolute;
32
+ right: 0;
33
+ top: 0;
34
+ bottom: 0;
35
+ padding: 14px;
36
+ font-size: 1rem;
37
+ color: #5a5d68;
38
+ }
39
+ `;
40
+
41
+ export const LabelWrapper = styled.label`
42
+ margin-bottom: 8px;
43
+
44
+ .label {
45
+ display: block;
46
+ color: #5a5d68;
47
+
48
+ font-style: normal;
49
+ font-weight: 600;
50
+ font-size: 0.875rem;
51
+ line-height: 114%;
52
+ letter-spacing: -0.02em;
53
+ }
54
+
55
+ .description {
56
+ font-style: normal;
57
+ font-weight: 500;
58
+ font-size: 0.625rem;
59
+ line-height: 120%;
60
+ color: #5a5d68;
61
+ display: block;
62
+ }
63
+ `;
64
+
65
+ export const CustomTextArea = styled.textarea`
66
+ font-family: 'Monospace', -apple-system, BlinkMacSystemFont, sans-serif;
67
+ font-size: 0.875rem;
68
+ font-style: normal;
69
+ font-weight: 500;
70
+ line-height: 20px;
71
+ text-align: left;
72
+ letter-spacing: -0.02em;
73
+ resize: vertical;
74
+ padding: 8px 12px;
75
+
76
+ border-radius: 4px;
77
+ border: 1px solid #979aa5;
78
+ color: #5a5d68 !important;
79
+ width: 100%;
80
+
81
+ background: #ffffff;
82
+ transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out,
83
+ border 0.2s ease-in-out;
84
+
85
+ &:focus {
86
+ outline: none;
87
+ box-shadow: 0 0 0 3px #6690ff;
88
+ }
89
+
90
+ &:hover {
91
+ border: 1px solid #102693;
92
+ }
93
+ &:active {
94
+ border: 1px solid #102693;
95
+ }
96
+ &:disabled {
97
+ border: 1px solid #dadce3;
98
+ background: #f3f5f9;
99
+ color: #dadce3;
100
+ }
101
+
102
+ &.small {
103
+ min-height: 32px;
104
+ }
105
+
106
+ &.medium {
107
+ min-height: 40px;
108
+ }
109
+
110
+ &.large {
111
+ min-height: 48px;
112
+ font-size: 1rem;
113
+ }
114
+
115
+ &.success {
116
+ background: #e3f8cc;
117
+ border: 1px solid #19660a;
118
+ color: #19660a;
119
+ }
120
+
121
+ &.danger {
122
+ background: #fae0d2;
123
+ border: 1px solid #871821;
124
+ color: #871821;
125
+ }
126
+
127
+ &.error {
128
+ background: #fae0d2;
129
+ border: 1px solid #871821;
130
+ color: #871821;
131
+ }
132
+
133
+ &.has-start-icon {
134
+ padding-left: 40px;
135
+ }
136
+ &.has-end-icon {
137
+ padding-right: 40px;
138
+ }
139
+ `;
140
+
141
+ export const Helper = styled.div`
142
+ &.helper {
143
+ font-style: normal;
144
+ font-weight: 500;
145
+ font-size: 0.625rem;
146
+ line-height: 120%;
147
+ color: #5a5d68;
148
+ display: block;
149
+ margin-top: 4px;
150
+
151
+ &.success {
152
+ color: #19660a;
153
+ }
154
+
155
+ &.danger {
156
+ color: #871821;
157
+ }
158
+ }
159
+ `;
160
+
161
+ export const Error = styled.div`
162
+ font-style: normal;
163
+ font-weight: 500;
164
+ font-size: 0.625rem;
165
+ line-height: 120%;
166
+ display: block;
167
+ margin-top: 4px;
168
+ color: #871821;
169
+ `;
@@ -3,6 +3,7 @@ import { getLanguage } from '../../utils/getLanguage'
3
3
  import * as S from './styles';
4
4
  import Select from '../Select'
5
5
  import InputTest from './components/InputTest'
6
+ import TextArea from './components/TextArea'
6
7
  import { PiWaveformBold } from 'react-icons/pi';
7
8
  import { FaList } from 'react-icons/fa';
8
9
  import EmptyState from '../EmptyState';
@@ -12,11 +13,12 @@ import { useDispatch, useSelector } from 'react-redux';
12
13
  import { testAction } from '../../store/modules/actions';
13
14
 
14
15
  export const TestArea = () => {
15
- const { id, language, personas, propTags, token } = useSharedProps();
16
+ const { id, language, personas, propTags, token, env } = useSharedProps();
16
17
  const t = getLanguage(language)
17
18
  const results = useSelector((state: any) => state.message);
18
19
  const isloading = useSelector((state: any) => state.isloading);
19
20
  const [search, setSearch] = useState('');
21
+ const [prompt, setPrompt] = useState('');
20
22
  const [profile, setProfile] = useState('');
21
23
  const [presset, setPresset] = useState('');
22
24
  const dispatch = useDispatch();
@@ -43,8 +45,12 @@ export const TestArea = () => {
43
45
  setSearch(value);
44
46
  };
45
47
 
48
+ const handlePrompt = (value: string) => {
49
+ setPrompt(value);
50
+ };
51
+
46
52
  const handleTest = () => {
47
- dispatch(testAction(search, profile, presset, id, token))
53
+ dispatch(testAction(search, prompt, profile, presset, id, token, env))
48
54
  };
49
55
 
50
56
  const returnTest = () => {
@@ -60,6 +66,7 @@ export const TestArea = () => {
60
66
  <S.Inputs>
61
67
  <InputTest placeholder={t.testArea.typeSentence} onChange={handleSearch} />
62
68
  <Select placeholder={t.testArea.selectPersona} options={optionsPersona} onSelect={handleSelectPersona} />
69
+ {profile === "Custom" && <TextArea className="textarea-message" label="Prompt" placeholder={t.testArea.typePrompt} value={prompt} onChange={(e) => { handlePrompt(e.target.value); }} />}
63
70
  <Select placeholder={t.testArea.selectPresset} options={optionsPresset} onSelect={handleSelectPresset} />
64
71
  <button onClick={handleTest}><PiWaveformBold /> {t.buttons.test}</button>
65
72
  </S.Inputs>
@@ -83,7 +90,7 @@ export const TestArea = () => {
83
90
  }
84
91
 
85
92
  return (
86
- <SharedPropsProvider id={id} token={token} language={language} propTags={{ tags: [] }} personas={[{name: '', description: ''}]}>
93
+ <SharedPropsProvider id={id} token={token} language={language} env={env} propTags={{ tags: [] }} personas={[{name: '', description: ''}]}>
87
94
  <S.Container>
88
95
  {returnTest()}
89
96
  </S.Container>
@@ -7,6 +7,7 @@ interface Props {
7
7
  propTags: { tags: [] }
8
8
  personas: [{ name: string, description: string }];
9
9
  token: string;
10
+ env: string;
10
11
  children?: React.ReactNode;
11
12
  }
12
13
 
@@ -35,6 +35,7 @@ type Buttons = {
35
35
  type TestArea = {
36
36
  description: string;
37
37
  typeSentence: string;
38
+ typePrompt: string;
38
39
  selectPersona: string;
39
40
  selectPresset: string;
40
41
  emptyState: {
@@ -0,0 +1,9 @@
1
+ import axios from 'axios';
2
+
3
+ export const API_TOKEN = 'API_TOKEN';
4
+
5
+ const url = 'http://localhost:5000';
6
+
7
+ axios.defaults.baseURL = `${url}`;
8
+
9
+ export default axios.create();
@@ -1,9 +1,9 @@
1
1
  import types from './types'
2
2
 
3
- export const getFilesAction = (id: string, token: string) => {
3
+ export const getFilesAction = (id: string, token: string, env: string) => {
4
4
  return {
5
5
  type: types.GET_FILES_REQUEST,
6
- payload: { id, token }
6
+ payload: { id, token, env }
7
7
  }
8
8
  }
9
9
 
@@ -14,10 +14,10 @@ export const getFilesActionSuccess = ({ files }: any) => {
14
14
  }
15
15
  }
16
16
 
17
- export const deleteFilesAction = (name: string, id: string, language: string, token: string) => {
17
+ export const deleteFilesAction = (name: string, id: string, language: string, token: string, env: string) => {
18
18
  return {
19
19
  type: types.DELETE_FILES_REQUEST,
20
- payload: { name, id, language, token }
20
+ payload: { name, id, language, token, env }
21
21
  }
22
22
  }
23
23
 
@@ -28,10 +28,10 @@ export const deleteFilesActionSuccess = ({ files }: any) => {
28
28
  }
29
29
  }
30
30
 
31
- export const uploadFilesAction = (file: any, id: string, pressets: string[], language: string, token: string) => {
31
+ export const uploadFilesAction = (file: any, id: string, pressets: string[], language: string, token: string, env: string) => {
32
32
  return {
33
33
  type: types.UPLOAD_FILES_REQUEST,
34
- payload: { file, id, pressets, language, token }
34
+ payload: { file, id, pressets, language, token, env }
35
35
  }
36
36
  }
37
37
 
@@ -42,17 +42,17 @@ export const uploadFilesActionSuccess = ({ files }: any) => {
42
42
  }
43
43
  }
44
44
 
45
- export const trainingAction = (id: string, pressets: string[], language: string, token: string) => {
45
+ export const trainingAction = (id: string, pressets: string[], language: string, token: string, env: string) => {
46
46
  return {
47
47
  type: types.TRAINING_REQUEST,
48
- payload: { id, pressets, language, token }
48
+ payload: { id, pressets, language, token, env }
49
49
  }
50
50
  }
51
51
 
52
- export const testAction = (question: string, profile: string, presset: string, files_directory: string, token: string) => {
52
+ export const testAction = (question: string, prompt:string, profile: string, presset: string, files_directory: string, token: string, env: string) => {
53
53
  return {
54
54
  type: types.TEST_REQUEST,
55
- payload: { question, profile, presset, files_directory, token }
55
+ payload: { question, prompt, profile, presset, files_directory, token, env }
56
56
  }
57
57
  }
58
58