-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System messages don't work with Anthropic's Claude. #7807
Comments
Hey there, @raffareis! I'm here to help you with any bugs, questions, or contributions you might have. Let's tackle this issue together! To address the issue with integrating Zep Memory and Anthropic's Claude API, you can use the Here's a brief guide on how to implement this:
Here's a code snippet to illustrate this: import { Memory } from "@getzep/zep-cloud";
import { condenseZepMemoryIntoHumanMessage, zepMemoryContextToSystemPrompt } from "./path_to_your_functions";
// Assume `memory` is an instance of Zep Memory
const memory: Memory = /* your Zep memory instance */;
// Convert Zep memory into a human message
const humanMessage = condenseZepMemoryIntoHumanMessage(memory);
// Use the system prompt and human message with Claude API
const systemPrompt = zepMemoryContextToSystemPrompt(memory);
// Pass `systemPrompt` as the top-level "system" parameter
// and `humanMessage` as the input message to Claude API This approach ensures compatibility with Claude's API by using the top-level "system" parameter instead of a To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Add separateMessages option to ZepMemory class to address Claude API limitation with system messages. When set to false, all memory content is condensed into a single HumanMessage instead of using SystemMessage. Default is true for backward compatibility. Fixes langchain-ai#7807
When using Zep Memory this creates a message with role="system".
langchainjs/libs/langchain-community/src/memory/zep.ts
Line 148 in e376af8
However Claude doesn't support this:
Claude doesn't have a role="system" message, instead it has a "system" base parameter on its API:
https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/system-prompts
https://docs.anthropic.com/en/api/messages#body-messages
The text was updated successfully, but these errors were encountered: