Closed jlev closed 3 months ago
( I just removed my last comment β after looking at the suggested code change )
Thanks for suggesting this @jlev βΒ It's an important one, indeed.
In order to enable developers to provide headers to LangServe
, here is a suggested way:
The usage should be as per following:
const [customHeaders, setCustomHeaders] = useState<LangServeHeaders>({ key: 'value' });
const adapter = useChatAdapter({
url: 'https://<Your LangServe Runnable URL>',
headers: customHeaders
});
LangServeHeaders
should be addedheaders
should be added to LS adapter optionsuseChatAdapter
should be updated to support the new attributeHere are few hints to assist in implementing the change
packages/js/langchain
of the adapter:LangServeHeaders
type hereheaders
option to add to ChatAdapterOptions
headers
option in React Hooks:useChatAdapter
hook to enable supplying the headers
option when it's providedheaders
in the LangServeAbstractAdapter
β similar to get endpointUrl()
fetch
and stream
LangServe adapters to access headers (via this.headers) and add them to the fetch request.Give it a try and let me know @jlev β I'll keep an eye on Discord to answer any question and assist. I'm assigning this issue to you, since I feel like you'll handle it π
I'd starting to production-ize my LLM with NLUX and Langserve. Is there a way to set authorization headers for the adapter? I am using streaming mode, and I'd like to require an auth0 token with each request.
https://github.com/nluxai/nlux/blob/latest/packages/js/langchain/src/langserve/adapter/stream.ts#L22
Should I make a custom adapter, or is this something that could be passed into the ChatAdapterExtras, like it is for NLBridge?