microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
21.82k stars 3.25k forks source link

.Net: Bug: .NET Google Gimini connector Issue #7904

Open sshrishipwc opened 2 months ago

sshrishipwc commented 2 months ago

Describe the bug

Google Gimini connector error when we pass custom http client. The API is exposed from GIF.

To Reproduce Steps to reproduce the behavior:

Code block Google Gimini connector using below code

GoogleAIGeminiChatCompletionService chatCompletionService = new(      modelId: "chat-bison:predict",      apiKey: .xxxxxxx,      apiVersion: GoogleAIVersion.V1,      httpClient: httpClient );   var resultdata = await chatCompletionService.GetChatMessageContentsAsync(chat, chatRequestSettings, Kernel.CreateBuilder().Build());

Expected behavior As the service is setup through GIF it should user token from HTTP client and authenticate API

Error details

Microsoft.SemanticKernel.HttpOperationException: 'Response status code does not indicate success: 401 (Unauthorized).'

RogerBarreto commented 2 months ago

Thanks for the issue!

Not fully sure what is the use case in this issue.

  1. I'm assuming also that GIF means Gateway Integration Framework correct here if I'm wrong. If this is correct, in theory your Gateway should ignore any provided header content and override it in the middle of the request.

  2. If there's no Gateway, from my understanding when using your custom HttpClient you should be able to override the header thru a Custom DelegatingHandler overriding the SendAsync with the request Header you want.

    Custom Http Handler Example

sshrishipwc commented 2 months ago

Yes it’s Gateway Integrated Framework. This is working fine for all Azure Open AI models but getting 401 for Gimini.

We verified the API call with Postman and it’s working as expected.

Get Outlook for iOShttps://aka.ms/o0ukef


From: Roger Barreto @.> Sent: Wednesday, August 7, 2024 4:32:23 AM To: microsoft/semantic-kernel @.> Cc: Hrishikesh Sawalkar (US) @.>; Author @.> Subject: Re: [microsoft/semantic-kernel] .Net: Bug: .NET Google Gimini connector Issue (Issue #7904)

Thanks for the issue!

Not fully sure what is the use case in this issue.

  1. I'm assuming also that GIF means Gateway Integration Framework correct here if I'm wrong. If this is correct, in theory your Gateway should ignore any provided header content and override it in the middle of the request.

  2. If there's no Gateway, from my understanding when using your custom HttpClient you should be able to override the header thru a Custom DelegatingHandler overriding the SendAsync with the request Header you want.

Custom Http Handler Examplehttps://urldefense.com/v3/__https://github.com/microsoft/semantic-kernel/blob/7b8ac8abf54c3c0e98c9e3f7653f44b0bb7565d3/dotnet/samples/Concepts/Memory/HuggingFace_TextEmbeddingCustomHttpHandler.cs*L43__;Iw!!Nyu6ZXf5!qHiSpaicGnsJurOM-UhcnQDzzl9bA0raz_G4J3b3AE-Hy6afK3-dN1RxSuGpkXc68_XrG9Ifn9twe0f9_8P-SiZNUHzcHQ$

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/microsoft/semantic-kernel/issues/7904*issuecomment-2273037594__;Iw!!Nyu6ZXf5!qHiSpaicGnsJurOM-UhcnQDzzl9bA0raz_G4J3b3AE-Hy6afK3-dN1RxSuGpkXc68_XrG9Ifn9twe0f9_8P-Siadl7U7FQ$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AZH3M7BSMX33SE5PQWR5LS3ZQHSSPAVCNFSM6AAAAABMCWNN7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZTGAZTONJZGQ__;!!Nyu6ZXf5!qHiSpaicGnsJurOM-UhcnQDzzl9bA0raz_G4J3b3AE-Hy6afK3-dN1RxSuGpkXc68_XrG9Ifn9twe0f9_8P-SiY1F3i9XA$. You are receiving this because you authored the thread.Message ID: @.***>


The information transmitted, including any attachments, is only for the intended recipient and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer and destroy any copies.

If the content of this email includes tax advice, the advice is limited to the matters specifically addressed herein and is not intended to address other potential tax consequences or the potential application of tax penalties.

PwC refers to one or more US member firms of the PwC network. Each member firm is a separate legal entity. Please see www.pwc.com/structure for further details.