Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/memos-local-plugin/core/config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export const DEFAULT_CONFIG: ResolvedConfig = {
openRouter: false,
maxTokens: 1024,
headers: {},
// Only read when provider = "chatgpt" (Sign in with ChatGPT).
chatgpt: { model: "", fallback: true, tokenFile: "" },
},
l3Llm: {
// Empty by default — falls back to the shared `llm` settings.
Expand All @@ -80,6 +82,7 @@ export const DEFAULT_CONFIG: ResolvedConfig = {
openRouter: false,
maxTokens: 4096,
headers: {},
chatgpt: { model: "", fallback: true, tokenFile: "" },
},
skillEvolver: {
// Empty by default — falls back to the shared `llm` settings.
Expand All @@ -96,6 +99,7 @@ export const DEFAULT_CONFIG: ResolvedConfig = {
openRouter: false,
maxTokens: 4096,
headers: {},
chatgpt: { model: "", fallback: true, tokenFile: "" },
},
storage: {
ftsTokenizer: "trigram",
Expand Down
50 changes: 41 additions & 9 deletions apps/memos-local-plugin/core/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,46 @@ const EmbeddingSchema = Type.Object({
}, { default: {} }),
}, { default: {} });

/** Reasoning effort levels accepted by `reasoning.effort` and `chatgpt.reasoningEffort`. */
const ReasoningEffortSchema = Type.Union([
Type.Literal("minimal"),
Type.Literal("none"),
Type.Literal("low"),
Type.Literal("medium"),
Type.Literal("high"),
Type.Literal("xhigh"),
Type.Literal("max"),
]);

const ReasoningSchema = Type.Object({
/**
* OpenRouter-compatible reasoning toggle. Omit the whole block to keep
* the provider/model default.
*/
enabled: Type.Optional(Type.Boolean()),
/** Optional provider effort hint for reasoning-capable models. */
effort: Type.Optional(Type.Union([
Type.Literal("minimal"),
Type.Literal("none"),
Type.Literal("low"),
Type.Literal("medium"),
Type.Literal("high"),
Type.Literal("xhigh"),
Type.Literal("max"),
])),
effort: Type.Optional(ReasoningEffortSchema),
/** Optional token budget for reasoning-capable providers. */
maxTokens: Type.Optional(Type.Number({ minimum: 1 })),
}, { default: {} });

/**
* Settings for `provider: chatgpt` (Sign in with ChatGPT, see
* `core/llm/providers/chatgpt.ts`). Only read when the provider is
* "chatgpt"; `endpoint` / `apiKey` / `model` in the same block stay the
* openai_compatible fallback.
*/
const ChatGptSchema = Type.Object({
/** Model slug from GET /v1/models. Blank = provider default. */
model: Type.Optional(Type.String()),
/** Fall back to the openai_compatible settings on failure. Default true. */
fallback: Type.Optional(Type.Boolean()),
/** Credential file. Default ~/.config/memos-local/chatgpt-oauth.json. */
tokenFile: Type.Optional(Type.String()),
/** Optional Responses API reasoning effort (e.g. "low"). Omitted when unset. */
reasoningEffort: Type.Optional(ReasoningEffortSchema),
});

const LlmSchema = Type.Object({
provider: Type.Union([
Type.Literal(""),
Expand All @@ -104,6 +124,7 @@ const LlmSchema = Type.Object({
Type.Literal("anthropic"),
Type.Literal("bedrock"),
Type.Literal("host"),
Type.Literal("chatgpt"),
], { default: "" }),
endpoint: StringWithDefault(""),
model: StringWithDefault(""),
Expand All @@ -127,6 +148,8 @@ const LlmSchema = Type.Object({
maxTokens: NumberInRange(1024, 100, 131072),
/** Extra HTTP headers for the provider request. */
headers: Type.Optional(Type.Record(Type.String(), Type.String(), { default: {} })),
/** Only read when provider = "chatgpt" (see ChatGptSchema). */
chatgpt: Type.Optional(ChatGptSchema),
}, { default: {} });

/**
Expand All @@ -145,6 +168,7 @@ const SkillEvolverSchema = Type.Object({
Type.Literal("openai_compatible"),
Type.Literal("gemini"),
Type.Literal("anthropic"),
Type.Literal("chatgpt"),
], { default: "" }),
endpoint: StringWithDefault(""),
model: StringWithDefault(""),
Expand All @@ -163,6 +187,13 @@ const SkillEvolverSchema = Type.Object({
maxTokens: NumberInRange(1024, 100, 131072),
/** Extra HTTP headers for the provider request. */
headers: Type.Optional(Type.Record(Type.String(), Type.String(), { default: {} })),
/**
* Only read when provider = "chatgpt". When this block's endpoint and
* apiKey are both blank, the openai_compatible fallback uses the main
* `llm` block's endpoint and apiKey, provided the main provider is
* openai_compatible or chatgpt.
*/
chatgpt: Type.Optional(ChatGptSchema),
}, { default: {} });

const StorageSchema = Type.Object({
Expand Down Expand Up @@ -709,4 +740,5 @@ export const ConfigSchema = Type.Object({
}, { default: {} });

export type ReasoningConfig = Static<typeof ReasoningSchema>;
export type ChatGptConfig = Static<typeof ChatGptSchema>;
export type ResolvedConfig = Static<typeof ConfigSchema>;
5 changes: 3 additions & 2 deletions apps/memos-local-plugin/core/llm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ facade — providers are not exported outside this directory.

## 1. Introduction

Five real providers + two sentinels, all behind one interface:
Six real providers + two sentinels, all behind one interface:

| provider | native JSON mode | native stream | notes |
| ------------------- | ---------------- | ------------- | ----------------------------- |
| `openai_compatible` | ✅ (`json_object`) | ✅ (SSE) | Works with OpenAI, Azure, Zhipu, SiliconFlow, Bailian, etc. |
| `anthropic` | ❌ (hint-based) | ✅ (SSE) | Messages API. |
| `gemini` | ✅ (`responseMimeType`) | ✅ (SSE) | Google generateContent. |
| `bedrock` | ❌ (hint-based) | ❌ | Converse API. SigV4 is the caller's problem. |
| `chatgpt` | ✅ (`json_object`, hint fallback) | ✅ (SSE) | User's ChatGPT plan via Sign in with ChatGPT (Responses API, `store:false`). Falls back to the block's openai_compatible settings. See `docs/CONFIG-ADVANCED.md`. |
| `host` | ❌ (hint-based) | ❌ (faked) | Delegates to the host agent (OpenClaw) via `HostLlmBridge`. |
| `local_only` | ─ | ─ | Always throws `LLM_UNAVAILABLE`. Use to explicitly disable LLM. |

Expand Down Expand Up @@ -161,7 +162,7 @@ Current prompts:
- `llm.json` — malformed-JSON retry warnings
- `llm.prompts` — prompt registry lookups (Phase 12 onward)
- `llm.openai_compatible`, `llm.anthropic`, `llm.gemini`, `llm.bedrock`,
`llm.host`, `llm.local_only` — per-provider HTTP attempts + duration
`llm.host`, `llm.local_only`, `llm.chatgpt` — per-provider HTTP attempts + duration
+ status

Every successful call also produces an `llm(...)` payload:
Expand Down
Loading