Skip to content

Commit

Permalink
Merge pull request #901 from b4s36t4/fix/azure-ai-extra
Browse files Browse the repository at this point in the history
chore: allow azure-ai to accept the extra-params from the headers
  • Loading branch information
VisargD authored Jan 30, 2025
2 parents 3c7e325 + 74e2513 commit 98d6c61
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/handlers/handlerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ export function constructConfigFromRequestHeaders(
requestHeaders[`x-${POWERED_BY}-azure-deployment-type`],
azureApiVersion: requestHeaders[`x-${POWERED_BY}-azure-api-version`],
azureEndpointName: requestHeaders[`x-${POWERED_BY}-azure-endpoint-name`],
azureExtraParams: requestHeaders[`x-${POWERED_BY}-azure-extra-params`],
};

const awsConfig = {
Expand Down
10 changes: 7 additions & 3 deletions src/providers/azure-ai-inference/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ const AzureAIInferenceAPI: ProviderAPIConfig = {
return `https://${azureEndpointName}.${azureRegion}.inference.ml.azure.com/score`;
},
headers: ({ providerOptions }) => {
const { apiKey, azureDeploymentType, azureDeploymentName } =
providerOptions;
const {
apiKey,
azureDeploymentType,
azureDeploymentName,
azureExtraParams,
} = providerOptions;
const headers: Record<string, string> = {
Authorization: `Bearer ${apiKey}`,
'extra-parameters': 'ignore',
'extra-parameters': azureExtraParams || 'pass-through',
};
if (azureDeploymentType === 'managed' && azureDeploymentName) {
headers['azureml-model-deployment'] = azureDeploymentName;
Expand Down
1 change: 1 addition & 0 deletions src/types/requestBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export interface Options {
azureDeploymentType?: 'managed' | 'serverless';
azureEndpointName?: string;
azureApiVersion?: string;
azureExtraParams?: string;

/** The parameter to determine if extra non-openai compliant fields should be returned in response */
strictOpenAiCompliance?: boolean;
Expand Down

0 comments on commit 98d6c61

Please sign in to comment.