mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
feat: abort openai text completion when stopping responses
This commit is contained in:
@@ -211,10 +211,12 @@ export const generateOpenAIChatCompletion = async (
|
||||
token: string = '',
|
||||
body: object,
|
||||
url: string = OPENAI_API_BASE_URL
|
||||
) => {
|
||||
): Promise<[Response | null, AbortController]> => {
|
||||
const controller = new AbortController();
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${url}/chat/completions`, {
|
||||
signal: controller.signal,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
@@ -231,7 +233,7 @@ export const generateOpenAIChatCompletion = async (
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res;
|
||||
return [res, controller];
|
||||
};
|
||||
|
||||
export const synthesizeOpenAISpeech = async (
|
||||
|
||||
Reference in New Issue
Block a user