Skip to content

Commit

Permalink
clear AutoGenAnalysis result when new session created. (#93)
Browse files Browse the repository at this point in the history
* clear AutoGenAnalysis result when new session created

* comment fix

* comment fix

* comment fix
  • Loading branch information
colinlaoaa authored Nov 2, 2023
1 parent 3620dc9 commit 2fb7c1e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
14 changes: 12 additions & 2 deletions solidportal/panel/src/components/UserInputView.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ const UserInputView = ({ showView,
setGetAutoGenStatusCall,
setSaveSetAutoGenTaskId,
getAutoGenTaskId,
getAutoGenResult,
setIsFinal,
setSaveOpenAIKey,
setSaveUserRequirement,
setSaveProductInfo,
setSaveSelectedGraphType
setSaveSelectedGraphType,
autoGenStatus,
setIsAutoGenNewSession,
isAutoGenNewSession
}) => {
const [selectedGraphType, setSelectedGraphType] = useState(GraphType.OnboardProject);
const [openAIKey, setOpenAIKey] = useState("");
Expand All @@ -31,7 +36,7 @@ const UserInputView = ({ showView,
const [productInfo, setProductInfo] = useState("");
const pollingInterval = 5000;
const [uploadStatus, setUploadStatus] = useState(false)
const [isAutoGenNewSession, setIsAutoGenNewSession] = useState(true)


const disableStart = useRef(true)
const userRequirementRef = useRef("")
Expand Down Expand Up @@ -98,6 +103,7 @@ const UserInputView = ({ showView,
}
}, [uploadStatus, pollingInterval]);


const handleGraphTypeSelectChange = (e) => {
setSelectedGraphType(e.target.value);
setSaveSelectedGraphType(e.target.value);
Expand Down Expand Up @@ -364,6 +370,9 @@ const UserInputView = ({ showView,
}

const AutoGenAnalysis = async ( requirement ) => {
if(requirement.toLowerCase().replace(/\s/g, '') === "confirm"){
requirement = ""
}
disableStart.current = true
const requestBody = JSON.stringify({
openai_key: openAIKey,
Expand All @@ -383,6 +392,7 @@ const UserInputView = ({ showView,
setSaveSetAutoGenTaskId(response.data.task_id)
setIsAutoGenNewSession(false)
setGetAutoGenStatusCall(true)
getAutoGenResult.current = ""
} else if (response.data.status === 2) {
setIsAutoGenNewSession(true)
} else if (response.data.status === 3) {
Expand Down
21 changes: 16 additions & 5 deletions solidportal/panel/src/pages/SolidPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const SolidPortal = () => {
const [status, setStatus] = useState(false)
const [autoGenStatus, setAutoGenStatus] = useState(false)
const [autoGenTaskId, setAutoGenTaskId] = useState(null)
const [isAutoGenNewSession, setIsAutoGenNewSession] = useState(true)
let state_id = useRef("");
let autoGenResult = useRef("");
const [showTermsCondition, setShowTermsCondition] = useState(false)
Expand Down Expand Up @@ -73,8 +74,12 @@ const SolidPortal = () => {
setIsFinal(boolean)
}

const saveIsAutoGenNewSession = (boolean) => {
setIsAutoGenNewSession(boolean)
}

const userInputView = (
<UserInputView
<UserInputView
showView={!showTermsCondition && showLeftPanel}
setCurrentRunningSubgraphName={saveCurrentRunningSubgraphName}
setTotalSubgraph={saveSetTotalSubgraph}
Expand All @@ -84,15 +89,18 @@ const SolidPortal = () => {
setGetAutoGenStatusCall={saveGetAutoGenStatusCall}
setSaveSetAutoGenTaskId={saveSetAutoGenTaskId}
getAutoGenTaskId={autoGenTaskId}
getAutoGenResult={autoGenResult}
setIsFinal={saveIsFinal}
setSaveOpenAIKey={saveOpenAIKey}
setSaveUserRequirement={saveUserRequirement}
setSaveProductInfo={saveProductInfo}
setSaveSelectedGraphType={saveSelectedGraphType}
autoGenStatus={autoGenStatus}
setIsAutoGenNewSession={saveIsAutoGenNewSession}
isAutoGenNewSession={isAutoGenNewSession}
/>
);


// const [autoGenActivePlannerState, setAutoGenActivePlannerState] = useState(AutoGenActivePlannerState.Disable);
// const activeAutoGenPlanner = async () => {
Expand Down Expand Up @@ -195,7 +203,10 @@ const SolidPortal = () => {
console.log(response.data)
if (response.data.status === 1 || response.data.status === 2){
setMdEditorValue(response.data.message)
setAutoGenStatus(false)
setAutoGenStatus(false)
if (response.data.status === 2) {
setIsAutoGenNewSession(true)
}
}else if(response.data.status === 3){
console.log(response.data.result)
if (state_id.current !== response.data.result.state_id){
Expand All @@ -204,7 +215,7 @@ const SolidPortal = () => {
setMdEditorValue(autoGenResult.current)
setAutoGenStatus(false)
// check current planner status
// await activeAutoGenPlanner()
// await activeAutoGenPlanner()
}
state_id.current = response.data.result.state_id;
}
Expand Down Expand Up @@ -308,7 +319,7 @@ const SolidPortal = () => {
// if (response.data.status === 1) {
// setAutoGenTaskId(response.data.task_id)
// saveGetAutoGenStatusCall(true)
// }
// }
// else if (response.data.status === 3) {
// setAutoGenTaskId(response.data.task_id)
// saveGetAutoGenStatusCall(true)
Expand Down

0 comments on commit 2fb7c1e

Please sign in to comment.