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

langchain moonshotChat exmaple didn't work #27058

Open
5 tasks done
newday1 opened this issue Oct 3, 2024 · 0 comments
Open
5 tasks done

langchain moonshotChat exmaple didn't work #27058

newday1 opened this issue Oct 3, 2024 · 0 comments
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@newday1
Copy link

newday1 commented Oct 3, 2024

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

from langchain_community.chat_models.moonshot import MoonshotChat
from langchain_core.messages import HumanMessage, SystemMessage
import os

Generate your api key from: https://platform.moonshot.cn/console/api-keys

os.environ["MOONSHOT_API_KEY"] = "xxxxx"

chat = MoonshotChat()

messages = [
SystemMessage(
content="You are a helpful assistant that translates English to French."
),
HumanMessage(
content="Translate this sentence from English to French. I love programming."
),
]

chat.invoke(messages)

Error Message and Stack Trace (if applicable)


ValidationError Traceback (most recent call last)
Cell In[5], line 6
2 from langchain_community.chat_models.moonshot import MoonshotChat
3 from langchain_core.messages import HumanMessage, SystemMessage
----> 6 chat = MoonshotChat()
8 messages = [
9 SystemMessage(
10 content="You are a helpful assistant that translates English to French."
(...)
14 ),
15 ]
17 response = chat.invoke(messages)

File c:\Users\eric\miniconda3\envs\myai\Lib\site-packages\langchain_core_api\deprecation.py:213, in deprecated..deprecate..finalize..warn_if_direct_instance(self, *args, **kwargs)
211 warned = True
212 emit_warning()
--> 213 return wrapped(self, *args, **kwargs)

File c:\Users\eric\miniconda3\envs\myai\Lib\site-packages\langchain_core\load\serializable.py:111, in Serializable.init(self, *args, **kwargs)
109 def init(self, *args: Any, **kwargs: Any) -> None:
110 """"""
--> 111 super().init(*args, **kwargs)

File c:\Users\eric\miniconda3\envs\myai\Lib\site-packages\pydantic\main.py:212, in BaseModel.init(self, **data)
...

ValidationError: 1 validation error for MoonshotChat
client
Input should be a valid dictionary or instance of _MoonshotClient [type=model_type, input_value=<openai.resources.chat.co...t at 0x000001B3AB6F9220>, input_type=Completions]
For further information visit https://errors.pydantic.dev/2.9/v/model_type
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

Description

I executed simple use cases from the official documentation, but they didn't work.

System Info

System Information

OS: Windows
OS Version: 10.0.22631
Python Version: 3.12.6 | packaged by conda-forge | (main, Sep 30 2024, 17:48:58) [MSC v.1941 64 bit (AMD64)]

Package Information

langchain_core: 0.3.8
langchain: 0.3.1
langchain_community: 0.3.1
langsmith: 0.1.130
langchain_text_splitters: 0.3.0

Optional packages not installed

langgraph
langserve

Other Dependencies

aiohttp: 3.10.8
async-timeout: Installed. No version info available.
dataclasses-json: 0.6.7
httpx: 0.27.2
jsonpatch: 1.33
numpy: 1.26.4
orjson: 3.10.7
packaging: 24.1
pydantic: 2.9.2
pydantic-settings: 2.5.2
PyYAML: 6.0.2
requests: 2.32.3
requests-toolbelt: 1.0.0
SQLAlchemy: 2.0.35
tenacity: 8.5.0
typing-extensions: 4.12.2

@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Oct 3, 2024
Swastik-Swarup-Dash added a commit to Swastik-Swarup-Dash/langchain that referenced this issue Oct 3, 2024
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