Skip to content

Commit

Permalink
fix: bug (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
mizy authored Dec 4, 2023
1 parent 2ae285f commit 039e5f0
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 12 deletions.
8 changes: 4 additions & 4 deletions app/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@
}
}

.ant-btn-default {
border: 1px solid @blue;
border-radius: 3px;
color: @blue;
svg {
:focus {
outline: none;
}
}
2 changes: 2 additions & 0 deletions app/config/locale/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default {
language: 'Language',
switchOn: 'On',
switchOff: 'Off',
succcess: 'Success',
},
doc: {
welcome: 'Welcome to',
Expand Down Expand Up @@ -562,5 +563,6 @@ export default {
previous: 'Previous',
start: 'Start',
aiImport: 'AI Import',
pleaseConfigLLMFirst: 'Please configure LLM API first',
},
};
1 change: 1 addition & 0 deletions app/config/locale/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default {
language: '语言',
switchOn: '开启',
switchOff: '关闭',
pleaseConfigLLMFirst: '请先配置 LLM 接口地址',
},
doc: {
welcome: '欢迎使用',
Expand Down
2 changes: 2 additions & 0 deletions app/pages/Console/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import SchemaDrawer from './Drawer/SchemaDrawer';
// import NgqlDrawer from './Drawer/NgqlDrawer';
import styles from './index.module.less';
import { SchemaItemOverview } from '@app/stores/console';
import LLMBot from '../LLMBot';

const Option = Select.Option;

Expand Down Expand Up @@ -323,6 +324,7 @@ const Console = (props: IProps) => {
onExplorer={handleExplorer}
/>
)}
<LLMBot />
</div>
);
};
Expand Down
1 change: 1 addition & 0 deletions app/pages/Import/AIImport/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const Create = observer((props: { visible: boolean; onCancel: () => void }) => {
type: 'file',
promptTemplate: llmImportPrompt,
});
setTokens(null);
}, [props.visible]);

const onNext = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const FileSelect = observer((props: IFileSelect) => {
const getLocalFiles = useCallback(async () => {
const files = await getFiles();
setState({
directory: files,
// filter csv file
directory: files.filter((file) => file.name.endsWith('.csv')),
path: '/',
loading: false,
activeId: IDatasourceType.Local,
Expand Down
8 changes: 8 additions & 0 deletions app/pages/Import/TaskList/index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
padding: 15px 0 20px;
display: flex;

:global {
.ant-btn-default {
border: 1px solid @blue;
border-radius: 3px;
color: @blue;
}
}

&>button:not(:last-child) {
margin-right: 15px;
}
Expand Down
13 changes: 10 additions & 3 deletions app/pages/Import/TaskList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Option = Select.Option;

const TaskList = () => {
const timer = useRef<any>(null);
const { dataImport, global, moduleConfiguration, schema } = useStore();
const { dataImport, global, moduleConfiguration, schema, llm } = useStore();
const { spaces, getSpaces } = schema;
const isMounted = useRef(true);
const [filter, setFilter] = useState({ page: 1, pageSize: 10, space: undefined });
Expand Down Expand Up @@ -69,6 +69,13 @@ const TaskList = () => {
clearTimeout(timer.current);
getData();
};
const onCreateAIIMport = () => {
if (llm.config.gqlPath) {
setAiImportModalVisible(true);
} else {
message.error(intl.get('llm.pleaseConfigLLMFirst'));
}
};
useEffect(() => {
getSpaces();
initList();
Expand Down Expand Up @@ -123,8 +130,8 @@ const TaskList = () => {
{intl.get('import.uploadTemp')}
</Button>
)}
{global.appSetting.beta.functions.llmImport && (
<Button className="studioAddBtn" onClick={() => setAiImportModalVisible(true)}>
{global.appSetting.beta.open && global.appSetting.beta.functions.llmImport.open && (
<Button className="studioAddBtn" onClick={onCreateAIIMport}>
<Icon className="studioAddBtnIcon" type="icon-studio-btn-add" />
{intl.get('llm.aiImport')}
<span className={styles.beta}>beta</span>
Expand Down
1 change: 1 addition & 0 deletions app/pages/LLMBot/chat.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

.codeWrapper {
position: relative;
min-width: 360px;

:global {
.CodeMirror {
Expand Down
2 changes: 1 addition & 1 deletion app/pages/LLMBot/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useStore } from '@app/stores';
// float llm bot window
function LLMBot() {
const { global, llm } = useStore();
if (global.appSetting?.beta?.functions?.text2query.open != true) {
if (global.appSetting?.beta?.open && global.appSetting?.beta?.functions?.text2query.open != true) {
return null;
}
const { open } = llm;
Expand Down
2 changes: 0 additions & 2 deletions app/pages/MainPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Redirect, Route, Switch } from 'react-router-dom';
import { shouldAlwaysShowWelcome } from '@app/pages/Welcome';
import ErrorBoundary from '@app/components/ErrorBoundary';
import { MENU_LIST, RoutesList } from './routes';
import LLMBot from '../LLMBot';
import './index.less';

import Header from './Header';
Expand Down Expand Up @@ -36,7 +35,6 @@ const MainPage = () => {
<Redirect from="/" to={{ pathname: redirectPath, search: location.search }} />
</Switch>
</ErrorBoundary>
<LLMBot />
</Layout>
);
};
Expand Down
2 changes: 1 addition & 1 deletion app/pages/Schema/SchemaConfig/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const SchemaConfig = () => {
const { schema, global } = useStore();
const { spaces, getSpaces, switchSpace, currentSpace } = schema;
const { currentLocale } = useI18n();
const showViewSchemaBetaFunc = global.appSetting.beta.functions.viewSchema.open;
const showViewSchemaBetaFunc = global.appSetting.beta.open && global.appSetting.beta.functions.viewSchema.open;
const spaceInUrl = useMemo(() => {
const params = new URLSearchParams(location.search);
return params.get('space');
Expand Down
29 changes: 29 additions & 0 deletions server/api/studio/internal/service/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -279,6 +281,33 @@ func (i *importService) DownloadLogs(req *types.DownloadLogsRequest) error {
return ecode.WithInternalServer(fmt.Errorf("unset KeepResponse Writer"))
}

task := db.TaskInfo{
BID: id,
}
if err := db.CtxDB.Where(task).First(&task).Error; err != nil {
return ecode.WithErrorMessage(ecode.ErrInternalDatabase, err)
}
if task.LLMJobID != 0 {
llmJob := db.LLMJob{
ID: task.LLMJobID,
}
if err := db.CtxDB.Where(llmJob).First(&llmJob).Error; err != nil {
return ecode.WithErrorMessage(ecode.ErrInternalDatabase, err)
}
filePath := filepath.Join(studioConfig.GetConfig().LLM.GQLPath, fmt.Sprintf("%s/%s", llmJob.JobID, req.Name))
httpResp.WriteHeader(http.StatusOK)
httpResp.Header().Set("Content-Type", "application/octet-stream")
httpResp.Header().Set("Content-Disposition", "attachment;filename="+req.Name)
// download log
file, err := os.Open(filePath)
if err != nil {
return ecode.WithInternalServer(err)
}
defer file.Close()
io.Copy(httpResp, file)
return nil
}

fileName := req.Name
var taskEffect db.TaskEffect
if err := db.CtxDB.Select("log").Where("task_id = ?", id).First(&taskEffect).Error; err != nil {
Expand Down

0 comments on commit 039e5f0

Please sign in to comment.