Moon shot back
This commit is contained in:
@@ -6,7 +6,7 @@ import { addKey, finalizeBody } from "./middleware/request";
|
|||||||
import { ProxyResHandlerWithBody } from "./middleware/response";
|
import { ProxyResHandlerWithBody } from "./middleware/response";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { MoonshotKey, keyPool } from "../shared/key-management";
|
import { MoonshotKey, keyPool } from "../shared/key-management";
|
||||||
import { isMoonshotModel, isMoonshotVisionModel, enableMoonshotPartial, hasMoonshotPartialMode } from "../shared/api-schemas/moonshot";
|
import { isMoonshotModel, isMoonshotVisionModel } from "../shared/api-schemas/moonshot";
|
||||||
import { logger } from "../logger";
|
import { logger } from "../logger";
|
||||||
|
|
||||||
const log = logger.child({ module: "proxy", service: "moonshot" });
|
const log = logger.child({ module: "proxy", service: "moonshot" });
|
||||||
|
|||||||
@@ -83,24 +83,5 @@ export const MoonshotV1EmbeddingsSchema = z.object({
|
|||||||
encoding_format: z.enum(["float", "base64"]).optional()
|
encoding_format: z.enum(["float", "base64"]).optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Helper function to enable partial mode for Moonshot (similar to Deepseek's prefill)
|
// Note: Partial mode handling is implemented directly in the proxy middleware
|
||||||
export function enableMoonshotPartial(messages: any[]): any[] {
|
// to follow the Deepseek-style consolidation pattern
|
||||||
// If the last message is from assistant and doesn't have partial flag, add it
|
|
||||||
if (messages.length > 0 && messages[messages.length - 1].role === 'assistant') {
|
|
||||||
const lastMessage = messages[messages.length - 1];
|
|
||||||
if (!lastMessage.partial) {
|
|
||||||
return [
|
|
||||||
...messages.slice(0, -1),
|
|
||||||
{ ...lastMessage, partial: true }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper function to check if request uses partial mode
|
|
||||||
export function hasMoonshotPartialMode(messages: any[]): boolean {
|
|
||||||
return messages.length > 0 &&
|
|
||||||
messages[messages.length - 1].role === 'assistant' &&
|
|
||||||
messages[messages.length - 1].partial === true;
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user