Added iteration loading
This commit is contained in:
@@ -43,6 +43,28 @@ export const MemoryEditor = ({
|
||||
setShowCreateDialog(false);
|
||||
};
|
||||
|
||||
const handleLoadIteration = async (event) => {
|
||||
const file = event.target.files[0];
|
||||
if (file) {
|
||||
const content = await file.text();
|
||||
const response = await fetch('/api/memory/load_iteration', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ content: content })
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to load iteration');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleLoadIterationClick = () => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.accept = '.xml';
|
||||
input.onchange = handleLoadIteration;
|
||||
input.click();
|
||||
};
|
||||
|
||||
const generateId = () => {
|
||||
const now = new Date();
|
||||
return now.getFullYear() +
|
||||
@@ -160,10 +182,16 @@ export const MemoryEditor = ({
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
<div className="flex justify-end mb-4">
|
||||
<div className="flex justify-end mb-4 gap-2">
|
||||
<button
|
||||
onClick={() => setShowCreateDialog(true)}
|
||||
className="px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700"
|
||||
onClick={handleLoadIterationClick}
|
||||
className="px-4 py-2 text-sm font-medium bg-white hover:bg-gray-100 border border-gray-200 rounded-md"
|
||||
>
|
||||
Load Iteration
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setShowCreateDialog(true)}
|
||||
className="px-4 py-2 text-sm font-medium bg-white hover:bg-gray-100 border border-gray-200 rounded-md"
|
||||
>
|
||||
Add Entry
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user