npm.io
1.0.1 • Published yesterday

@orqo/foundationmodels-core

Licence
Apache-2.0
Version
1.0.1
Deps
0
Size
111 kB
Vulns
0
Weekly
0

@orqo/foundationmodels-core

Core ports, domain types, errors, and trace model for Apple Foundation Models TypeScript runtime.

Install

pnpm add @orqo/foundationmodels-core

Usage

This package is the low-level foundation consumed by @orqo/foundationmodels and all other packages in the monorepo. Direct use is intended for authors building custom IntelligenceProvider implementations.

import type { IntelligenceProvider, IntelligenceOperation, ProviderContext } from "@orqo/foundationmodels-core";

// Implement the provider port to connect a custom inference backend.
const myProvider: IntelligenceProvider = {
  id: "my-backend",
  operations: new Set<IntelligenceOperation>(["availability", "respond", "stream"]),

  async availability(ctx) {
    return { available: true, models: [] };
  },

  async respond(request, ctx) {
    // call your backend here
    return { text: "hello", usage: { promptTokens: 0, completionTokens: 0 } };
  },
};

// Inject it via createFoundationModels() in @orqo/foundationmodels:
// createFoundationModels({ providers: { custom: [myProvider] } })

Key exports: IntelligenceProvider, FoundationModelsError (typed error base class), FoundationModelsRespondRequest, FoundationModelsStreamEvent, ClassifyRequest, ExtractRequest, RankRequest, SummarizeRequest, AvailabilityReport, and all domain types.

Most applications should depend on @orqo/foundationmodels rather than this package directly.

Keywords