Skip to content

Commit

Permalink
Enforce trailing slash in the client (#126)
Browse files Browse the repository at this point in the history
Would resolve the error in #125

---------

Co-authored-by: Eugene Yurtsev <[email protected]>
  • Loading branch information
hinthornw and eyurtsev authored Oct 30, 2023
1 parent 7be2927 commit a94b666
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions langserve/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ def _batch(

return outputs

def _enforce_trailing_slash(self, url: str) -> str:
if url.endswith("/"):
return url
return url + "/"

def batch(
self,
inputs: List[Input],
Expand Down Expand Up @@ -459,7 +464,7 @@ def stream(
"config": _without_callbacks(config),
"kwargs": kwargs,
}
endpoint = urljoin(self.url, "stream")
endpoint = urljoin(self._enforce_trailing_slash(self.url), "stream")

try:
from httpx_sse import connect_sse
Expand Down Expand Up @@ -522,7 +527,7 @@ async def astream(
"config": _without_callbacks(config),
"kwargs": kwargs,
}
endpoint = urljoin(self.url, "stream")
endpoint = urljoin(self._enforce_trailing_slash(self.url), "stream")

try:
from httpx_sse import aconnect_sse
Expand Down

0 comments on commit a94b666

Please sign in to comment.