I deployed a llama-3-70b-instruct model via the Azure AI Studio. I then tried to call it with a HTTP request which resulted in a 424 HTTP error. This error still occured when using the example code provided by Microsfts “View Code” feature in the playground. Using the playground with the deployment however worked just fine. The code is as follows:
static async Task InvokeRequestResponseService()
{
var handler = new HttpClientHandler()
{
ClientCertificateOptions = ClientCertificateOption.Manual,
ServerCertificateCustomValidationCallback =
(httpRequestMessage, cert, cetChain, policyErrors) => { return true; }
};
using (var client = new HttpClient(handler))
{
// Request data goes here
// The example below assumes JSON formatting which may be updated
// depending on the format your endpoint expects.
// More information can be found here:
// https://docs.microsoft.com/azure/machine-learning/how-to-deploy-advanced-entry-script
var requestBody = @"{
""input_data"": {
""input_string"": [
{
""role"": ""user"",
""content"": ""I am going to Paris, what should I see?""
},
{
""role"": ""assistant"",
""content"": ""Paris, the capital of France, is known for its stunning architecture, art museums, historical landmarks, and romantic atmosphere. Here are some of the top attractions to see in Paris:nn1. The Eiffel Tower: The iconic Eiffel Tower is one of the most recognizable landmarks in the world and offers breathtaking views of the city.n2. The Louvre Museum: The Louvre is one of the world's largest and most famous museums, housing an impressive collection of art and artifacts, including the Mona Lisa.n3. Notre-Dame Cathedral: This beautiful cathedral is one of the most famous landmarks in Paris and is known for its Gothic architecture and stunning stained glass windows.nnThese are just a few of the many attractions that Paris has to offer. With so much to see and do, it's no wonder that Paris is one of the most popular tourist destinations in the world.""
},
{
""role"": ""user"",
""content"": ""What is so great about #1?""
}
],
""parameters"": {
""temperature"": 0.8,
""top_p"": 0.8,
""max_new_tokens"": 128
}
}
}";
// Replace this with the primary/secondary key, AMLToken, or Microsoft Entra ID token for the endpoint
const string apiKey = "<my key>";
if (string.IsNullOrEmpty(apiKey))
{
throw new Exception("A key should be provided to invoke the endpoint");
}
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue( "Bearer", apiKey);
client.BaseAddress = new Uri("https://<deploymentname>.westeurope.inference.ml.azure.com/score/v1/chat/completions");
var content = new StringContent(requestBody);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
// WARNING: The 'await' statement below can result in a deadlock
// if you are calling this code from the UI thread of an ASP.Net application.
// One way to address this would be to call ConfigureAwait(false)
// so that the execution does not attempt to resume on the original context.
// For instance, replace code such as:
// result = await DoSomeTask()
// with the following:
// result = await DoSomeTask().ConfigureAwait(false)
HttpResponseMessage response = await client.PostAsync("", content);
if (response.IsSuccessStatusCode)
{
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine("Result: {0}", result);
}
else
{
Console.WriteLine(string.Format("The request failed with status code: {0}", response.StatusCode));
// Print the headers - they include the requert ID and the timestamp,
// which are useful for debugging the failure
Console.WriteLine(response.Headers.ToString());
string responseContent = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseContent);
}
}
}
I of course inserted my API Key and deployment name. The response also contained the following headers:
The request failed with status code: FailedDependency
Date: Tue, 07 May 2024 21:19:40 GMT
Server: azureml-frontdoor
X-Request-ID: xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
ms-azureml-model-error-reason: model_error
ms-azureml-model-error-statuscode: 404
azureml-model-deployment: meta-llama-3-70b-instruct-2
azureml-model-session: meta-llama-3-70b-instruct-2
What am i missing to get this running?
I also created different deployments but each time i would run into the same issue. I expected that my initial request might not be exactly what the endpoint expects, but the fact that microsofts example isn’t working is really confusing to me.
abcdefghijk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.