Skip to content

Update of @langchain/mistralai necessary for using Mistral API in Autogen Studio #6147

@AlexKnowsIt

Description

@AlexKnowsIt

What happened?

Describe the bug
When using Autogen Studio with the Mistral API, the generated request payload includes an extra field ("name") inside the user object. The Mistral API only accepts "role" and "content" for user messages, so including the "name" field causes a HTTP 422 error ("Extra inputs are not permitted"). This issue causes all API calls to fail unless the extra field is removed.

To Reproduce

  1. Configure Autogen Studio with the following provider settings:
    {
      "provider": "autogen_ext.models.openai.OpenAIChatCompletionClient",
      "component_type": "model",
      "version": 1,
      "component_version": 1,
      "description": "Chat completion client for OpenAI hosted models.",
      "label": "OpenAIChatCompletionClient",
      "config": {
        "model": "mistral-small-latest",
        "model_info": {
          "family": "mistral",
          "model_name": "mistral-small-latest",
          "vision": false,
          "function_calling": true,
          "json_output": false
        },
        "api_key": "YOUR_API_KEY",
        "api_type": "mistral",
        "base_url": "https://api.mistral.ai/v1/"
      }
    }
  2. Trigger a chat completion request. The generated payload contains an object similar to:
    {
      "role": "user",
      "content": "Your prompt here",
      "name": "user"
    }
  3. The Mistral API responds with a HTTP 422 error:
    {
      "detail": [
        {
          "type": "extra_forbidden",
          "loc": ["body", "messages", 0, "user", "name"],
          "msg": "Extra inputs are not permitted",
          "input": "user"
        }
      ]
    }
    

Expected behavior
The API request payload should only include the "role" and "content" keys for the user object. With the correct payload structure, the Mistral API call should succeed without returning a 422 error.

Additional context
This issue has been addressed in the underlying library @langchain/mistralai, which in version 0.0.19 removes the extra "name" field from the request. Updating to version 0.0.19 resolves the problem.
Since Autogen Studio currently uses an older version, please update the dependency to @langchain/mistralai version 0.0.19 (or later) to ensure compatibility with the stricter validation rules of the Mistral API.

Feedback or further questions are welcome.

Which packages was the bug in?

AutoGen Studio (autogensudio)

AutoGen library version.

Python dev (main branch)

Other library version.

No response

Model used

All mistral models

Model provider

Mistral AI

Other model provider

No response

Python version

None

.NET version

None

Operating system

None

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions