Spaces:
Running
Running
File size: 856 Bytes
605fc97 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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/history"
chain = RemoteRunnable(url) #Client for iteracting with LangChain runnables that are hosted as LangServe endpoints
stream = chain.stream(input={"question":"among these cities, which one is better to find a job for machine learning engineer?",
"username": "Sima"}) # .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)
|