brainlid / langchain

Elixir implementation of an AI focused LangChain style framework.
https://hexdocs.pm/langchain/
Other
571 stars 68 forks source link

Wrap Anthropic message when processing response #98

Closed yujonglee closed 5 months ago

yujonglee commented 5 months ago

This line cause problem for current Anthropic implementation:

https://github.com/brainlid/langchain/blob/1dab891c48d26f0127991c784e6a2bb7f1050188/lib/utils.ex#L109

This PR fix it by wrapping message.

brainlid commented 5 months ago

Thanks! I like the fix. Can you update the PR to not include the formatting changes? Yes, they are valid formatting changes, however, they are not related to the 1 line fix.

yujonglee commented 5 months ago

@brainlid makes sense. just did that!

brainlid commented 5 months ago

Thanks! ❤️💛💙💜

I ended up solving it a different way by updating Utils.fire_callback. The spec for fire_callback should allow for a non-list, and I think that's right. I didn't want converting a single message to return a list of 1 messages either.

But this pointed out that I was missing some test coverage, which I've also addressed.