code7-leia 0.2.18 → 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.
@@ -1,5 +1,6 @@
1
1
  import { takeLatest, all, put, call } from 'redux-saga/effects';
2
2
  import api from '../../service/Api'
3
+ import apiHml from '../../service/ApiHml'
3
4
  import Types from './types'
4
5
  import { getFilesActionSuccess,
5
6
  deleteFilesActionSuccess,
@@ -13,8 +14,8 @@ import { getLanguage } from '../../utils/getLanguage'
13
14
  export function* getFilesSaga(action: any) {
14
15
  try {
15
16
  yield put(commonLoadingStart());
16
- const { id, token } = action.payload
17
- const { data } = yield call(api.get, `/training/${id}?token=${token}`);
17
+ const { id, token, env } = action.payload
18
+ const { data } = yield call(env.toLowerCase() === 'prod' ? api.get : apiHml.get, `/training/${id}?token=${token}`);
18
19
  yield put(getFilesActionSuccess({ files: data.files}));
19
20
  } catch (error) {
20
21
  console.log('-----------getFiles.error------------------->', error);
@@ -27,10 +28,10 @@ export function* deleteFilesSaga(action: any) {
27
28
  const t = getLanguage(action.payload.language)
28
29
  try {
29
30
  yield put(commonLoadingStart());
30
- const { id, name, token } = action.payload
31
+ const { id, name, token, env } = action.payload
31
32
 
32
- yield call(api.delete, `/delete/${id}/${name}?token=${token}`);
33
- const { data } = yield call(api.get, `/training/${id}?token=${token}`);
33
+ yield call(env.toLowerCase() === 'prod' ? api.delete : apiHml.delete, `/delete/${id}/${name}?token=${token}`);
34
+ const { data } = yield call(env.toLowerCase() === 'prod' ? api.get : apiHml.get, `/training/${id}?token=${token}`);
34
35
  yield put(deleteFilesActionSuccess({ files: data.files, success: true }));
35
36
  } catch (error) {
36
37
  toast.error({title: t.toast.deleteFile.fail.title, description: t.toast.deleteFile.fail.description});
@@ -43,8 +44,8 @@ export function* deleteFilesSaga(action: any) {
43
44
  export function* testSaga(action: any) {
44
45
  try {
45
46
  yield put(commonLoadingStart());
46
- const { question, profile, presset, files_directory, token } = action.payload
47
- const { data } = yield call(api.post, `/ask`, { question, profile, tag: presset, files_directory, token });
47
+ const { question, prompt, profile, presset, files_directory, token, env } = action.payload
48
+ const { data } = yield call(env.toLowerCase() === 'prod' ? api.post : apiHml.post, `/ask`, { question, description: prompt, profile, tag: presset, files_directory, token });
48
49
  yield put(testActionSuccess({ message: data.message }));
49
50
  } catch (error) {
50
51
  console.log('-----------testSaga.error------------------->', error);
@@ -57,15 +58,12 @@ export function* uploadFilesSaga(action: any) {
57
58
  const t = getLanguage(action.payload.language);
58
59
  try {
59
60
  yield put(commonLoadingStart());
60
- const { id, file, pressets, token } = action.payload;
61
+ const { id, file, pressets, token, env } = action.payload;
61
62
 
62
63
  const blob = new Blob([file.content]);
63
64
  const formData = new FormData();
64
- const sanitizedPath = file.properties.path.replace(/^(\.\/|\/+)|\/+$/g, '');
65
- console.log('sanitizedPath: ', sanitizedPath)
65
+ const sanitizedPath = file.properties.path.replace(/^\/+|\/+$/g, '');
66
66
  formData.append('file', blob, sanitizedPath || 'default_filename');
67
- console.log('formData: ', formData)
68
- console.log('file: ', file)
69
67
 
70
68
  const queryParams = pressets.length
71
69
  ? new URLSearchParams({ tags: pressets.join(',') }).toString()
@@ -75,13 +73,13 @@ export function* uploadFilesSaga(action: any) {
75
73
  ? `/upload/${id}?token=${token}&${queryParams}`
76
74
  : `/upload/${id}?token=${token}`;
77
75
 
78
- yield call(api.post, url, formData, {
76
+ yield call(env.toLowerCase() === 'prod' ? api.post : apiHml.post, url, formData, {
79
77
  headers: {
80
78
  'Content-Type': 'multipart/form-data',
81
79
  },
82
80
  });
83
81
 
84
- const { data } = yield call(api.get, `/training/${id}?token=${token}`);
82
+ const { data } = yield call(env.toLowerCase() === 'prod' ? api.get : apiHml.get, `/training/${id}?token=${token}`);
85
83
  yield put(uploadFilesActionSuccess({ files: data.files }));
86
84
  } catch (error) {
87
85
  toast.error({
@@ -99,14 +97,14 @@ export function* TrainingSaga(action: any) {
99
97
  const t = getLanguage(action.payload.language)
100
98
  try {
101
99
  yield put(commonLoadingStart());
102
- const { id, pressets, token } = action.payload;
100
+ const { id, pressets, token, env } = action.payload;
103
101
  const tag = pressets.join(',');
104
102
 
105
103
  const queryParams = new URLSearchParams({ tag }).toString();
106
104
 
107
- yield call(api.post, pressets.length > 0 ? `/training?${queryParams}` : `/training`,{ files_directory: id, token });
105
+ yield call(env.toLowerCase() === 'prod' ? api.post : apiHml.post, pressets.length > 0 ? `/training?${queryParams}` : `/training`,{ files_directory: id, token });
108
106
 
109
- const { data } = yield call(api.get, `/training/${id}?token=${token}`);
107
+ const { data } = yield call(env.toLowerCase() === 'prod' ? api.get : apiHml.get, `/training/${id}?token=${token}`);
110
108
  yield put(uploadFilesActionSuccess({ files: data.files }));
111
109
  toast.success({title: t.toast.Train.success.title, description: t.toast.Train.success.description});
112
110
  } catch (error) {
@@ -38,6 +38,7 @@ export const enTranslation: Language = {
38
38
  testArea: {
39
39
  description: 'Type a sentence to test artificial intelligence',
40
40
  typeSentence: 'Type a sentence',
41
+ typePrompt: 'Insert a custom prompt here',
41
42
  selectPersona: 'Select a Persona',
42
43
  selectPresset: 'Select a presset',
43
44
  emptyState: {
@@ -38,6 +38,7 @@ export const esTranslation: Language = {
38
38
  testArea: {
39
39
  description: 'Escribe una frase para probar la inteligencia artificial.',
40
40
  typeSentence: 'Escribe una oración',
41
+ typePrompt: 'Inserte un prompt personalizado aquí',
41
42
  selectPersona: 'Seleccionar una Persona',
42
43
  selectPresset: 'Seleccionar una preconfiguración',
43
44
  emptyState: {
@@ -38,6 +38,7 @@ export const ptTranslation: Language = {
38
38
  testArea: {
39
39
  description: 'Digite uma frase para testar a inteligência artificial.',
40
40
  typeSentence: 'Digite uma frase',
41
+ typePrompt: 'Insira aqui um prompt personalizado',
41
42
  selectPersona: 'Selecione uma Persona',
42
43
  selectPresset: 'Selecione uma predefinição',
43
44
  emptyState: {