langchain-ai / langserve

LangServe 🦜️🏓
Other
1.87k stars 206 forks source link

No need to specify word `invoke` at the end of the url #118

Closed robertoshimizu closed 10 months ago

robertoshimizu commented 10 months ago

It seems that adding the word invoke at the and of the url, it gets duplicated when hitting the server.

import { RemoteRunnable } from "langchain/runnables/remote";

const chain = new RemoteRunnable({
  url: `http://localhost:8000/chain/invoke/`,
});
const result = await chain.invoke({
  topic: "cats",
});

Here what I get when keeping the word invoke as per documentation: INFO: 192.168.0.147:52826 - "POST /chain/invoke/invoke HTTP/1.1" 404 Not Found

And here what I get when I supress the word invoke, i.e., url is just http://localhost:8000/chain/: INFO: 192.168.0.147:52848 - "POST /chain/invoke HTTP/1.1" 200 OK

It seems that when calling the method invoke, langserve already add the word invoke at the end of the url, under the hood. In conclusion, suggest to confirm if my observation makes sense, and if so, adjust the documentation. Best, Roberto

eyurtsev commented 10 months ago

@robertoshimizu that's correct you should not include invoke. The client appends the appropriate path sufffix (invoke/batch/stream) based on the method that you're using.

the client can do

chain.invoke chain.ainvoke chain.batch chain.abatch chain.stream chain.astream chain.astream_log

Would not be a good experience if changing between batch/stream/invoke required one to also modify the underlying URL.


Is there a good place in the documentation you'd like to see this in?

robertoshimizu commented 10 months ago

Thanks for the response Eugene.

I guess a good place would be exactly where it is today, i.e., where it is explained the Client methods to make the various calls. Just make sure the url is clean.

Best RS

eyurtsev commented 10 months ago

This fixed the issue: https://github.com/langchain-ai/langserve/pull/226

Sorry didn't put it together that that was the typescript example provided in the README