Created
July 20, 2023 10:54
-
-
Save AlexanderHolmeset/2c664fb7b9de11c2d6181825233176e6 to your computer and use it in GitHub Desktop.
This file contains 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
$Question = "How many sick days do i have?" | |
$AzureOpenAIEndpointURL = "https://sharepointdocumentschat.openai.azure.com/" | |
$AzureOpenAIEndpointKey = "7256974864a9499499ca4d3e70fa0c7b" | |
$AzureOpenAIModelDelpoymentName = "ChatGPT4" | |
$AzureCognitiveSearchURL = "https://sharepointsearchinstance.search.windows.net" | |
$AzureCognitiveSearchAdminKey = "Wt1mZ0sjkKoXW913d2eJ8xXYJk4JHThk1UK8H0wZoIAzSeDjYTmC" | |
$Header = @{"api-key" = "$AzureOpenAIEndpointKey" | |
"ChatGpt_Key" = "$AzureOpenAIEndpointKey " | |
"ChatGpt_Url" = "$AzureOpenAIEndpointURL" | |
"content-type" = "application/json" | |
} | |
$Body = @" | |
{ | |
"dataSources": [ | |
{ | |
"type": "AzureCognitiveSearch", | |
"parameters": { | |
"endpoint": "$azurecognitivesearchurl", | |
"key": "$AzureCognitiveSearchAdminKey", | |
"indexName": "sharepoint-index" | |
} | |
} | |
], | |
"messages": [ | |
{ | |
"role": "user", | |
"content": "$Question" | |
} | |
] | |
} | |
"@ | |
$uri = $AzureOpenAIEndpointURL + "openai/deployments/" + $AzureOpenAIModelDelpoymentName + "/extensions/chat/completions?api-version=2023-06-01-preview" | |
$meassage = invoke-restmethod -Method POST -Uri $uri -Body $body -Headers $Header | |
"Question: $Question" | |
"Answer: $($meassage.CHoices.messages[1].content)" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment