chore: update something
Browse files
app.py
CHANGED
|
@@ -384,7 +384,7 @@ def generate(
|
|
| 384 |
chat_history: list[tuple[str, str]],
|
| 385 |
allow_used_tools: bool = True,
|
| 386 |
system_prompt: str = "",
|
| 387 |
-
max_new_tokens: int =
|
| 388 |
temperature: float = 0.4,
|
| 389 |
top_p: float = 0.95,
|
| 390 |
top_k: int = 50,
|
|
@@ -468,12 +468,11 @@ def generate(
|
|
| 468 |
gr.Info("Searching for information on the Google.")
|
| 469 |
document_references = search_with_google(keyword)
|
| 470 |
|
|
|
|
|
|
|
|
|
|
| 471 |
input_ids = build_input_ids(
|
| 472 |
-
apply_tools=
|
| 473 |
-
True
|
| 474 |
-
if allow_used_tools is True and previous_response is None
|
| 475 |
-
else False
|
| 476 |
-
),
|
| 477 |
references=document_references,
|
| 478 |
)
|
| 479 |
streamer = TextIteratorStreamer(
|
|
@@ -505,12 +504,16 @@ def generate(
|
|
| 505 |
if state["mark"] is None:
|
| 506 |
state["mark"] = time.time()
|
| 507 |
outputs.append(text)
|
| 508 |
-
if
|
|
|
|
|
|
|
|
|
|
| 509 |
state["respond"] = True
|
| 510 |
yield "".join(outputs)
|
| 511 |
|
| 512 |
if (
|
| 513 |
-
|
|
|
|
| 514 |
and state["mark"] + waiting_tools_timeout > time.time()
|
| 515 |
):
|
| 516 |
gr.Info("Searching for information on the internet.")
|
|
|
|
| 384 |
chat_history: list[tuple[str, str]],
|
| 385 |
allow_used_tools: bool = True,
|
| 386 |
system_prompt: str = "",
|
| 387 |
+
max_new_tokens: int = 1536,
|
| 388 |
temperature: float = 0.4,
|
| 389 |
top_p: float = 0.95,
|
| 390 |
top_k: int = 50,
|
|
|
|
| 468 |
gr.Info("Searching for information on the Google.")
|
| 469 |
document_references = search_with_google(keyword)
|
| 470 |
|
| 471 |
+
apply_tools = (
|
| 472 |
+
True if allow_used_tools is True and previous_response is None else False
|
| 473 |
+
)
|
| 474 |
input_ids = build_input_ids(
|
| 475 |
+
apply_tools=apply_tools,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 476 |
references=document_references,
|
| 477 |
)
|
| 478 |
streamer = TextIteratorStreamer(
|
|
|
|
| 504 |
if state["mark"] is None:
|
| 505 |
state["mark"] = time.time()
|
| 506 |
outputs.append(text)
|
| 507 |
+
if (
|
| 508 |
+
apply_tools is False
|
| 509 |
+
or state["mark"] + waiting_tools_timeout < time.time()
|
| 510 |
+
):
|
| 511 |
state["respond"] = True
|
| 512 |
yield "".join(outputs)
|
| 513 |
|
| 514 |
if (
|
| 515 |
+
apply_tools is True
|
| 516 |
+
and state["respond"] is False
|
| 517 |
and state["mark"] + waiting_tools_timeout > time.time()
|
| 518 |
):
|
| 519 |
gr.Info("Searching for information on the internet.")
|