o1 "developer" role support and reasoning effort

This commit is contained in:
penurin
2024-12-27 17:13:58 +00:00
parent 36e2430a8f
commit 75cb98c727
2 changed files with 6 additions and 5 deletions
+4 -4
View File
@@ -82,7 +82,7 @@ function openAIMessagesToClaudeTextPrompt(messages: OpenAIChatMessage[]) {
let role: string = m.role;
if (role === "assistant") {
role = "Assistant";
} else if (role === "system") {
} else if (["system", "developer"].includes(role)) {
role = "System";
} else if (role === "user") {
role = "Human";
@@ -365,7 +365,7 @@ function openAIMessagesToClaudeChatPrompt(messages: OpenAIChatMessage[]): {
// Here we will lose the original name if it was a system message, but that
// is generally okay because the system message is usually a prompt and not
// a character in the chat.
const name = msg.role === "system" ? "System" : msg.name?.trim();
const name = ["system", "developer"].includes(msg.role) ? "System" : msg.name?.trim();
const content = convertOpenAIContent(msg.content);
// Prepend the display name to the first text content in the current message
@@ -395,8 +395,8 @@ function openAIMessagesToClaudeChatPrompt(messages: OpenAIChatMessage[]): {
function isSystemOpenAIRole(
role: OpenAIChatMessage["role"]
): role is "system" | "function" | "tool" {
return ["system", "function", "tool"].includes(role);
): role is "developer" | "system" | "function" | "tool" {
return ["developer","system", "function", "tool"].includes(role);
}
function getFirstTextContent(content: OpenAIChatMessage["content"]) {
+2 -1
View File
@@ -21,7 +21,7 @@ export const OpenAIV1ChatCompletionSchema = z
model: z.string().max(100),
messages: z.array(
z.object({
role: z.enum(["system", "user", "assistant", "tool", "function"]),
role: z.enum(["developer", "system", "user", "assistant", "tool", "function"]),
content: z.union([z.string(), OpenAIV1ChatContentArraySchema]),
name: z.string().optional(),
tool_calls: z.array(z.any()).optional(),
@@ -78,6 +78,7 @@ export const OpenAIV1ChatCompletionSchema = z
tool_choice: z.any().optional(),
function_choice: z.any().optional(),
response_format: z.any(),
reasoning_effort: z.enum(["low", "medium", "high"]).optional(),
})
// Tool usage must be enabled via config because we currently have no way to
// track quota usage for them or enforce limits.