MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / GPTChatFormatToClaudeInstant

Function GPTChatFormatToClaudeInstant

lib/queryLLM.ts:438–461  ·  view source on GitHub ↗
(
  chatMessages: ChatGPTMessage[],
)

Source from the content-addressed store, hash-verified

436}
437
438export function GPTChatFormatToClaudeInstant(
439 chatMessages: ChatGPTMessage[],
440): string {
441 const roleToName = {
442 system: "",
443 user: "Human:\n",
444 assistant: "Assistant:\n",
445 function: "Function: ", // Should never be used in Claude Instant
446 };
447 if (chatMessages.filter((m) => m.role === "function").length > 0) {
448 throw new Error(
449 "Function messages are not supported in Claude Instant. Please remove them.",
450 );
451 }
452 const out = `${chatMessages
453 .map((message) => `${roleToName[message.role]}${message.content}`)
454 .join("\n\n")}`;
455 if (!out.includes("\n\nHuman:")) {
456 throw new Error(
457 "Claude Instant requires a user message. Please add a user message to the prompt.",
458 );
459 }
460 return out;
461}

Callers 1

getLLMRequestChatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected