tmc / langchaingo

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

The problem with FunctionDefinition struct #875

Open ImPedro29 opened 3 weeks ago

ImPedro29 commented 3 weeks ago

Problem

The structure of the FunctionDefinition still uses any type of parameter, the code is not as modular when it allows it. This creates a problem forcing the client to implement a function call interface for each provider. https://github.com/tmc/langchaingo/blob/03b74ec5c76370198108c00a64c36f33d10c9601/llms/options.go#L81

Context

I will need to implement this modularity for the application I am building and I am happy to leave this thing open source. I'm opening this issue because I'm not sure of the motivations for the code to be written this way.

Possible Solution 1

I believe we can have a fixed model for all llms, as in general, we want to achieve the same result. I don't really like this solution, but it should solve the problem in the short term.

Possible Solution 2

Another proposal would be to create an interface for the parameters where each llm will implement its own structure, the interface only guarantees that they all share mandatory methods, such as the name of the parameters

Let's discuss

tmc commented 2 weeks ago

Can you be a bit more specific in your proposed solution?