Skip to content

[Feature Request] Minimax M2 support #3334

@hzzhyj

Description

@hzzhyj

Required prerequisites

Motivation

model = ModelFactory.create(
    api_key="minimax_api_key",
    model_platform=ModelPlatformType.ANTHROPIC,
    model_type="MiniMax-M2",
    url="https://api.minimax.io/anthropic",
)

So in minimax official website they are saying we should use anthropic. But this is not working

Instead, if we do the following

import anthropic

client = anthropic.Anthropic(
    base_url="https://api.minimax.io/anthropic",
    api_key="minimax_api_key",  # Your MiniMax API Key
)

message = client.messages.create(
    model="MiniMax-M2",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}],
)

print(message)

it works. Can we add support for this provider and this model?

See https://platform.minimax.io/docs/guides/text-generation

Solution

No response

Alternatives

No response

Additional context

Traceback

Traceback (most recent call last):
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/agents/chat_agent.py", line 2248, in _aget_model_response
    response = await self.model_backend.arun(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/models/model_manager.py", line 287, in arun
    raise exc
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/models/model_manager.py", line 274, in arun
    response = await self.current_model.arun(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/models/base_model.py", line 480, in arun
    result = await self._arun(messages, response_format, tools)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/models/openai_compatible_model.py", line 267, in _arun
    result = await self._arequest_chat_completion(messages, tools)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/models/anthropic_model.py", line 175, in _arequest_chat_completion
    return await super()._arequest_chat_completion(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/models/openai_compatible_model.py", line 297, in _arequest_chat_completion
    return await self._async_client.chat.completions.create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/openai/resources/chat/completions/completions.py", line 2585, in create
    return await self._post(
           ^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/openai/_base_client.py", line 1794, in post
    return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/openai/_base_client.py", line 1594, in request
    raise self._make_status_error_from_response(err.response) from None
openai.NotFoundError: <html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
Traceback (most recent call last):
  File "/Users/hzzhyj/neuromesh/sugar_backend/z_test_files/test_gemini.py", line 490, in <module>
    response = asyncio.run(client.astep(query))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/agents/chat_agent.py", line 1946, in astep
    return await self._astep_non_streaming_task(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/agents/chat_agent.py", line 2008, in _astep_non_streaming_task
    response = await self._aget_model_response(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/agents/chat_agent.py", line 2248, in _aget_model_response
    response = await self.model_backend.arun(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/models/model_manager.py", line 287, in arun
    raise exc
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/models/model_manager.py", line 274, in arun
    response = await self.current_model.arun(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/models/base_model.py", line 480, in arun
    result = await self._arun(messages, response_format, tools)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/models/openai_compatible_model.py", line 267, in _arun
    result = await self._arequest_chat_completion(messages, tools)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/models/anthropic_model.py", line 175, in _arequest_chat_completion
    return await super()._arequest_chat_completion(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/camel/models/openai_compatible_model.py", line 297, in _arequest_chat_completion
    return await self._async_client.chat.completions.create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/openai/resources/chat/completions/completions.py", line 2585, in create
    return await self._post(
           ^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/openai/_base_client.py", line 1794, in post
    return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hzzhyj/neuromesh/sugar_backend/venv/lib/python3.11/site-packages/openai/_base_client.py", line 1594, in request
    raise self._make_status_error_from_response(err.response) from None
openai.NotFoundError: <html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions