Replies: 1 comment
-
Hello, @eeleedev! I'm here to assist you with any bugs, questions, or contributions. Let's tackle this together while we wait for a human maintainer. To modify the from langchain_core.output_parsers import StrOutputParser
def ask_question(self, question, show_sources=False):
"""Ask a question and return only the model's response."""
try:
# Get the answer from the chain
res = self.qa(question)
response = res["result"]
# Use StrOutputParser to extract and return only the model's response
parser = StrOutputParser()
answer = parser.parse(response)
print("answer:", answer)
return answer
except Exception as e:
logging.error(f"Error in ask_question: {e}")
raise e This modification ensures that the |
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 am using Langchain v0.2 for a project involving a question-answering application. The ask_question method is expected to return only the model's answer to a given question. However, the current output includes additional information such as system instructions (SYS) and context metadata. I want to modify the output to return only the model's response without the extraneous information. Here is an example of the current output:
I need guidance on how to extract only the model's response (LLM answer...) from this output format.
System Info
System Information
Package Information
Beta Was this translation helpful? Give feedback.
All reactions