langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Improvements to ConvoOutputParser and MessageHistory

Open Cobryis opened this issue 1 year ago β€’ 7 comments

  • Updated ConvoOutputParser to more robustly handle poorly formatted response scenarios from an LLM like GPT-3.5-Turbo.

  • Added a ActionBasedChatMessageHistory as an alternative to ChatMessageHistory to avoid prompt contamination caused by LLM reading its previous messages without proper formatting and then not correctly formatting future responses.

Cobryis avatar Apr 25 '23 02:04 Cobryis

Just wanted to add a comment that for ConvoOutputParser I did consider raising an exception if there was a json object in the response but it was missing the required fields. I opted not to do this because in general with this change I'm expecting incorrectly formatted responses from the LLM to be Final Answers. However, if the agent were able to receive and understand exceptions so it could correct itself, I might consider it better to raise the exception (though this would introduce higher token usage which I'm currently trying to avoid).

Cobryis avatar Apr 25 '23 18:04 Cobryis

Hi @Cobryis , I like your idea of customizing json decoder! Left some small comments. Will leave for the maintainers to decide. :)

btw, it looks like we don’t have test case for ConvoOutputParser yet. Will it be a good idea to add a test for it? Thanks!

skcoirz avatar Apr 28 '23 17:04 skcoirz

p

Yeah I think a test for it would be good. I'm currently working on a real application using this stuff so that's how I'm testing at the moment. When I have more free time I'd like to build more tests (or a notebook) mimicking what I have so that this stuff is less fragile.

Cobryis avatar Apr 28 '23 18:04 Cobryis

Author

Really cool. I'm doing the same and running into the same kind of error I think.

File "/app/output_parsers/CustomOutputParser.py", line 21, in parse
    raise ValueError(f"Could not parse LLM output: `{llm_output}`")
ValueError: Could not parse LLM output: `
Thought: Scan the repository and make a detailed analysis of it.
Action:
{
  "action": "TODO",
  "action_input": "Scan the repository you're in and make a detailed analysis of it. Then put it in a file called 'helloworld.md'"
}
`

I love this community is so active right now.

Ryangr0 avatar Apr 28 '23 19:04 Ryangr0

p

Yeah I think a test for it would be good. I'm currently working on a real application using this stuff so that's how I'm testing at the moment. When I have more free time I'd like to build more tests (or a notebook) mimicking what I have so that this stuff is less fragile.

echoing this, a small test suite would be AWESOME here

love this effort tho - thanks for improving this

hwchase17 avatar Apr 29 '23 04:04 hwchase17

image I added a very powerful bash agent, let me know if you are interested. I also allow it to make python / ruby/ any code available from thee env image

clockcoinG1 avatar Apr 30 '23 01:04 clockcoinG1

@hwchase17 Are you planning to merge this PR? I understand that you are working for a test suite.

arnabbiswas1 avatar May 09 '23 10:05 arnabbiswas1

Is this fix available ?

rickbraddy-pharma avatar May 17 '23 20:05 rickbraddy-pharma

hey, any update on this PR?

0xrjman avatar Aug 31 '23 20:08 0xrjman

It was abandoned

On Aug 31, 2023, at 3:38 PM, 0xrjman @.***> wrote:

ο»Ώ Caution: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. When in doubt, contact your IT Department

hey, any update on this PR?

β€” Reply to this email directly, view it on GitHubhttps://github.com/langchain-ai/langchain/pull/3480#issuecomment-1701748501, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AYDQ4EVABN4KKNGYHRUGJZTXYDY2XANCNFSM6AAAAAAXKL7RF4. You are receiving this because you commented.Message ID: @.***>

rickbraddy-pharma avatar Aug 31 '23 20:08 rickbraddy-pharma

@Cobryis Hi , could you, please, resolve the merging issues and address the last comments (if needed)? After that, ping me and I push this PR for the review. Thanks!

If this PR is not needed anymore, could you, please, let me know?

leo-gan avatar Sep 13 '23 01:09 leo-gan

@Cobryis Hi , could you, please, resolve the merging issues and address the last comments (if needed)? After that, ping me and I push this PR for the review. Thanks!

If this PR is not needed anymore, could you, please, let me know?

I'm not sure if it's not needed, but I'm not using it. It seems like some people would like this, though they're free to fork my change and get it to marge with the latest in langchain. I'm not using langchain anymore so really not sure what the code looks like now.

Cobryis avatar Sep 13 '23 01:09 Cobryis

@Cobryis Thanks for feedback! Thanks for your thoughts and effort! Really appreciated!

leo-gan avatar Sep 13 '23 01:09 leo-gan