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 {
|
export {
|
||||||
buildCerebrasModelDefinition,
|
buildCerebrasModelDefinition,
|
||||||
CEREBRAS_BASE_URL,
|
CEREBRAS_BASE_URL,
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* Cerebras provider plugin entrypoint.
|
||||||
|
*/
|
||||||
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
||||||
import { applyCerebrasConfig, CEREBRAS_DEFAULT_MODEL_REF } from "./onboard.js";
|
import { applyCerebrasConfig, CEREBRAS_DEFAULT_MODEL_REF } from "./onboard.js";
|
||||||
import { buildCerebrasProvider } from "./provider-catalog.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 { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
|
||||||
import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
||||||
import manifest from "./openclaw.plugin.json" with { type: "json" };
|
import manifest from "./openclaw.plugin.json" with { type: "json" };
|
||||||
|
|
||||||
const CEREBRAS_MANIFEST_CATALOG = manifest.modelCatalog.providers.cerebras;
|
const CEREBRAS_MANIFEST_CATALOG = manifest.modelCatalog.providers.cerebras;
|
||||||
|
|
||||||
|
/** Base URL for Cerebras OpenAI-compatible inference. */
|
||||||
export const CEREBRAS_BASE_URL = CEREBRAS_MANIFEST_CATALOG.baseUrl;
|
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;
|
export const CEREBRAS_MODEL_CATALOG = CEREBRAS_MANIFEST_CATALOG.models;
|
||||||
|
|
||||||
|
/** Builds normalized Cerebras catalog model definitions. */
|
||||||
export function buildCerebrasCatalogModels(): ModelDefinitionConfig[] {
|
export function buildCerebrasCatalogModels(): ModelDefinitionConfig[] {
|
||||||
return buildManifestModelProviderConfig({
|
return buildManifestModelProviderConfig({
|
||||||
providerId: "cerebras",
|
providerId: "cerebras",
|
||||||
@@ -14,6 +20,7 @@ export function buildCerebrasCatalogModels(): ModelDefinitionConfig[] {
|
|||||||
}).models;
|
}).models;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Builds one normalized Cerebras model definition from a manifest entry. */
|
||||||
export function buildCerebrasModelDefinition(
|
export function buildCerebrasModelDefinition(
|
||||||
model: (typeof CEREBRAS_MODEL_CATALOG)[number],
|
model: (typeof CEREBRAS_MODEL_CATALOG)[number],
|
||||||
): ModelDefinitionConfig {
|
): ModelDefinitionConfig {
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* Cerebras onboarding config helpers.
|
||||||
|
*/
|
||||||
import {
|
import {
|
||||||
createModelCatalogPresetAppliers,
|
createModelCatalogPresetAppliers,
|
||||||
type OpenClawConfig,
|
type OpenClawConfig,
|
||||||
@@ -8,6 +11,7 @@ import {
|
|||||||
CEREBRAS_MODEL_CATALOG,
|
CEREBRAS_MODEL_CATALOG,
|
||||||
} from "./models.js";
|
} from "./models.js";
|
||||||
|
|
||||||
|
/** Default Cerebras model reference used after onboarding. */
|
||||||
export const CEREBRAS_DEFAULT_MODEL_REF = "cerebras/zai-glm-4.7";
|
export const CEREBRAS_DEFAULT_MODEL_REF = "cerebras/zai-glm-4.7";
|
||||||
|
|
||||||
const cerebrasPresetAppliers = createModelCatalogPresetAppliers({
|
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 {
|
export function applyCerebrasConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||||
return cerebrasPresetAppliers.applyConfig(cfg);
|
return cerebrasPresetAppliers.applyConfig(cfg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* Cerebras model provider builder.
|
||||||
|
*/
|
||||||
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
||||||
import { buildCerebrasCatalogModels, CEREBRAS_BASE_URL } from "./models.js";
|
import { buildCerebrasCatalogModels, CEREBRAS_BASE_URL } from "./models.js";
|
||||||
|
|
||||||
|
/** Builds the Cerebras OpenAI-compatible model provider config. */
|
||||||
export function buildCerebrasProvider(): ModelProviderConfig {
|
export function buildCerebrasProvider(): ModelProviderConfig {
|
||||||
return {
|
return {
|
||||||
baseUrl: CEREBRAS_BASE_URL,
|
baseUrl: CEREBRAS_BASE_URL,
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* Public Chutes provider plugin API exports.
|
||||||
|
*/
|
||||||
export {
|
export {
|
||||||
buildChutesModelDefinition,
|
buildChutesModelDefinition,
|
||||||
CHUTES_BASE_URL,
|
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 { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
||||||
import {
|
import {
|
||||||
resolveOAuthApiKeyMarker,
|
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(
|
export function isChutesModelDiscoveryTestEnvironment(
|
||||||
env: Record<string, string | undefined> = process.env,
|
env: Record<string, string | undefined> = process.env,
|
||||||
): boolean {
|
): 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 type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
||||||
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
||||||
import {
|
import {
|
||||||
@@ -13,13 +16,17 @@ import { isChutesModelDiscoveryTestEnvironment } from "./model-discovery-env.js"
|
|||||||
|
|
||||||
const log = createSubsystemLogger("chutes-models");
|
const log = createSubsystemLogger("chutes-models");
|
||||||
|
|
||||||
|
/** Base URL for Chutes OpenAI-compatible inference. */
|
||||||
export const CHUTES_BASE_URL = "https://llm.chutes.ai/v1";
|
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";
|
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}`;
|
export const CHUTES_DEFAULT_MODEL_REF = `chutes/${CHUTES_DEFAULT_MODEL_ID}`;
|
||||||
|
|
||||||
const CHUTES_DEFAULT_CONTEXT_WINDOW = 128000;
|
const CHUTES_DEFAULT_CONTEXT_WINDOW = 128000;
|
||||||
const CHUTES_DEFAULT_MAX_TOKENS = 4096;
|
const CHUTES_DEFAULT_MAX_TOKENS = 4096;
|
||||||
|
|
||||||
|
/** Bundled fallback Chutes model catalog. */
|
||||||
export const CHUTES_MODEL_CATALOG: ModelDefinitionConfig[] = [
|
export const CHUTES_MODEL_CATALOG: ModelDefinitionConfig[] = [
|
||||||
{
|
{
|
||||||
id: "Qwen/Qwen3-32B",
|
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(
|
export function buildChutesModelDefinition(
|
||||||
model: (typeof CHUTES_MODEL_CATALOG)[number],
|
model: (typeof CHUTES_MODEL_CATALOG)[number],
|
||||||
): ModelDefinitionConfig {
|
): ModelDefinitionConfig {
|
||||||
@@ -491,6 +499,7 @@ interface CacheEntry {
|
|||||||
|
|
||||||
const modelCache = new Map<string, CacheEntry>();
|
const modelCache = new Map<string, CacheEntry>();
|
||||||
|
|
||||||
|
/** Clears the dynamic Chutes model discovery cache for tests. */
|
||||||
export function clearChutesModelCacheForTests(): void {
|
export function clearChutesModelCacheForTests(): void {
|
||||||
modelCache.clear();
|
modelCache.clear();
|
||||||
}
|
}
|
||||||
@@ -521,6 +530,7 @@ function cacheAndReturn(
|
|||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Discovers Chutes models dynamically, falling back to the bundled static catalog. */
|
||||||
export async function discoverChutesModels(accessToken?: string): Promise<ModelDefinitionConfig[]> {
|
export async function discoverChutesModels(accessToken?: string): Promise<ModelDefinitionConfig[]> {
|
||||||
const trimmedKey = normalizeOptionalString(accessToken) ?? "";
|
const trimmedKey = normalizeOptionalString(accessToken) ?? "";
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* Chutes OAuth PKCE login flow.
|
||||||
|
*/
|
||||||
import { randomBytes } from "node:crypto";
|
import { randomBytes } from "node:crypto";
|
||||||
import { resolveExpiresAtMsFromDurationSeconds } from "openclaw/plugin-sdk/number-runtime";
|
import { resolveExpiresAtMsFromDurationSeconds } from "openclaw/plugin-sdk/number-runtime";
|
||||||
import { generatePkceVerifierChallenge, toFormUrlEncoded } from "openclaw/plugin-sdk/provider-auth";
|
import { generatePkceVerifierChallenge, toFormUrlEncoded } from "openclaw/plugin-sdk/provider-auth";
|
||||||
@@ -181,6 +184,7 @@ async function exchangeChutesCodeForTokens(params: {
|
|||||||
} as ChutesStoredOAuth;
|
} as ChutesStoredOAuth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Runs Chutes OAuth and returns refreshable stored credentials. */
|
||||||
export async function loginChutes(params: {
|
export async function loginChutes(params: {
|
||||||
app: ChutesOAuthAppConfig;
|
app: ChutesOAuthAppConfig;
|
||||||
manual?: boolean;
|
manual?: boolean;
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* Chutes onboarding config helpers for OAuth and API-key setup.
|
||||||
|
*/
|
||||||
import {
|
import {
|
||||||
applyAgentDefaultModelPrimary,
|
applyAgentDefaultModelPrimary,
|
||||||
applyProviderConfigWithModelCatalogPreset,
|
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 {
|
export function applyChutesApiKeyConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||||
return applyAgentDefaultModelPrimary(applyChutesProviderConfig(cfg), CHUTES_DEFAULT_MODEL_REF);
|
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 type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
||||||
import {
|
import {
|
||||||
CHUTES_BASE_URL,
|
CHUTES_BASE_URL,
|
||||||
@@ -6,6 +9,7 @@ import {
|
|||||||
discoverChutesModels,
|
discoverChutesModels,
|
||||||
} from "./models.js";
|
} from "./models.js";
|
||||||
|
|
||||||
|
/** Builds the static Chutes provider catalog from bundled model metadata. */
|
||||||
export function buildStaticChutesProvider(): ModelProviderConfig {
|
export function buildStaticChutesProvider(): ModelProviderConfig {
|
||||||
return {
|
return {
|
||||||
baseUrl: CHUTES_BASE_URL,
|
baseUrl: CHUTES_BASE_URL,
|
||||||
|
|||||||
Reference in New Issue
Block a user