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

community: Fix a validation error for MoonshotChat #27801

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

twang2218
Copy link
Contributor

In PR #17100, the implementation for Moonshot was added, which defined two classes:

  • MoonshotChat(MoonshotCommon, ChatOpenAI) in langchain_community.chat_models.moonshot;
    • Here, validate_environment() assigns client as openai.OpenAI().chat.completions
      • Note that client here is actually a member variable defined in ChatOpenAI;
  • MoonshotCommon in langchain_community.llms.moonshot;
    • And here, validate_environment() assigns _client as _MoonshotClient;
      • Note that this is the underscored _client, which is defined within MoonshotCommon itself;

At this time, there was no conflict between the two, one being client and the other _client.

However, in PR #25878 which fixed #24390, _client in MoonshotCommon was changed to client. Since then, a conflict in the definition of client has arisen between MoonshotCommon and MoonshotChat, which caused pydantic validation error.

To fix this issue, the type of client in MoonshotCommon should be changed to Any.

In PR langchain-ai#17100, the implementation for Moonshot was added, which defined two classes:

- `MoonshotChat(MoonshotCommon, ChatOpenAI)` in `langchain_community.chat_models.moonshot`;
  - Here, `validate_environment()` assigns **client** as `openai.OpenAI().chat.completions`
    - Note that **client** here is actually a member variable defined in `ChatOpenAI`;
- `MoonshotCommon` in `langchain_community.llms.moonshot`;
  - And here, `validate_environment()` assigns **_client** as `_MoonshotClient`;
    - Note that this is the underscored **_client**, which is defined within `MoonshotCommon` itself;

At this time, there was no conflict between the two, one being `client` and the other `_client`.

However, in PR langchain-ai#25878 which fixed langchain-ai#24390, `_client` in `MoonshotCommon` was changed to `client`. Since then, a conflict in the definition of `client` has arisen between `MoonshotCommon` and `MoonshotChat`, which caused `pydantic` validation error.

To fix this issue, the type of `client` in `MoonshotCommon` should be changed to `Any`.

Signed-off-by: Tao Wang <[email protected]>
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Oct 31, 2024
Copy link

vercel bot commented Oct 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 5:02pm

@dosubot dosubot bot added community Related to langchain-community 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Oct 31, 2024
@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Oct 31, 2024
@ccurme ccurme merged commit 25a1031 into langchain-ai:master Oct 31, 2024
18 checks passed
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 community Related to langchain-community lgtm PR looks good. Use to confirm that a PR is ready for merging. size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
Archived in project
2 participants