Automatically add Anthropic "\n\nHuman:" preamble when necessary (khanon/oai-reverse-proxy!23)

This commit is contained in:
khanon
2023-06-09 07:16:40 +00:00
parent 4f2a12ef14
commit 96cf4a0e2d
8 changed files with 122 additions and 16 deletions
@@ -153,19 +153,10 @@ function openaiToAnthropic(body: any, req: Request) {
// Remove duplicates
stops = [...new Set(stops)];
// TEMP: More shitty anthropic API hacks
// If you receive a 400 Bad Request error from Anthropic complaining about
// "prompt must start with a '\n\nHuman: ' turn", enable this setting.
// I will try to fix this when I can identify why it only happens sometimes.
let preamble = "";
if (process.env.CLAUDE_ADD_HUMAN_PREAMBLE) {
preamble = "\n\nHuman: Hello Claude.";
}
return {
...rest,
model,
prompt: preamble + prompt,
prompt: prompt,
max_tokens_to_sample: rest.max_tokens,
stop_sequences: stops,
};