mitulagr2 commited on
Commit
bb7b1b4
·
1 Parent(s): e347d9f

Update main.py

Browse files
Files changed (1) hide show
  1. app/main.py +13 -9
app/main.py CHANGED
@@ -87,15 +87,19 @@ async def process_input(text: str):
87
  if text and len(text.strip()) > 0:
88
  text = text.strip()
89
  streaming_response = session_assistant.ask(text)
90
- # res.writeHead(200, {
91
- # 'Content-Type': 'text/event-stream',
92
- # 'Cache-Control': 'no-cache',
93
- # 'Content-Encoding': 'none',
94
- # 'Connection': 'keep-alive',
95
- # 'Access-Control-Allow-Origin': '*'
96
- # });
97
- # return StreamingResponse(astreamer(streaming_response.response_gen), media_type='text/event-stream')
98
- return StreamingResponse(streaming_response.response_gen)
 
 
 
 
99
 
100
 
101
  @app.post("/upload")
 
87
  if text and len(text.strip()) > 0:
88
  text = text.strip()
89
  streaming_response = session_assistant.ask(text)
90
+ headers = {
91
+ 'X-Content-Type-Options': 'nosniff',
92
+ 'Content-Type': 'text/event-stream',
93
+ 'Cache-Control': 'no-cache',
94
+ 'Content-Encoding': 'none',
95
+ 'Connection': 'keep-alive',
96
+ 'Access-Control-Allow-Origin': '*'
97
+ }
98
+ return StreamingResponse(
99
+ astreamer(streaming_response.response_gen),
100
+ headers=headers,
101
+ media_type='text/event-stream'
102
+ )
103
 
104
 
105
  @app.post("/upload")