Add Event Bus (#184)

Major internal refactor to use an event bus to pass event/messages along. These changes are largely invisible user facing but sets up internal design for real time stats and information.

- `--watch-config` logic refactored for events
- remove multiple SSE api endpoints, replaced with /api/events
- keep all functionality essentially the same
- UI/backend sync is in near real time now
This commit is contained in:
Benson Wong
2025-07-01 22:17:35 -07:00
committed by GitHub
parent c867a6c9a2
commit 1921e570d7
13 changed files with 378 additions and 362 deletions

View File

@@ -3,14 +3,12 @@ import { useAPI } from "../contexts/APIProvider";
import { usePersistentState } from "../hooks/usePersistentState";
const LogViewer = () => {
const { proxyLogs, upstreamLogs, enableProxyLogs, enableUpstreamLogs } = useAPI();
const { proxyLogs, upstreamLogs, enableAPIEvents } = useAPI();
useEffect(() => {
enableProxyLogs(true);
enableUpstreamLogs(true);
enableAPIEvents(true);
return () => {
enableProxyLogs(false);
enableUpstreamLogs(false);
enableAPIEvents(false);
};
}, []);

View File

@@ -4,15 +4,13 @@ import { LogPanel } from "./LogViewer";
import { processEvalTimes } from "../lib/Utils";
export default function ModelsPage() {
const { models, enableModelUpdates, unloadAllModels, loadModel, upstreamLogs, enableUpstreamLogs } = useAPI();
const { models, unloadAllModels, loadModel, upstreamLogs, enableAPIEvents } = useAPI();
const [isUnloading, setIsUnloading] = useState(false);
useEffect(() => {
enableModelUpdates(true);
enableUpstreamLogs(true);
enableAPIEvents(true);
return () => {
enableModelUpdates(false);
enableUpstreamLogs(false);
enableAPIEvents(false);
};
}, []);
@@ -57,8 +55,13 @@ export default function ModelsPage() {
<tr key={model.id} className="border-b hover:bg-secondary-hover border-border">
<td className="p-2">
<a href={`/upstream/${model.id}/`} className="underline" target="_blank">
{model.id}
{model.name !== "" ? model.name : model.id}
</a>
{model.description != "" && (
<p>
<em>{model.description}</em>
</p>
)}
</td>
<td className="p-2">
<button