Skip to content

Commit

Permalink
feat: Added support for Azure OpenAI API
Browse files Browse the repository at this point in the history
  • Loading branch information
hiro-v committed Dec 8, 2023
1 parent 7e3e648 commit bbffaaf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions extensions/inference-openai-extension/src/helpers/sse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ export function requestInference(
controller?: AbortController
): Observable<string> {
return new Observable((subscriber) => {
let model_id: string = model.id
if (engine.full_url.includes("openai.azure.com")){
model_id = engine.full_url.split("/")[5]
}
const requestBody = JSON.stringify({
messages: recentMessages,
stream: true,
model: model.id,
// Model parameters spreading
...model.parameters,
model: model_id
// ...model.parameters,
});
fetch(`${engine.full_url}`, {
method: "POST",
Expand All @@ -29,6 +32,7 @@ export function requestInference(
Accept: "text/event-stream",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${engine.api_key}`,
"api-key": `${engine.api_key}`,
},
body: requestBody,
signal: controller?.signal,
Expand Down

0 comments on commit bbffaaf

Please sign in to comment.