Damien Benveniste commited on
Commit
e13658e
·
1 Parent(s): 6c7011f
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -2,6 +2,7 @@
2
  import os
3
  from fastapi import FastAPI, Request, Response
4
  from langserve import APIHandler
 
5
  from langchain_huggingface import HuggingFaceEndpoint
6
 
7
  app = FastAPI()
@@ -18,6 +19,11 @@ llm = HuggingFaceEndpoint(
18
  api_handler = APIHandler(llm, path="/stream")
19
 
20
 
 
 
 
 
21
  @app.post("/stream")
22
- async def simple_stream(request: Request):
23
- return await api_handler.stream(request)
 
 
2
  import os
3
  from fastapi import FastAPI, Request, Response
4
  from langserve import APIHandler
5
+ from pydantic import BaseModel
6
  from langchain_huggingface import HuggingFaceEndpoint
7
 
8
  app = FastAPI()
 
19
  api_handler = APIHandler(llm, path="/stream")
20
 
21
 
22
+ class InputRequest(BaseModel):
23
+ input: str
24
+
25
+
26
  @app.post("/stream")
27
+ async def simple_stream(request: InputRequest):
28
+
29
+ return await api_handler.stream(request.input)