Skip to content

Commit fc883b0

Browse files
UPDATE UI + groq AI
1 parent 50ce52d commit fc883b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1686
-31784
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ npm-debug.log*
1111
yarn-debug.log*
1212
yarn-error.log*
1313

14-
#playwright
15-
.env

assets/index-BftVdWSb.js

Lines changed: 314 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/index-BkC6B-km.js

Lines changed: 329 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/index-Dy5KTA2O.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/index-J5HNR8zq.js

Lines changed: 329 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/database/career_advisor.db

20 KB
Binary file not shown.

backend/services/llmScorer.js

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,29 +111,70 @@ function safeParseChatReply(content) {
111111
if (!content) return null;
112112
const text = String(content).trim();
113113
const candidates = [];
114-
try {
115-
candidates.push(JSON.parse(text));
116-
} catch { }
117114

118-
const match = text.match(/\{[\s\S]*\}/);
119-
if (match) {
115+
const tryParseJson = (value) => {
116+
if (!value) return null;
120117
try {
121-
candidates.push(JSON.parse(match[0]));
122-
} catch { }
123-
}
118+
return JSON.parse(value);
119+
} catch {
120+
return null;
121+
}
122+
};
123+
124+
const extractFromFence = (value) => {
125+
const fence = value.match(/```(?:json)?\s*([\s\S]*?)```/i);
126+
if (!fence) return null;
127+
return tryParseJson(fence[1].trim());
128+
};
129+
130+
const extractFirstJsonObject = (value) => {
131+
let start = -1;
132+
let depth = 0;
133+
for (let i = 0; i < value.length; i += 1) {
134+
const ch = value[i];
135+
if (ch === '{') {
136+
if (depth === 0) start = i;
137+
depth += 1;
138+
} else if (ch === '}') {
139+
if (depth > 0) depth -= 1;
140+
if (depth === 0 && start !== -1) {
141+
const slice = value.slice(start, i + 1);
142+
const parsed = tryParseJson(slice);
143+
if (parsed) return parsed;
144+
start = -1;
145+
}
146+
}
147+
}
148+
return null;
149+
};
150+
151+
const parsedFull = tryParseJson(text);
152+
if (parsedFull) candidates.push(parsedFull);
153+
154+
const parsedFence = extractFromFence(text);
155+
if (parsedFence) candidates.push(parsedFence);
156+
157+
const parsedObject = extractFirstJsonObject(text);
158+
if (parsedObject) candidates.push(parsedObject);
124159

125160
for (const obj of candidates) {
126161
if (!obj || typeof obj !== 'object') continue;
127162
let bot = String(obj.bot_reply || '').trim();
128163
if (!bot) continue;
129164

130-
// Nếu model trả về chuỗi template mặc định, ta cố gắng lấy nó làm nội dung
165+
// Nếu model trả về chuỗi template mặc định, bỏ qua đối tượng này
131166
if (bot.toLowerCase().includes('nội dung phản hồi')) continue;
132167
if (!Array.isArray(obj.suggested_questions)) {
133168
obj.suggested_questions = [];
134169
}
135170
return obj;
136171
}
172+
173+
// Fallback: dùng raw text như phản hồi để tránh null
174+
if (text && !text.toLowerCase().includes('nội dung phản hồi')) {
175+
return { bot_reply: text, suggested_questions: [] };
176+
}
177+
137178
return null;
138179
}
139180

frontend/dist/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
}(window.location));
1717
</script>
1818
<script src="./runtime-config.js"></script>
19-
<script type="module" crossorigin src="./assets/index-DYVZpLk5.js"></script>
20-
<link rel="stylesheet" crossorigin href="./assets/index-B-t5DAid.css">
19+
<script type="module" crossorigin src="./assets/index-J5HNR8zq.js"></script>
20+
<link rel="stylesheet" crossorigin href="./assets/index-Dy5KTA2O.css">
2121
</head>
2222
<body>
2323
<div id="root"></div>

frontend/node_modules/.package-lock.json

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/node_modules/.vite/deps/_metadata.json

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)