Spaces:
Sleeping
Sleeping
| from langserve import RemoteRunnable | |
| # Hit our enpoint with specified rout | |
| # If we put /simple/stream, it complains; because chain.stream will hit /simple/stream endpoint | |
| url = "https://simafarazi-backend-c.hf.space/simple/" | |
| chain = RemoteRunnable(url) #Client for iteracting with LangChain runnables that are hosted as LangServe endpoints | |
| stream = chain.stream(input={'question':'How are you?'}) # .stream() and .invoke() are standard methods to interact with hosted runnables | |
| for chunk in stream: # Each chunk corresponds to a token/word | |
| #end="": prints worlds one after each other, an not in a separate lines | |
| #flush=True: prints world to the screen immidiately without any buffer | |
| print(chunk, end="", flush=True) | |