Skip to content
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

Update default values of minimax_api_host and model in MiniMaxChat __init__ #29278

Open
5 tasks done
jsmerix opened this issue Jan 17, 2025 · 0 comments
Open
5 tasks done
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@jsmerix
Copy link

jsmerix commented Jan 17, 2025

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

The following code:

from langchain_community.chat_models import MiniMaxChat

api_key = "YOUR_API_KEY"
chat = MiniMaxChat(api_key=api_key)
messages = [
    ("human", "Hello, how are you?"),
]

resp = chat.invoke(messages)
print(resp)

Error Message and Stack Trace (if applicable)

Traceback (most recent call last):
  File "/home/work/langchain/bug_report.py", line 13, in <module>
    resp = chat.invoke(messages)
  File "/home/work/langchain/venv/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 286, in invoke
    self.generate_prompt(
  File "/home/work/langchain/venv/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 786, in generate_prompt
    return self.generate(prompt_messages, stop=stop, callbacks=callbacks, **kwargs)
  File "/home/work/langchain/venv/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 643, in generate
    raise e
  File "/home/work/langchain/venv/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 633, in generate
    self._generate_with_cache(
  File "/home/work/langchain/venv/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py", line 851, in _generate_with_cache
    result = self._generate(
  File "/home/work/langchain/venv/lib/python3.10/site-packages/langchain_community/chat_models/minimax.py", line 515, in _generate
    return self._create_chat_result(response.json())
  File "/home/work/langchain/venv/lib/python3.10/site-packages/langchain_community/chat_models/minimax.py", line 429, in _create_chat_result
    for res in response["choices"]:
KeyError: 'choices'

Description

  • I am trying to run MiniMaxChatusing default settings
  • The underlying problem is that the default values for parameters do not work
    • minimax_api_host is https://api.minimax.chat/v1/text/chatcompletion_v2, whereas it should be https://api.minimaxi.chat/v1/text/chatcompletion_v2 (note the i -> minimax -> minimaxi)
    • model is abab6.5-chat, whereas it should be abab6.5s-chat (note the s)
    • Consequently, the received response is not a succesful one, so the choices key is not present in it
  • Using overriden parameters MiniMaxChat(api_key=api_key, model="abab6.5s-chat", minimax_api_host="https://api.minimaxi.chat/v1/text/chatcompletion_v2") yields successful result
  • Additionally there is a problem with the code itself at the point of the raised exception. It's difficult to comprehend for a user why the KeyError was raised - but that is for another issue probably.
    • In my opinion, it would be better to fail early with an informative error message - invalid API key, insufficient balance, invalid model name etc.

System Info

python -m langchain_core.sys_info yields:

System Information
------------------
> OS:  Linux
> OS Version:  #52~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Dec  9 15:00:52 UTC 2
> Python Version:  3.10.12 (main, Nov  6 2024, 20:22:13) [GCC 11.4.0]

Package Information
-------------------
> langchain_core: 0.3.30
> langchain: 0.3.14
> langchain_community: 0.3.14
> langsmith: 0.2.11
> langchain_minimax: Installed. No version info available.
> langchain_openai: 0.3.0
> langchain_text_splitters: 0.3.5

Optional packages not installed
-------------------------------
> langserve

Other Dependencies
------------------
> aiohttp: 3.11.11
> async-timeout: 4.0.3
> dataclasses-json: 0.6.7
> httpx: 0.28.1
> httpx-sse: 0.4.0
> jsonpatch: 1.33
> langsmith-pyo3: Installed. No version info available.
> numpy: 1.26.4
> openai: 1.59.8
> orjson: 3.10.14
> packaging: 24.2
> pydantic: 2.10.5
> pydantic-settings: 2.7.1
> PyYAML: 6.0.2
> requests: 2.32.3
> requests-toolbelt: 1.0.0
> SQLAlchemy: 2.0.37
> tenacity: 9.0.0
> tiktoken: 0.8.0
> typing-extensions: 4.12.2
> zstandard: Installed. No version info available.
@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant