Skip to content

Commit

Permalink
fix: issues (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
mizy committed Jan 22, 2024
1 parent 9c9bda4 commit 067ead7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
5 changes: 4 additions & 1 deletion app/components/ColorPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ interface IProps {

const ColorPicker: React.FC<IProps> = (props: IProps) => {
const { onChange, onChangeComplete } = props;
const handleChange = color => {
const handleChange = (color) => {
if (onChange) {
onChange(color);
}
};

const handleChangeComplete = (color, _event) => {
if (onChangeComplete) {
if (_event.target.value && _event.target.value.length === 3) {
return;
}
onChangeComplete(color);
}
};
Expand Down
5 changes: 4 additions & 1 deletion app/components/FileConfigSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ const FileConfigSetting = (props: IProps) => {
const readFile = useCallback(
debounce(() => {
const { activeItem, setState } = state;
if (!activeItem || !(activeItem.name.indexOf('.csv') > -1)) return;
if (!activeItem || !(activeItem.name.indexOf('.csv') > -1)) {
setState({ previewContent: [] });
return;
}
setState({ loading: true });
let content = [];
if (activeItem.sample !== undefined) {
Expand Down
6 changes: 5 additions & 1 deletion app/pages/MainPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Suspense } from 'react';
import { Suspense, useEffect } from 'react';
import { Layout, Spin } from 'antd';
import { Redirect, Route, Switch } from 'react-router-dom';
import { shouldAlwaysShowWelcome } from '@app/pages/Welcome';
Expand All @@ -7,10 +7,14 @@ import { MENU_LIST, RoutesList } from './routes';
import './index.less';

import Header from './Header';
import llm from '@app/stores/llm';
const { Content } = Layout;

const MainPage = () => {
const redirectPath = shouldAlwaysShowWelcome() ? '/welcome' : '/console';
useEffect(() => {
llm.fetchConfig();
}, []);
return (
<Layout className="nebulaStudioLayout">
<Header menus={MENU_LIST} />
Expand Down
4 changes: 2 additions & 2 deletions app/stores/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ class LLM {
open = false;
config = {
maxContextLength: 2000,
url: 'https://{your-resource-name}.openai.azure.com/openai/deployments/{deployment-id}/chat/completions?api-version={api-version}',
url: 'https://api.openai.com/v1/chat/completions',
apiType: 'openai',
model: 'gpt-3.5-turbo',
features: ['spaceSchema', 'useConsoleNGQL'],
} as LLMConfig;
widget: HTMLSpanElement;
Expand All @@ -96,7 +97,6 @@ class LLM {
editor: false,
widget: false,
});
this.fetchConfig();
}

fetchConfig() {
Expand Down
8 changes: 4 additions & 4 deletions server/api/studio/pkg/llm/importjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ func (i *ImportJob) ParseText(text string) {
}

func (i *ImportJob) GetPrompt(text string) string {
promptTemplate := config.GetConfig().LLM.PromptTemplate
i.Prompt = strings.ReplaceAll(promptTemplate, "{userPrompt}", i.LLMJob.UserPrompt)
i.Prompt = strings.ReplaceAll(promptTemplate, "{spaceSchema}", i.SpaceSchemaString)
i.Prompt = config.GetConfig().LLM.PromptTemplate
i.Prompt = strings.ReplaceAll(i.Prompt, "{userPrompt}", i.LLMJob.UserPrompt)
i.Prompt = strings.ReplaceAll(i.Prompt, "{spaceSchema}", i.SpaceSchemaString)
i.Prompt = strings.ReplaceAll(i.Prompt, "{text}", text)
return i.Prompt
}
Expand All @@ -396,7 +396,7 @@ func (i *ImportJob) QueryBlocks(blocks []string) error {
break
}
if IsRunningJobStopped(job.JobID) {
return nil
return fmt.Errorf("job stopped")
}
prompt := i.GetPrompt(block)
text, err := i.Query(prompt)
Expand Down

0 comments on commit 067ead7

Please sign in to comment.