Download basic_chat.py from Mummar/lstm: direct link, hf CLI and curl.
- Browser
- Download file 640 Bytes
-
https://huggingface.co/spaces/Mummar/lstm/resolve/main/basic_chat.py
- Command line
-
hf download hf://spaces/Mummar/lstm/basic_chat.py
-
curl -L -o basic_chat.py https://huggingface.co/spaces/Mummar/lstm/resolve/main/basic_chat.py
640 Bytes
| %%writefile server_app.py | |
| # https://python.langchain.com/docs/langserve#server | |
| from fastapi import FastAPI | |
| from langchain.prompts import ChatPromptTemplate | |
| from langchain_nvidia_ai_endpoints import ChatNVIDIA | |
| from langserve import add_routes | |
| llm = ChatNVIDIA(model="mixtral_8x7b") | |
| app = FastAPI( | |
| title="LangChain Server", | |
| version="1.0", | |
| description="A simple api server using Langchain's Runnable interfaces", | |
| ) | |
| add_routes( | |
| app, | |
| llm, | |
| path="/basic_chat", | |
| ) | |
| ## Might be encountered if this were for a standalone python file... | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run(app, host="0.0.0.0", port=9012) |