SimaFarazi commited on
Commit
91a4394
1 Parent(s): 4790e1f

clean up main for only simple stream app

Browse files
Files changed (1) hide show
  1. app_simple_stream/app/main.py +5 -11
app_simple_stream/app/main.py CHANGED
@@ -13,17 +13,11 @@ from chains import simple_chain
13
  app = FastAPI()
14
 
15
  # Generate stream of data
16
- async def generate_stream(
17
- input_data: schemas.BaseModel,
18
- runnable: Runnable,
19
- callbacks: List[BaseCallbackHandler]=[]
20
- ):
21
- for output in runnable.stream(
22
- input_data.dict(), config={"callbacks": callbacks}
23
- ):
24
- data = WellKnownLCSerializer().dumps(output).decode("utf-8") # Decode data
25
- yield {'data': data, "event": "data"}
26
- yield {"event": "end"}
27
 
28
 
29
  @app.post("/simple/stream")
 
13
  app = FastAPI()
14
 
15
  # Generate stream of data
16
+ async def generate_stream(input_data: schemas.BaseModel, runnable: Runnable, callbacks: List[BaseCallbackHandler]=[]):
17
+ for output in runnable.stream(input_data.dict(), config={"callbacks": callbacks}):
18
+ data = WellKnownLCSerializer().dumps(output).decode("utf-8") # Decode data
19
+ yield {'data': data, "event": "data"}
20
+ yield {"event": "end"}
 
 
 
 
 
 
21
 
22
 
23
  @app.post("/simple/stream")