Replies: 1 comment
-
Hey there, @Nithin745! I'm here to help you with any bugs, questions, or contributions. Let's work together to solve the issue you're facing. To resolve the issue of concatenated messages and get only the AI's response in the output, you can use the
Here is the relevant code: from langchain_core.messages import AIMessage
from langchain.agents.output_parsers.openai_functions import OpenAIFunctionsAgentOutputParser
# Create an AIMessage
msg = AIMessage(content="Model response.")
# Parse the AIMessage
parser = OpenAIFunctionsAgentOutputParser()
result = parser._parse_ai_message(msg)
# Extract the response
response = result.return_values["output"]
print(response) This will ensure that only the AI's response string is returned in the output [1][2][3]. |
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
-
Checked other resources
Commit to Help
Example Code
Description
I am using langchain to create sql agent that will write and execute query and give me the results, but for some reason instead of giving me the results only in the output it is concatenating systemMessage + HumanMessage + AIMessage as a single string, so i even tried one tutorial from langchain for still im facing the same issue
this is the code i followed => https://python.langchain.com/v0.2/docs/how_to/migrate_agent/#in-langgraph-4
and this is the output i got.
System Info
langchain==0.2.6
langchain-chroma==0.1.1
langchain-community==0.2.6
langchain-core==0.2.10
langchain-huggingface==0.0.3
langchain-openai==0.1.11
langchain-text-splitters==0.2.2
langchainhub==0.1.20
platform (linux )
python version = 3.12
Beta Was this translation helpful? Give feedback.
All reactions