tmc / langchaingo

LangChain for Go, the easiest way to write LLM-based programs in Go
https://tmc.github.io/langchaingo/
MIT License
3.73k stars 518 forks source link

examples: Add use of Defined outputparser in LLMChain #929

Open erictse opened 6 days ago

erictse commented 6 days ago

Note to maintainers

Hi, @tmc!

While this example works, there are a number of issues I have that you can help walk me through.

  1. LLMChain doesn't consider the outputparser's format instructions when sending the prompt. It seems a good solution should, but that might be a departure from Python LangChain (not sure) and would need consideration on how to not break things.
  2. There's a type assertion to extract the output struct from the outputparser which is unwieldy and unexpected necessary due to https://github.com/tmc/langchaingo/blob/main/chains/llm.go#L53 where the map value must be type any.

For both these issues, I'm not sure I see a solution that behaves like LangChain yet is practical. It leads me to wonder, as far would you be interested in deviating from LangChain and building what is optimal based on both Go and the technical opinions by leadership on this project?

PR Checklist