adds stop sequences for better UJB/group chat behavior on claude
This commit is contained in:
parent
304893e13d
commit
f102f02a65
|
@ -111,15 +111,28 @@ function openaiToAnthropic(body: any, req: Request) {
|
||||||
// tokens (https://console.anthropic.com/docs/prompt-design#prompt-length)
|
// tokens (https://console.anthropic.com/docs/prompt-design#prompt-length)
|
||||||
// as the cutoff, minus a little bit for safety.
|
// as the cutoff, minus a little bit for safety.
|
||||||
|
|
||||||
// For smaller prompts we use 1.2 because it's not as cucked as 1.3
|
// For smaller prompts we use 1.2 because it's not as annoying as 1.3
|
||||||
// For big prompts (v1, auto-selects the latest model) is all we can use.
|
// For big prompts (v1, auto-selects the latest model) is all we can use.
|
||||||
const model = prompt.length > 25000 ? "claude-v1-100k" : "claude-v1.2";
|
const model = prompt.length > 25000 ? "claude-v1-100k" : "claude-v1.2";
|
||||||
|
|
||||||
|
let stops = rest.stop
|
||||||
|
? Array.isArray(rest.stop)
|
||||||
|
? rest.stop
|
||||||
|
: [rest.stop]
|
||||||
|
: [];
|
||||||
|
// Recommended by Anthropic
|
||||||
|
stops.push("\n\nHuman:");
|
||||||
|
// Helps with jailbreak prompts that send fake system messages and multi-bot
|
||||||
|
// chats that prefix bot messages with "System: Respond as <bot name>".
|
||||||
|
stops.push("\n\nSystem:");
|
||||||
|
// Remove duplicates
|
||||||
|
stops = [...new Set(stops)];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
model,
|
model,
|
||||||
prompt,
|
prompt,
|
||||||
max_tokens_to_sample: rest.max_tokens,
|
max_tokens_to_sample: rest.max_tokens,
|
||||||
stop_sequences: rest.stop,
|
stop_sequences: stops,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue