tmc / langchaingo

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

Add metadata fields in OpenAI calls #811

Closed lowjiansheng closed 2 months ago

lowjiansheng commented 2 months ago

PR Checklist

There are OpenAI servers (like LiteLLM) that takes in additional metadata in their requests to log additional information. In LiteLLM's case, the metadata field is used to store information like custom tags and trace ids which will be propagated to Langfuse.

In Langchain Python, there are model_kwargs argument to achieve this, however it's difficult to add kwargs to structs for deserialization in Go. Therefore we'll need to hardcode a metadata field here.