Skip to content

Commit ce1a572

Browse files
only store config once (#182)
1 parent 08b3c4e commit ce1a572

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

app/admin/bots/routes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ async def set_config(name: str, config: Dict[str, Any]):
1313
"""
1414
Update bot config
1515
"""
16-
return await store.update_config(name, config)
16+
await store.update_config(name, config)
17+
return {"message": "Config updated successfully"}
1718

1819

1920
@router.get("/{name}/config")

app/bot/memory/memory_saver_mongo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ async def get(self, thread_id: Text) -> Optional[State]:
2323
{"_id": 0, "nlu": 0, "date": 0, "user_message": 0, "bot_message": 0},
2424
sort=[("$natural", -1)],
2525
)
26-
print(result)
2726
if result:
2827
return State.from_dict(result)
2928
return None

frontend/app/admin/settings/ml/page.tsx

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const MLSettingsPage: React.FC = () => {
88
confidence_threshold: 0.5
99
});
1010
const [isLoading, setIsLoading] = useState(true);
11+
const [localThreshold, setLocalThreshold] = useState<number>(0.5);
1112

1213
useEffect(() => {
1314
fetchConfig();
@@ -17,6 +18,7 @@ const MLSettingsPage: React.FC = () => {
1718
try {
1819
const data = await getConfig();
1920
setConfig(data);
21+
setLocalThreshold(data.confidence_threshold);
2022
} catch (error) {
2123
console.error('Error fetching config:', error);
2224
} finally {
@@ -27,7 +29,7 @@ const MLSettingsPage: React.FC = () => {
2729
const handleThresholdChange = async (value: number) => {
2830
try {
2931
setConfig(prev => ({ ...prev, confidence_threshold: value }));
30-
await updateConfig(config);
32+
await updateConfig({ ...config, confidence_threshold: value });
3133
} catch (error) {
3234
console.error('Error updating config:', error);
3335
}
@@ -53,7 +55,7 @@ const MLSettingsPage: React.FC = () => {
5355
<div className="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
5456
<div className="space-y-6">
5557
<div>
56-
<h2 className="text-lg font-medium text-gray-800 mb-4">Tune ML</h2>
58+
<h2 className="text-lg font-medium text-gray-800 mb-4">Intent Classification</h2>
5759
<div className="space-y-4">
5860
<div>
5961
<label className="block text-sm font-medium text-gray-700 mb-2">
@@ -65,12 +67,14 @@ const MLSettingsPage: React.FC = () => {
6567
min="0.1"
6668
max="1.0"
6769
step="0.05"
68-
value={config.confidence_threshold}
69-
onChange={(e) => handleThresholdChange(parseFloat(e.target.value))}
70+
value={localThreshold}
71+
onChange={(e) => setLocalThreshold(parseFloat(e.target.value))}
72+
onMouseUp={() => handleThresholdChange(localThreshold)}
73+
onTouchEnd={() => handleThresholdChange(localThreshold)}
7074
className="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-green-500"
7175
/>
7276
<span className="text-sm font-medium text-gray-900 min-w-[4rem]">
73-
{(config.confidence_threshold * 100).toFixed(0)}%
77+
{(localThreshold * 100).toFixed(0)}%
7478
</span>
7579
</div>
7680
<p className="mt-2 text-sm text-gray-500">
@@ -79,15 +83,6 @@ const MLSettingsPage: React.FC = () => {
7983
</div>
8084
</div>
8185
</div>
82-
83-
<div className="border-t border-gray-200 pt-6">
84-
<h3 className="text-sm font-medium text-gray-700 mb-2">About ML Settings</h3>
85-
<p className="text-sm text-gray-500">
86-
The confidence threshold determines how certain the model needs to be before matching an intent.
87-
A higher threshold means fewer false positives but might miss some valid intents.
88-
A lower threshold means more matches but might include some incorrect ones.
89-
</p>
90-
</div>
9186
</div>
9287
</div>
9388
</div>

0 commit comments

Comments
 (0)