.Net: Bug: 401 Unauthorized (Vertex AI and Weaviate)
I keep receiving the same error on my code:
Microsoft.SemanticKernel.HttpOperationException: Response status code does not indicate success: 401 (Unauthorized).
---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Microsoft.SemanticKernel.Http.HttpClientExtensions.SendWithSuccessCheckAsync(HttpClient client, HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Microsoft.SemanticKernel.Http.HttpClientExtensions.SendWithSuccessCheckAsync(HttpClient client, HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.Http.HttpClientExtensions.SendWithSuccessCheckAsync(HttpClient client, HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.Connectors.Weaviate.WeaviateMemoryStore.ExecuteHttpRequestAsync(HttpRequestMessage request, CancellationToken cancel)
at Microsoft.SemanticKernel.Connectors.Weaviate.WeaviateMemoryStore.DoesCollectionExistAsync(String collectionName, CancellationToken cancellationToken)
at Microsoft.SemanticKernel.Memory.SemanticTextMemory.SaveInformationAsync(String collection, String text, String id, String description, String additionalMetadata, Kernel kernel, CancellationToken cancellationToken)
at Program.<Main>$(String[] args) in D:\code\Meu-Aluguel\Api\Program.cs:line 32
at Program.<Main>(String[] args)
My code:
var weviateApiKey = "weaviate-admin-api-key";
var collection = "Test_Collection";
WeaviateMemoryStore memoryStore = new("https://my-endpoint.c0.us-east1.gcp.weaviate.cloud", weviateApiKey);
var projectId = "my-project-id";
var modelId = "gemini-1.5-pro-001";
var location = "us-central1";
var gloudAccessToken = "gcloud-access-token"; // I copied this directly from the command "gcloud auth print-access-token", just to be sure
ITextEmbeddingGenerationService textEmbeddingService = new VertexAITextEmbeddingGenerationService("text-multilingual-embedding-002", gcloudAccessToken, location, projectId);
var memory = new SemanticTextMemory(memoryStore, textEmbeddingService);
await memory.SaveInformationAsync(collection, "My name is John", Guid.NewGuid().ToString()); // <-- the Exception is thrown on this line
I've already made sure that I have all the necessary permissions on the Google Cloud and AI Vertex API, so much so that I can generate embeddings via curl. I just can't generate the embeddings programmatically.
Also, this is my collection on Weaviate:
I can't identify what I would supposedly be doing wrong.
The Weaviate documentation (https://weaviate.io/developers/weaviate/model-providers/google/embeddings) says that, for the integration with Vertex AI to work, the Vertex AI API key must be passed in the request header in the X-Google-Vertex-Api-Key field. Is the library configured to do this?
Hi @heinsenberg82 we have introduced new VectorData connectors to replace the experimental Memory functionality. Our plan is to mark the current experimental Memory functionality as obsolete and we are encouraging developer to switch to using the VectorData functionality.
Here are some links to help you to get started:
- https://github.com/markwallace-microsoft/semantic-kernel/tree/main/dotnet/samples/GettingStartedWithVectorStores
- https://learn.microsoft.com/en-us/semantic-kernel/concepts/vector-store-connectors/?pivots=programming-language-csharp
- https://learn.microsoft.com/en-us/semantic-kernel/concepts/vector-store-connectors/code-samples?pivots=programming-language-csharp
This issue is stale because it has been open for 90 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.