Meshpocalypse Semantic
    Preparing search index...

    Function selectModel

    • Select the best model for an agent capability, with budget-aware downgrade.

      Queries the mesh RDF graph via the model-select-budget-aware SPARQL template. If the token budget ratio falls below budgetThreshold, the cheapest available model is returned instead of the highest-quality one.

      Returns null if no agents with the requested capability and linked model capabilities are found in the graph.

      Parameters

      Returns Promise<SelectedModel | null>

      The selected SelectedModel, or null if none found.

      const model = await selectModel(graph, {
      capabilityIri: 'https://meshpocalypse.dev/ontology#Summarise',
      budgetIri: 'https://meshpocalypse.dev/budget/tenant-a',
      budgetThreshold: 0.2,
      });
      if (model) {
      console.log(model.downgraded ? 'Using cheap model:' : 'Using quality model:', model.modelId);
      }