Following Build A Chatbot Tutorial: SystemMessage Error in Trimming #24006
Unanswered
Miguel-Adarlo
asked this question in
Q&A
Replies: 1 comment
-
Did you figured out something? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I'm trying to follow the tutorial on Langchain Chatbots. I'm at the trimming part. I run into this error:
`
ValueError Traceback (most recent call last)
File /Users/xxxxxx/Documents/VINA-FRIDAY/ChatbotTest.py:69
50 messages = [
51 SystemMessage(content="you're a good assistant"), #kept this
52 HumanMessage(content="hi! I'm bob"),
(...)
61 AIMessage(content="yes!"),
62 ]
63 chain = (
64 RunnablePassthrough.assign(messages=itemgetter("messages") | trimmer)
65 | prompt
66 | model
67 )
---> 69 response = chain.invoke(
70 {
71 "messages": messages + [HumanMessage(content="what's my name?")],
72 "language": "English",
73 }
74 )
File ~/anaconda3/envs/VINA-FRIDAY/lib/python3.11/site-packages/langchain_core/runnables/base.py:2499, in RunnableSequence.invoke(self, input, config, **kwargs)
2497 input = step.invoke(input, config, **kwargs)
2498 else:
-> 2499 input = step.invoke(input, config)
...
257 "Detected more than one SystemMessage in the list of messages."
258 "Gemini APIs support the insertion of only one SystemMessage."
259 )
ValueError: SystemMessage should be the first in the history.
`
When trying to reset the prompt to not have a system message, it doesn't work. I still have the same error.
System Info
langchain==0.2.7
langchain-community==0.2.6
langchain-core==0.2.12
langchain-google-vertexai==1.0.6
langchain-text-splitters==0.2.2
Mac
Python 3.11
Beta Was this translation helpful? Give feedback.
All reactions