Skip to content

.NET: Bug: extra-parameters needed in HttpClient for Mistral #11634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
williambohrmann3 opened this issue Apr 17, 2025 · 4 comments · May be fixed by #11646
Open

.NET: Bug: extra-parameters needed in HttpClient for Mistral #11634

williambohrmann3 opened this issue Apr 17, 2025 · 4 comments · May be fixed by #11646
Assignees
Labels
ai connector Anything related to AI connectors .NET Issue or Pull requests regarding .NET code

Comments

@williambohrmann3
Copy link

williambohrmann3 commented Apr 17, 2025

Describe the bug
I am getting a 400 bad request exception for Mistral chat completions when I don't specify an HttpClient with the following header

DefaultRequestHeaders =
{
    {  "extra-parameters", "pass-through" },
}

Expected behavior
A clear and concise description of what you expected to happen.

To Reproduce
Run reproducer code
https://github.com/williambohrmann3/SemanticKernelMistralBug/blob/master/Program.cs

Expected behavior
The HttpRequest parameter is marked as optional, so this header shouldn't be required. It should "just work".

Platform

  • Language: C#
  • Source: NuGet 1.47.0-alpha
  • AI model: MistralAI:mistral-large-latest
  • IDE: Visual Studio
  • OS: Windows

Additional context
Interestingly, Python devs using the Mistral connector for LangChain are getting the same error message.
https://learn.microsoft.com/en-us/answers/questions/2117664/my-mistral-large-2407-serverless-deployment-api-is

https://learn.microsoft.com/en-us/answers/questions/2113323/((detail-extra-parameters-(safe-prompt)-are-not-al

Deep in the stack trace, after enabling language runtime exceptions, my colleague found the following error

Error code: 400 - {'detail': "Extra parameters ['n'] are not allowed when extra-parameters is not set or set to be 'error'. Set extra-parameters to 'pass-through' to pass to the model."}
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code python Pull requests for the Python Semantic Kernel triage labels Apr 17, 2025
@github-actions github-actions bot changed the title Bug: extra-parameters needed in HttpClient for Mistral .Net: Bug: extra-parameters needed in HttpClient for Mistral Apr 17, 2025
@github-actions github-actions bot changed the title .Net: Bug: extra-parameters needed in HttpClient for Mistral Python: Bug: extra-parameters needed in HttpClient for Mistral Apr 17, 2025
@williambohrmann3 williambohrmann3 changed the title Python: Bug: extra-parameters needed in HttpClient for Mistral .NET: Bug: extra-parameters needed in HttpClient for Mistral Apr 17, 2025
@williambohrmann3
Copy link
Author

The Mistral endpoint I am using is serverless, alike the Python LangChain user from the Microsoft Q+A linked above

@shethaadit
Copy link
Contributor

Hi @RogerBarreto / @westey-m, I have raised PR to fix this. Will monitor for the green build. :)

@RogerBarreto RogerBarreto self-assigned this Apr 18, 2025
@donatas-xyz
Copy link

I have exactly the same setup and error, but my Mistral Chat Completion service is not accepting HttpClient?

public static IServiceCollection AddMistralChatCompletion(
    this IServiceCollection services,
    string modelId,
    string apiKey,
    Uri? endpoint = null,
    string? serviceId = null)
{
    Verify.NotNull(services);

    return services.AddKeyedSingleton<IChatCompletionService>(serviceId, (serviceProvider, _) =>
        new MistralAIChatCompletionService(modelId, apiKey, endpoint, HttpClientProvider.GetHttpClient(serviceProvider)));
}

What am I missing?

@RogerBarreto
Copy link
Member

RogerBarreto commented Apr 19, 2025

@donatas-xyz, HttpClientProvider.GetHttpClient(serviceProvider) attempts to get it using the serviceProvider.GetService<HttpClient>();

If you don't have one registered it will create a new HttpClient without the header setting. Without the header setting you may see the same error.

The PR #11646 will fix this.

@RogerBarreto RogerBarreto removed python Pull requests for the Python Semantic Kernel triage labels Apr 19, 2025
@RogerBarreto RogerBarreto moved this to Community PRs in Semantic Kernel Apr 22, 2025
@RogerBarreto RogerBarreto moved this from Community PRs to Sprint: In Review in Semantic Kernel Apr 22, 2025
@RogerBarreto RogerBarreto added the ai connector Anything related to AI connectors label Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai connector Anything related to AI connectors .NET Issue or Pull requests regarding .NET code
Projects
Status: Sprint: In Review
Development

Successfully merging a pull request may close this issue.

5 participants