Skip to content

armgit / Edge0

Public Imported from GitHub
0

Run 35B MoE models in ~2.5 GB of RAM. Weights stream from SSD; a trained router predicts loads a step ahead. Mac, iPhone, Android, Windows supported

Python
1.2 KB
Raw Blame
import { Channel, invoke } from "@tauri-apps/api/core";

import { toApiError } from "./frames";
import type { EventFrame, StreamFrame } from "./frames";

export async function apiGet(path: string): Promise<unknown> {
  try {
    return await invoke<unknown>("api_get", { path });
  } catch (e) {
    throw toApiError(String(e));
  }
}

export async function apiPost(path: string, body: unknown): Promise<unknown> {
  try {
    return await invoke<unknown>("api_post", { path, body });
  } catch (e) {
    throw toApiError(String(e));
  }
}

export async function apiDelete(path: string): Promise<unknown> {
  try {
    return await invoke<unknown>("api_delete", { path });
  } catch (e) {
    throw toApiError(String(e));
  }
}

export function subscribeEventDriver(onFrame: (f: EventFrame) => void): () => void {
  const channel = new Channel<string>();
  channel.onmessage = (raw: string) => {
    try {
      onFrame(JSON.parse(raw) as EventFrame);
    } catch {
      /* ignore malformed event frames */
    }
  };
  void invoke("events_subscribe", { onFrame: channel }).catch(() => undefined);
  return () => void invoke("events_unsubscribe").catch(() => undefined);
}

export type { StreamFrame };