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
2 changes: 1 addition & 1 deletion apps/memos-local-openclaw/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Add the plugin config to `~/.openclaw/openclaw.json`:
| Provider | `provider` value | Example `model` |
|---|---|---|
| OpenAI / compatible | `openai_compatible` | `gpt-4o-mini` |
| Anthropic | `anthropic` | `claude-3-haiku-20240307` |
| Anthropic | `anthropic` | `claude-haiku-4-5-20251001` |
| Gemini | `gemini` | `gemini-1.5-flash` |
| AWS Bedrock | `bedrock` | `anthropic.claude-3-haiku-20240307-v1:0` |

Expand Down
2 changes: 1 addition & 1 deletion apps/memos-local-openclaw/site/public/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ Replace the four argument values above with user-provided values.
| Provider | `provider` value | Example `model` |
| -------- | ---------------- | --------------- |
| OpenAI / compatible | `openai_compatible` | `gpt-4o-mini` |
| Anthropic | `anthropic` | `claude-3-haiku-20240307` |
| Anthropic | `anthropic` | `claude-haiku-4-5-20251001` |
| Gemini | `gemini` | `gemini-1.5-flash` |
| AWS Bedrock | `bedrock` | `anthropic.claude-3-haiku-20240307-v1:0` |

Expand Down
14 changes: 7 additions & 7 deletions apps/memos-local-openclaw/src/ingest/providers/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export async function summarizeTaskAnthropic(
log: Logger,
): Promise<string> {
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down Expand Up @@ -108,7 +108,7 @@ export async function generateTaskTitleAnthropic(
log: Logger,
): Promise<string> {
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down Expand Up @@ -174,7 +174,7 @@ export async function judgeNewTopicAnthropic(
log: Logger,
): Promise<boolean> {
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down Expand Up @@ -236,7 +236,7 @@ export async function filterRelevantAnthropic(
log: Logger,
): Promise<FilterResult> {
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down Expand Up @@ -298,7 +298,7 @@ export async function summarizeAnthropic(
log: Logger,
): Promise<string> {
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down Expand Up @@ -365,7 +365,7 @@ async function callAnthropicMessagesTopic(
): Promise<string> {
if (!cfg.apiKey) throw new Error(`Anthropic ${errorLabel}: apiKey is required`);
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
...cfg.headers,
Expand Down Expand Up @@ -440,7 +440,7 @@ export async function judgeDedupAnthropic(
log: Logger,
): Promise<DedupResult> {
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down
2 changes: 1 addition & 1 deletion apps/memos-local-openclaw/src/shared/llm-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ async function callLLMOnceAnthropic(
const endpoint = normalizeAnthropicEndpoint(
cfg.endpoint ?? "https://api.anthropic.com/v1/messages",
);
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down
2 changes: 1 addition & 1 deletion apps/memos-local-openclaw/src/viewer/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4006,7 +4006,7 @@ export class ViewerServer {
"x-api-key": apiKey,
"anthropic-version": "2023-06-01",
},
body: JSON.stringify({ model: model || "claude-3-haiku-20240307", max_tokens: 5, messages: [{ role: "user", content: "hi" }] }),
body: JSON.stringify({ model: model || "claude-haiku-4-5-20251001", max_tokens: 5, messages: [{ role: "user", content: "hi" }] }),
signal: AbortSignal.timeout(15_000),
});
if (!resp.ok) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1719,11 +1719,12 @@ describe('IPC Handlers Integration', () => {

it('api-key:validate should return valid for 200 response', async () => {
// Arrange
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({
const mockFetch = vi.fn().mockResolvedValue({
ok: true,
status: 200,
json: () => Promise.resolve({}),
}));
});
vi.stubGlobal('fetch', mockFetch);

// Act
const result = await invokeHandler('api-key:validate', 'sk-test-key') as {
Expand All @@ -1732,6 +1733,10 @@ describe('IPC Handlers Integration', () => {

// Assert
expect(result.valid).toBe(true);
expect(mockFetch).toHaveBeenCalledWith(
'https://api.anthropic.com/v1/models',
expect.objectContaining({ method: 'GET' })
);
});
});

Expand Down Expand Up @@ -1792,6 +1797,32 @@ describe('IPC Handlers Integration', () => {
);
});

it('api-key:validate-provider should validate Anthropic key without calling a model', async () => {
// Arrange
const mockFetch = vi.fn().mockResolvedValue({
ok: true,
json: () => Promise.resolve({}),
});
vi.stubGlobal('fetch', mockFetch);

// Act
const result = await invokeHandler('api-key:validate-provider', 'anthropic', 'sk-ant-key') as {
valid: boolean;
};

// Assert
expect(result.valid).toBe(true);
expect(mockFetch).toHaveBeenCalledWith(
'https://api.anthropic.com/v1/models',
expect.objectContaining({
method: 'GET',
headers: expect.objectContaining({
'x-api-key': 'sk-ant-key',
}),
})
);
});

it('api-key:validate-provider should validate Google key', async () => {
// Arrange
const mockFetch = vi.fn().mockResolvedValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,21 +815,15 @@ export function registerIPCHandlers(): void {
console.log('[API Key] Validation requested');

try {
// Make a simple API call to validate the key
// List models instead of sending a message, so a model retirement can't fail the check
const response = await fetchWithTimeout(
'https://api.anthropic.com/v1/messages',
'https://api.anthropic.com/v1/models',
{
method: 'POST',
method: 'GET',
headers: {
'Content-Type': 'application/json',
'x-api-key': sanitizedKey,
'anthropic-version': '2023-06-01',
},
body: JSON.stringify({
model: 'claude-3-haiku-20240307',
max_tokens: 1,
messages: [{ role: 'user', content: 'test' }],
}),
},
API_KEY_VALIDATION_TIMEOUT_MS
);
Expand Down Expand Up @@ -868,19 +862,13 @@ export function registerIPCHandlers(): void {
switch (provider) {
case 'anthropic':
response = await fetchWithTimeout(
'https://api.anthropic.com/v1/messages',
'https://api.anthropic.com/v1/models',
{
method: 'POST',
method: 'GET',
headers: {
'Content-Type': 'application/json',
'x-api-key': sanitizedKey,
'anthropic-version': '2023-06-01',
},
body: JSON.stringify({
model: 'claude-3-haiku-20240307',
max_tokens: 1,
messages: [{ role: 'user', content: 'test' }],
}),
},
API_KEY_VALIDATION_TIMEOUT_MS
);
Expand Down
14 changes: 7 additions & 7 deletions packages/memos-core/src/ingest/providers/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export async function summarizeTaskAnthropic(
log: Logger,
): Promise<string> {
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down Expand Up @@ -108,7 +108,7 @@ export async function generateTaskTitleAnthropic(
log: Logger,
): Promise<string> {
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down Expand Up @@ -174,7 +174,7 @@ export async function judgeNewTopicAnthropic(
log: Logger,
): Promise<boolean> {
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down Expand Up @@ -236,7 +236,7 @@ export async function filterRelevantAnthropic(
log: Logger,
): Promise<FilterResult> {
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down Expand Up @@ -298,7 +298,7 @@ export async function summarizeAnthropic(
log: Logger,
): Promise<string> {
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down Expand Up @@ -365,7 +365,7 @@ async function callAnthropicMessagesTopic(
): Promise<string> {
if (!cfg.apiKey) throw new Error(`Anthropic ${errorLabel}: apiKey is required`);
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
...cfg.headers,
Expand Down Expand Up @@ -440,7 +440,7 @@ export async function judgeDedupAnthropic(
log: Logger,
): Promise<DedupResult> {
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down
2 changes: 1 addition & 1 deletion packages/memos-core/src/shared/llm-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ async function callLLMOnceAnthropic(
const endpoint = normalizeAnthropicEndpoint(
cfg.endpoint ?? "https://api.anthropic.com/v1/messages",
);
const model = cfg.model ?? "claude-3-haiku-20240307";
const model = cfg.model ?? "claude-haiku-4-5-20251001";
const headers: Record<string, string> = {
"Content-Type": "application/json",
"x-api-key": cfg.apiKey ?? "",
Expand Down
2 changes: 1 addition & 1 deletion packages/memos-core/src/viewer/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3929,7 +3929,7 @@ export class ViewerServer {
"x-api-key": apiKey,
"anthropic-version": "2023-06-01",
},
body: JSON.stringify({ model: model || "claude-3-haiku-20240307", max_tokens: 5, messages: [{ role: "user", content: "hi" }] }),
body: JSON.stringify({ model: model || "claude-haiku-4-5-20251001", max_tokens: 5, messages: [{ role: "user", content: "hi" }] }),
signal: AbortSignal.timeout(15_000),
});
if (!resp.ok) {
Expand Down
Loading