Replies: 1 comment
-
Hey there, @cptnanon! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this together while we wait for a human maintainer.
To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
We have a custom proxied endpoints for our LLMs (OpenAI, Gemini & Anthropic) that requires its own authentication and specialized request handling. The official LangChain.js documentation recommends creating custom LLMs by overriding the
_generate
method. However, doing so forces us to reimplement various utility functions to convert between internal message formats and client responses.To avoid duplicating all this conversion logic, we're exploring an alternative approach: overriding the
completionWithRetry
method in a subclass ofChatOpenAI
. By doing so, we can simply swap out the HTTP request logic to call our custom, authenticated endpoint, while still leveraging all of LangChain.js’s built-in message conversion utilities and callback integrations.Additionally, we're wondering whether this approach is applicable to other models (such as Gemini) that might require similar customizations, or if there are any potential pitfalls (e.g., streaming, token tracking, or callback compatibility issues) with deviating from the recommended
_generate
override.My Questions:
completionWithRetry
rather than_generate
—for integrating a custom, authenticated REST endpoint?_generate
, given that it avoids duplicating message conversion logic?System Info
[email protected]
Beta Was this translation helpful? Give feedback.
All reactions