-
-
Save krnese/e9cf8232234c520372ee7ab825ff80cd to your computer and use it in GitHub Desktop.
rag validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Azure Open AI configuration | |
$AzureOpenAIEndpoint = "" | |
$DeploymentName = "" | |
$EmbeddingDeploymentName = "" | |
$Prompt = "" | |
# Azure AI search configuraton | |
$AzureAiSearchEndpoint = "" | |
$IndexName = "" | |
# Get Token | |
$TokenRequest = Get-AzAccessToken -ResourceUrl "https://cognitiveservices.azure.com" | |
$MyToken = $TokenRequest.token | |
# Form the request body towards the Azure Open AI API endpoint, with AzureCognitiveSearch added as dataSource for RAG | |
$Body = @" | |
{ | |
"dataSources": [ | |
{ | |
"type": "AzureCognitiveSearch", | |
"parameters": { | |
"endpoint": "https://$($AzureAiSearchEndpoint)", | |
"indexName": "$($IndexName)", | |
"embeddingDeploymentName": "$($EmbeddingDeploymentName)" | |
} | |
} | |
], | |
"messages": [ | |
{ | |
"role": "system", | |
"content": "You are an AI assistant that helps people find information." | |
}, | |
{ | |
"role": "user", | |
"content": "$($Prompt)" | |
} | |
] | |
} | |
"@ | |
# AI Request | |
$AzureOAIRequest = @{ | |
Uri = "https://$($AzureOpenAIEndpoint)/openai/deployments/$($DeploymentName)/extensions/chat/completions?api-version=2023-10-01-preview" | |
Headers = @{ | |
Authorization = "Bearer $($MyToken)" | |
'Content-Type' = 'application/json' | |
} | |
Method = 'POST' | |
Body = $Body | |
#UseBasicParsing = $true | |
} | |
$Response = Invoke-WebRequest @AzureOAIRequest | |
[Newtonsoft.Json.Linq.JObject]::Parse($Response.Content).ToString() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment