cnmoro commited on
Commit
b480514
·
verified ·
1 Parent(s): 99b37ed

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -81,7 +81,7 @@ async def predict(message, history):
81
  async with aiohttp.ClientSession() as session:
82
  async with session.post(url, headers=headers, json=body) as response:
83
 
84
- buffer = "" # A buffer to hold incomplete lines of SSE data
85
  async for chunk in response.content.iter_any():
86
  buffer += chunk.decode()
87
  while "\n" in buffer: # Process as long as there are complete lines in the buffer
@@ -101,8 +101,8 @@ async def predict(message, history):
101
  full_response += current_text
102
  yield full_response
103
  await asyncio.sleep(0.01)
104
- except Exception as e:
105
- print(e)
106
 
107
  final_metadata_block = ""
108
 
@@ -116,11 +116,10 @@ async def predict(message, history):
116
 
117
  yield f"{full_response}\n\n{final_metadata_block}"
118
 
119
- # Setting up the Gradio chat interface.
120
  gr.ChatInterface(
121
  predict,
122
- title="Web Search with LLM !",
123
- description="Ask any question, and I will try to answer it using web search !",
124
  retry_btn=None,
125
  undo_btn=None,
126
  examples=[
@@ -129,4 +128,4 @@ gr.ChatInterface(
129
  'What is the capital of France?',
130
  'Why does Brazil has a high tax rate?'
131
  ]
132
- ).launch() # Launching the web interface.
 
81
  async with aiohttp.ClientSession() as session:
82
  async with session.post(url, headers=headers, json=body) as response:
83
 
84
+ buffer = "" # A buffer to hold incomplete lines of data
85
  async for chunk in response.content.iter_any():
86
  buffer += chunk.decode()
87
  while "\n" in buffer: # Process as long as there are complete lines in the buffer
 
101
  full_response += current_text
102
  yield full_response
103
  await asyncio.sleep(0.01)
104
+ except Exception:
105
+ pass
106
 
107
  final_metadata_block = ""
108
 
 
116
 
117
  yield f"{full_response}\n\n{final_metadata_block}"
118
 
 
119
  gr.ChatInterface(
120
  predict,
121
+ title="Web Search with LLM",
122
+ description="Ask any question, and I will try to answer it using web search",
123
  retry_btn=None,
124
  undo_btn=None,
125
  examples=[
 
128
  'What is the capital of France?',
129
  'Why does Brazil has a high tax rate?'
130
  ]
131
+ ).launch()