-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
ValueError: Got unexpected message type: AIMessageChunk #804
Comments
I Just had the same error and found this via Google search. Running the most recent version of gpt-engineer and have previous had other versions work in my WSL setup on this same box. /home/pb/venvs/v1/lib/python3.11/site-packages/langchain/schema/messages.py:336 in │ |
same error I got, but it looks like langchain issue |
Same here. Anything I can do ? |
I'm a little confused, is this the same problem as in #802 ? |
I traced the error back a little bit to a missing handler in elif _type == "AIMessageChunk":
return AIMessageChunk(**message["data"]) The whole function now looks like this: def _message_from_dict(message: dict) -> BaseMessage:
_type = message["type"]
if _type == "human":
return HumanMessage(**message["data"])
elif _type == "ai":
return AIMessage(**message["data"])
elif _type == "system":
return SystemMessage(**message["data"])
elif _type == "chat":
return ChatMessage(**message["data"])
elif _type == "function":
return FunctionMessage(**message["data"])
elif _type == "AIMessageChunk":
return AIMessageChunk(**message["data"])
else:
raise ValueError(f"Got unexpected message type: {_type}") |
I think how |
Fixed it for me on mac.
|
@wwencel @0x1pikachu The stack trace |
@pralad-p agreed. |
This also fixed the problem for me on Mac. Please consider integrating this into the code. |
@MWals @ibrahim-sowunmi @paulternate |
A direct fix here, instead of modifying langchain, is probably to downgrade the langchain version in your environment. |
This is now addressed in PR #833 by restricting the langchain version. Reinstalling from main branch source should solve it. |
… breaks message history runnable. (#15327) - **Description:** fix parse issue for AIMessageChunk when using - **Issue:** #14511 - **Dependencies:** none - **Twitter handle:** none Taken from this fix: gpt-engineer-org/gpt-engineer#804 (comment) Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` from the root of the package you've modified to check this locally. See contribution guidelines for more information on how to write/run tests, lint, etc: https://python.langchain.com/docs/contributing/ If you're adding a new integration, please include: 1. a test for the integration, preferably unit tests that do not rely on network access, 2. an example notebook showing its use. It lives in `docs/docs/integrations` directory. If no one reviews your PR within a few days, please @-mention one of @baskaryan, @eyurtsev, @hwchase17. --------- Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
the update from this issue landed in upstream langchain really quickly... langchain-ai/langchain#15327. credit to @paulternate |
Policy and info
Expected Behavior
I typed in a prompt after setting it up. When it responds with clarifying questions, I expect to be able to respond.
Current Behavior
It fails with the error message in the title.
Failure Information
Windows, GPT-4, CMD,
Steps to Reproduce
If possible, provide detailed steps for reproducing the issue.
Failure Logs
│ s.py:336 in _message_from_dict │
│ │
│ 333 │ elif _type == "function": │
│ 334 │ │ return FunctionMessage(**message["data"]) │
│ 335 │ else: │
│ ❱ 336 │ │ raise ValueError(f"Got unexpected message type: {_type}") │
│ 337 │
│ 338 │
│ 339 def messages_from_dict(messages: List[dict]) -> List[BaseMessage]: │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ _type = 'AIMessageChunk' │ │
│ │ message = { │ │
│ │ │ 'type': 'AIMessageChunk', │ │
│ │ │ 'data': { │ │
│ │ │ │ 'content': 'Summary of areas that need clarification:\n\n1. The specific │ │
│ │ type of reinforcement'+377, │ │
│ │ │ │ 'additional_kwargs': {}, │ │
│ │ │ │ 'type': 'AIMessageChunk', │ │
│ │ │ │ 'example': False │ │
│ │ │ } │ │
│ │ } │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: Got unexpected message type: AIMessageChunk
The text was updated successfully, but these errors were encountered: