Allow stopping of inference

This commit is contained in:
2024-11-30 12:44:13 +01:00
parent a0353d0d49
commit e71bd7e9eb
15 changed files with 139 additions and 69 deletions

View File

@@ -159,6 +159,12 @@ const App = () => {
}
};
const handleStop = () => {
fetch(`/api/inference/${activeLlm}/stop`, {
method: 'POST'
});
};
const handleSendInput = () => {
if (input.trim()) {
fetch('/api/input', {
@@ -347,6 +353,7 @@ const App = () => {
output={output}
autoApproverConfig={autoApproverConfig}
onApprove={handleApprove}
onStop={handleStop}
onToggleDiff={() => setShowDiff(!showDiff)}
onSendInput={handleSendInput}
onClearOutput={handleClearOutput}

View File

@@ -16,6 +16,7 @@ export const Sidebar = ({
output,
autoApproverConfig,
onApprove,
onStop,
onToggleDiff,
onSendInput,
onClearOutput,
@@ -31,7 +32,6 @@ export const Sidebar = ({
${showSidebar ? 'translate-x-0' : 'translate-x-full md:translate-x-0'}
`}>
<div className="p-4 space-y-4 overflow-y-auto h-full">
{/* Existing controls */}
<Select value={activeLlm} onValueChange={onLlmChange}>
<SelectTrigger>
<SelectValue placeholder="Select LLM" />
@@ -62,14 +62,13 @@ export const Sidebar = ({
</div>
<Button
onClick={onApprove}
disabled={llmState === LlmState.INFERENCE}
onClick={llmState === LlmState.INFERENCE ? onStop : onApprove}
className="w-full"
>
{
llmState === LlmState.NO_OUTPUT ? 'Inference' :
llmState === LlmState.OUTPUT ? 'Approve' :
'In Progress'
llmState === LlmState.INFERENCE ? 'Stop' :
'Approve'
}
</Button>

View File

@@ -46,17 +46,24 @@ export const MemoryEditor = ({
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');
try {
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');
} catch (error) {
if (error instanceof DOMException) {
alert('Failed to read the file. Check permissions. chown -R $USER:$USER iteration');
} else {
throw error;
}
}
}
};
const handleLoadIterationClick = () => {
const input = document.createElement('input');
input.type = 'file';