sudiptaverse commited on
Commit
e5c1cdd
·
verified ·
1 Parent(s): 3880b7e

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  from fastapi import FastAPI
3
  from langserve import add_routes
4
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
@@ -50,7 +49,7 @@ generator = pipeline(
50
  # LangChain pipeline
51
  llm = HuggingFacePipeline(pipeline=generator)
52
  prompt = ChatPromptTemplate.from_template(
53
- """Instruction:
54
  Explain this Python code step-by-step:
55
  Use code with caution
56
  {code}
@@ -64,3 +63,7 @@ chain = prompt | llm | parser
64
  # Add route
65
  add_routes(app, chain, path="/explain")
66
 
 
 
 
 
 
 
1
  from fastapi import FastAPI
2
  from langserve import add_routes
3
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
 
49
  # LangChain pipeline
50
  llm = HuggingFacePipeline(pipeline=generator)
51
  prompt = ChatPromptTemplate.from_template(
52
+ """Instruction:
53
  Explain this Python code step-by-step:
54
  Use code with caution
55
  {code}
 
63
  # Add route
64
  add_routes(app, chain, path="/explain")
65
 
66
+ # Run server (necessary for Hugging Face Spaces)
67
+ if __name__ == "__main__":
68
+ import uvicorn
69
+ uvicorn.run("app:app", host="0.0.0.0", port=7860)