mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
docs: document cerebras and chutes providers
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Public Cerebras provider plugin API exports.
|
||||
*/
|
||||
export {
|
||||
buildCerebrasModelDefinition,
|
||||
CEREBRAS_BASE_URL,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Cerebras provider plugin entrypoint.
|
||||
*/
|
||||
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
||||
import { applyCerebrasConfig, CEREBRAS_DEFAULT_MODEL_REF } from "./onboard.js";
|
||||
import { buildCerebrasProvider } from "./provider-catalog.js";
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
/**
|
||||
* Cerebras model catalog helpers derived from the plugin manifest.
|
||||
*/
|
||||
import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
|
||||
import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
||||
import manifest from "./openclaw.plugin.json" with { type: "json" };
|
||||
|
||||
const CEREBRAS_MANIFEST_CATALOG = manifest.modelCatalog.providers.cerebras;
|
||||
|
||||
/** Base URL for Cerebras OpenAI-compatible inference. */
|
||||
export const CEREBRAS_BASE_URL = CEREBRAS_MANIFEST_CATALOG.baseUrl;
|
||||
/** Cerebras model catalog entries from the plugin manifest. */
|
||||
export const CEREBRAS_MODEL_CATALOG = CEREBRAS_MANIFEST_CATALOG.models;
|
||||
|
||||
/** Builds normalized Cerebras catalog model definitions. */
|
||||
export function buildCerebrasCatalogModels(): ModelDefinitionConfig[] {
|
||||
return buildManifestModelProviderConfig({
|
||||
providerId: "cerebras",
|
||||
@@ -14,6 +20,7 @@ export function buildCerebrasCatalogModels(): ModelDefinitionConfig[] {
|
||||
}).models;
|
||||
}
|
||||
|
||||
/** Builds one normalized Cerebras model definition from a manifest entry. */
|
||||
export function buildCerebrasModelDefinition(
|
||||
model: (typeof CEREBRAS_MODEL_CATALOG)[number],
|
||||
): ModelDefinitionConfig {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Cerebras onboarding config helpers.
|
||||
*/
|
||||
import {
|
||||
createModelCatalogPresetAppliers,
|
||||
type OpenClawConfig,
|
||||
@@ -8,6 +11,7 @@ import {
|
||||
CEREBRAS_MODEL_CATALOG,
|
||||
} from "./models.js";
|
||||
|
||||
/** Default Cerebras model reference used after onboarding. */
|
||||
export const CEREBRAS_DEFAULT_MODEL_REF = "cerebras/zai-glm-4.7";
|
||||
|
||||
const cerebrasPresetAppliers = createModelCatalogPresetAppliers({
|
||||
@@ -21,6 +25,7 @@ const cerebrasPresetAppliers = createModelCatalogPresetAppliers({
|
||||
}),
|
||||
});
|
||||
|
||||
/** Applies Cerebras provider/catalog config and default model aliases. */
|
||||
export function applyCerebrasConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||
return cerebrasPresetAppliers.applyConfig(cfg);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
/**
|
||||
* Cerebras model provider builder.
|
||||
*/
|
||||
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
||||
import { buildCerebrasCatalogModels, CEREBRAS_BASE_URL } from "./models.js";
|
||||
|
||||
/** Builds the Cerebras OpenAI-compatible model provider config. */
|
||||
export function buildCerebrasProvider(): ModelProviderConfig {
|
||||
return {
|
||||
baseUrl: CEREBRAS_BASE_URL,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Public Chutes provider plugin API exports.
|
||||
*/
|
||||
export {
|
||||
buildChutesModelDefinition,
|
||||
CHUTES_BASE_URL,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Chutes provider plugin entrypoint with OAuth and API-key auth methods.
|
||||
*/
|
||||
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
||||
import {
|
||||
resolveOAuthApiKeyMarker,
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Environment helper for Chutes model discovery behavior in tests.
|
||||
*/
|
||||
/** Returns whether dynamic Chutes model discovery should use test behavior. */
|
||||
export function isChutesModelDiscoveryTestEnvironment(
|
||||
env: Record<string, string | undefined> = process.env,
|
||||
): boolean {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Chutes model catalog, static model definitions, and dynamic model discovery.
|
||||
*/
|
||||
import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
||||
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
||||
import {
|
||||
@@ -13,13 +16,17 @@ import { isChutesModelDiscoveryTestEnvironment } from "./model-discovery-env.js"
|
||||
|
||||
const log = createSubsystemLogger("chutes-models");
|
||||
|
||||
/** Base URL for Chutes OpenAI-compatible inference. */
|
||||
export const CHUTES_BASE_URL = "https://llm.chutes.ai/v1";
|
||||
/** Default Chutes model id used for onboarding. */
|
||||
export const CHUTES_DEFAULT_MODEL_ID = "zai-org/GLM-4.7-TEE";
|
||||
/** Default Chutes model ref used for onboarding. */
|
||||
export const CHUTES_DEFAULT_MODEL_REF = `chutes/${CHUTES_DEFAULT_MODEL_ID}`;
|
||||
|
||||
const CHUTES_DEFAULT_CONTEXT_WINDOW = 128000;
|
||||
const CHUTES_DEFAULT_MAX_TOKENS = 4096;
|
||||
|
||||
/** Bundled fallback Chutes model catalog. */
|
||||
export const CHUTES_MODEL_CATALOG: ModelDefinitionConfig[] = [
|
||||
{
|
||||
id: "Qwen/Qwen3-32B",
|
||||
@@ -452,6 +459,7 @@ export const CHUTES_MODEL_CATALOG: ModelDefinitionConfig[] = [
|
||||
},
|
||||
];
|
||||
|
||||
/** Adds Chutes provider compat metadata to one model catalog entry. */
|
||||
export function buildChutesModelDefinition(
|
||||
model: (typeof CHUTES_MODEL_CATALOG)[number],
|
||||
): ModelDefinitionConfig {
|
||||
@@ -491,6 +499,7 @@ interface CacheEntry {
|
||||
|
||||
const modelCache = new Map<string, CacheEntry>();
|
||||
|
||||
/** Clears the dynamic Chutes model discovery cache for tests. */
|
||||
export function clearChutesModelCacheForTests(): void {
|
||||
modelCache.clear();
|
||||
}
|
||||
@@ -521,6 +530,7 @@ function cacheAndReturn(
|
||||
return models;
|
||||
}
|
||||
|
||||
/** Discovers Chutes models dynamically, falling back to the bundled static catalog. */
|
||||
export async function discoverChutesModels(accessToken?: string): Promise<ModelDefinitionConfig[]> {
|
||||
const trimmedKey = normalizeOptionalString(accessToken) ?? "";
|
||||
const now = Date.now();
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Chutes OAuth PKCE login flow.
|
||||
*/
|
||||
import { randomBytes } from "node:crypto";
|
||||
import { resolveExpiresAtMsFromDurationSeconds } from "openclaw/plugin-sdk/number-runtime";
|
||||
import { generatePkceVerifierChallenge, toFormUrlEncoded } from "openclaw/plugin-sdk/provider-auth";
|
||||
@@ -181,6 +184,7 @@ async function exchangeChutesCodeForTokens(params: {
|
||||
} as ChutesStoredOAuth;
|
||||
}
|
||||
|
||||
/** Runs Chutes OAuth and returns refreshable stored credentials. */
|
||||
export async function loginChutes(params: {
|
||||
app: ChutesOAuthAppConfig;
|
||||
manual?: boolean;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Chutes onboarding config helpers for OAuth and API-key setup.
|
||||
*/
|
||||
import {
|
||||
applyAgentDefaultModelPrimary,
|
||||
applyProviderConfigWithModelCatalogPreset,
|
||||
@@ -58,6 +61,7 @@ export function applyChutesConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||
};
|
||||
}
|
||||
|
||||
/** Applies Chutes provider config and sets the default model for API-key auth. */
|
||||
export function applyChutesApiKeyConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||
return applyAgentDefaultModelPrimary(applyChutesProviderConfig(cfg), CHUTES_DEFAULT_MODEL_REF);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Chutes provider builders for static and dynamically discovered catalogs.
|
||||
*/
|
||||
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
||||
import {
|
||||
CHUTES_BASE_URL,
|
||||
@@ -6,6 +9,7 @@ import {
|
||||
discoverChutesModels,
|
||||
} from "./models.js";
|
||||
|
||||
/** Builds the static Chutes provider catalog from bundled model metadata. */
|
||||
export function buildStaticChutesProvider(): ModelProviderConfig {
|
||||
return {
|
||||
baseUrl: CHUTES_BASE_URL,
|
||||
|
||||
Reference in New Issue
Block a user