forked from open-webui/open-webui
feat: abort openai text completion when stopping responses
This commit is contained in:
parent
c1d85f8a6f
commit
c095a7c291
4 changed files with 20 additions and 8 deletions
|
@ -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 (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue