fixes issue with attempting to log non-completion endpoints
This commit is contained in:
parent
0f60fa9407
commit
34ed165a6f
|
@ -2,6 +2,8 @@ import { config } from "../../../config";
|
|||
import { logQueue } from "../../../prompt-logging";
|
||||
import { ProxyResHandlerWithBody } from ".";
|
||||
|
||||
const COMPLETE_ENDPOINT = "/v1/chat/completions";
|
||||
|
||||
/** If prompt logging is enabled, enqueues the prompt for logging. */
|
||||
export const logPrompt: ProxyResHandlerWithBody = async (
|
||||
_proxyRes,
|
||||
|
@ -16,6 +18,11 @@ export const logPrompt: ProxyResHandlerWithBody = async (
|
|||
throw new Error("Expected body to be an object");
|
||||
}
|
||||
|
||||
// Only log prompts if we're making a request to a completion endpoint
|
||||
if (!req.originalUrl.startsWith(COMPLETE_ENDPOINT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const model = req.body.model;
|
||||
const promptFlattened = flattenMessages(req.body.messages);
|
||||
const response = getResponseForModel({ model, body: responseBody });
|
||||
|
|
Loading…
Reference in New Issue