Skip to content

Commit

Permalink
Add generate graph feature from data by llm (Part 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonchenghy committed Mar 31, 2024
1 parent 89df633 commit 41af1a7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
20 changes: 14 additions & 6 deletions frontend/src/GraphPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'reactflow/dist/style.css';
const GraphPage = () => {

const location = useLocation();
const { topic } = { topic: location.state.topic } || {topic: "",};
const topic = location.state?.topic || "Placeholder Topic";
const { educationLevel } = { educationLevel: location.state.educationLevel } || { educationLevel: "" };
const { focus } = { focus: location.state.focus } || { focus: "" };
const { levelOfDetail } = { levelOfDetail: location.state.levelOfDetail } || { levelOfDetail: "" };
Expand All @@ -41,11 +41,19 @@ const GraphPage = () => {
// }, []);


const initialNodes = titles.map((title, index) => {
console.log(index)
console.log(title);
return { id: index.toString(), position: { x: 300 * index, y: 100 }, data: { label: title } };
});
let idCounter = 1;

const initialNodes = [
{ id: '1', position: { x: 0, y: 0 }, data: { label: topic } },
...titles.map((title) => {
idCounter++;
return { id: idCounter.toString(), position: { x: 150 * idCounter, y: 100 }, data: { label: title } };
}),
...explaination.map((explanation) => {
idCounter++;
return { id: idCounter.toString(), position: { x: 150 * idCounter, y: 200 }, data: { label: explanation } };
})
];

const initialEdges = [{ id: 'e1-2', source: '1', target: '2' }];

Expand Down
8 changes: 5 additions & 3 deletions frontend/src/SubtopicPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const SubtopicPage = () => {

const [subtopics, setSubtopics] = useState([]);

const [focus, setFocus] = useState("");

const [educationLevel, setEducationLevel] = useState("");
const [levelOfDetail, setLevelOfDetail] = useState("");

Expand All @@ -35,9 +37,9 @@ const SubtopicPage = () => {
setEducationLevel(e.target.value);
};

// const handleFocusChange = (e) => {
// setFocus(e.target.value);
// };
const handleFocusChange = (e) => {
setFocus(e.target.value);
};

const handleLevelOfDetailChange = (e) => {
setLevelOfDetail(e.target.value);
Expand Down

0 comments on commit 41af1a7

Please sign in to comment.