Spaces:
Runtime error
Runtime error
Update ui.py
Browse files
ui.py
CHANGED
|
@@ -22,6 +22,7 @@ from init import (
|
|
| 22 |
gemini_api_key
|
| 23 |
)
|
| 24 |
from utils import push_to_hf_hub
|
|
|
|
| 25 |
|
| 26 |
def get_paper_by_year(year):
|
| 27 |
months = sorted(date_dict[year].keys())
|
|
@@ -249,12 +250,16 @@ async def chat_stream(idx, local_data, user_prompt, chat_state, ctx_num_lconv=3)
|
|
| 249 |
# 'repetition_penalty': 1.2
|
| 250 |
# }
|
| 251 |
# ):
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
|
| 259 |
def chat_reset(local_data, chat_state):
|
| 260 |
ppm = chat_state["ppmanager_type"].from_json(json.dumps(local_data))
|
|
|
|
| 22 |
gemini_api_key
|
| 23 |
)
|
| 24 |
from utils import push_to_hf_hub
|
| 25 |
+
gemini_init(gemini_api_key)
|
| 26 |
|
| 27 |
def get_paper_by_year(year):
|
| 28 |
months = sorted(date_dict[year].keys())
|
|
|
|
| 250 |
# 'repetition_penalty': 1.2
|
| 251 |
# }
|
| 252 |
# ):
|
| 253 |
+
try:
|
| 254 |
+
async for result in gemini_gen_text(prompt):
|
| 255 |
+
ppm.append_pong(result)
|
| 256 |
+
yield "", ppm.build_uis(), str(ppm), gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=False)
|
| 257 |
+
|
| 258 |
+
yield "", ppm.build_uis(), str(ppm), gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True)
|
| 259 |
+
except Exception as e:
|
| 260 |
+
gr.Warning(e)
|
| 261 |
+
ppm.append_pong("Gemini refused to answer. This happens becase there were some safety issues in the answer.")
|
| 262 |
+
yield "", ppm.build_uis(), str(ppm), gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True)
|
| 263 |
|
| 264 |
def chat_reset(local_data, chat_state):
|
| 265 |
ppm = chat_state["ppmanager_type"].from_json(json.dumps(local_data))
|