Skip to content

Commit

Permalink
fix: fix issue 61 CloudOrc#61
Browse files Browse the repository at this point in the history
  • Loading branch information
nutsjian committed Jul 30, 2023
1 parent cb62b71 commit 5665a69
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 27 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ __pycache__
soliduimodelui.egg-info
workspace
kernel_connection_file.json
app.log
app.log
process_pids
build
soliduimodelui/kernel.log
soliduimodelui/web.log
4 changes: 4 additions & 0 deletions solidui-web/config/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
const productionVariable = [
{ name: "NODE_ENV", default: "production" },
{ name: "BASE_ENV", default: "" },
{ name: "APP_NAME", default: "SolidUI" },
{ name: "APP_VERSION", default: "0.2.0" },
]
const developmentVariable = [
{ name: "NODE_ENV", default: "development" },
{ name: "BASE_ENV", default: "" },
{ name: "PROXY_SERVER", default: "http://localhost:12345" },
{ name: "SERVER_PORT", default: 3000 },
{ name: "APP_NAME", default: "SolidUI" },
{ name: "APP_VERSION", default: "0.2.0" },
]

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion solidui-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@
"react-window": "1.8.9",
"scenejs": "1.9.4"
}
}
}
30 changes: 15 additions & 15 deletions solidui-web/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@ function main(envMode, config) {
// run serve
webpackServe(compiler, webpackConfig, envMode, config)
} else {
// run build
// run build
webpackBuild(compiler, webpackConfig, envMode, config)
}
}

/**
* log env file
* @param {*} envMode
* @returns
* @param {*} envMode
* @returns
*/
function loadEnvFile(envMode) {
const envFile = envConfig[envMode].envFile;
const needVariable = envConfig[envMode].needVariable;
// load
dotenv.config({ path: envFile, processEnv: process.env })
if (!checkFileExist([envFile]).status) Logger.logWarn(envFile + " does not exist, will Use default value")
if (!checkFileExist([envFile]).status) Logger.logWarn(envFile + " does not exist, will Use default value, more info please see https://github.com/CloudOrc/SolidUI/blob/dev/solidui-web/README.md")
function generateDefaultValue() {
const envDefault = {}
for (let i = 0; i < needVariable.length; i++) {
Expand Down Expand Up @@ -123,8 +123,8 @@ function preCheck() {

/**
* get webpack config
* @param {*} envMode
* @returns
* @param {*} envMode
* @returns
*/
function getWebpackConfig(envMode, config) {
let webpackConfigFile = envConfig[envMode].webpackConfigFile
Expand All @@ -137,17 +137,17 @@ function getWebpackConfig(envMode, config) {
}
/**
* Compiler create
* @param {*} webpackConfig
* @returns
* @param {*} webpackConfig
* @returns
*/
function createCompiler(webpackConfig) {
return webpack(webpackConfig)
}
/**
* serve
* @param {*} webpackConfig
* @param {*} envMode
* @param {*} config
* @param {*} webpackConfig
* @param {*} envMode
* @param {*} config
*/
function webpackServe(compiler, webpackConfig) {
const devServer = new WebpackDevServer(webpackConfig.devServer, compiler);
Expand Down Expand Up @@ -190,9 +190,9 @@ function webpackServe(compiler, webpackConfig) {
}
/**
* build
* @param {*} webpackConfig
* @param {*} envMode
* @param {*} config
* @param {*} webpackConfig
* @param {*} envMode
* @param {*} config
*/
function webpackBuild(compiler, webpackConfig) {
compiler.run((err, stats) => {
Expand Down Expand Up @@ -251,4 +251,4 @@ function webpackBuild(compiler, webpackConfig) {
}
});
})
}
}
3 changes: 2 additions & 1 deletion solidui-web/src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ const datasource = {
};

const modelui = {
keys: <T>() => ApiService.get<T>("/solidui/models/keys"),
// keys: <T>() => ApiService.get<T>("/solidui/models/keys"),
keys: <T>() => ApiService.get<T>("/solidui/keys/list"),
generate: <T>(params: { modelId: number; prompt: string }) =>
ApiService.post<T>(`/solidui/models/generate`, params),
generateByCommand: <T>(params: { command: string }) =>
Expand Down
8 changes: 6 additions & 2 deletions solidui-web/src/layouts/DefaultLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export default function DefaultLayout() {
setSelectKeys([key]);
navigate(key);
}
const vars: Record<string, any> = {};
Object.keys(process.env).forEach((key) => {
vars[key] = process.env[key];
});

return (
<div className="solidui-layout default">
Expand All @@ -90,8 +94,8 @@ export default function DefaultLayout() {
}}
>
<div className="logo" />
<div className="logo-text">{process.env.APP_NAME}</div>
<div className="version">v{process.env.APP_VERSION}</div>
<div className="logo-text">{vars.APP_NAME}</div>
<div className="version">v{vars.APP_VERSION}</div>
</div>
<div
className="header-right"
Expand Down
10 changes: 8 additions & 2 deletions solidui-web/src/pages/Designer/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,21 @@ function Header() {
}
}, [searchParams]);

const vars: Record<string, any> = {};
Object.keys(process.env).forEach((key) => {
vars[key] = process.env[key];
});

return (
<header className="header">
<div className="header-main">
<div className="header-left">
<div className="logo" onClick={renderHome} />
<div className="logo-text" onClick={renderHome}>
SolidUI
{/* SolidUI */}
{vars.APP_NAME || "SolidUI"}
</div>
<div className="version">v0.1.0</div>
<div className="version">v{vars.APP_VERSION || "0.2.0"}</div>
<div className="split-line" />
<div className="left-main">
<span style={{ marginLeft: "10px" }}>{title}</span>
Expand Down
29 changes: 24 additions & 5 deletions solidui-web/src/pages/Designer/Properties/modelui/useModelui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ function useModelui() {
const [promptInput, setPromptInput] = useState<string>("");
const [messages, setMessages] = useState<Array<MessageDict>>(
Array.from([
{
text: "Hello! I'm a GPT Code assistant. Ask me to do something for you! Pro tip: you can upload a file and I'll be able to use it.",
role: "system",
type: "message",
},
// {
// text: "Hello! I'm a GPT Code assistant. Ask me to do something for you! Pro tip: you can upload a file and I'll be able to use it.",
// role: "system",
// type: "message",
// },
]),
);
const [waitingForSystem, setWaitingForSystem] = useState<WaitingStates>(
Expand All @@ -58,6 +58,13 @@ function useModelui() {
if (mModels[0] && mModels[0].value) {
selectedModelIdRef.current = mModels[0].value;
}
addMessage({
text: `Hello! I'm a ${
mModels[0].label || "GPT"
} Code assistant. Ask me to do something for you! Pro tip: you can upload a file and I'll be able to use it.`,
role: "system",
type: "message",
});
setModels(mModels);
}
});
Expand Down Expand Up @@ -164,6 +171,18 @@ function useModelui() {

function handleModelChange(value: any) {
selectedModelIdRef.current = value;

const mModels = models.filter((model) => model.value === value);

if (mModels !== null && mModels !== undefined) {
addMessage({
text: `Hello! I'm a ${
mModels[0].label || "GPT"
} Code assistant. Ask me to do something for you! Pro tip: you can upload a file and I'll be able to use it.`,
role: "system",
type: "message",
});
}
}

function handlePromptInputChange(value: string) {
Expand Down

0 comments on commit 5665a69

Please sign in to comment.