mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2025-08-04 12:42:51 +08:00
add tool hint
Former-commit-id: 2abfe5fbc2f79a87c741aadebf11dd2fce8670a2
This commit is contained in:
parent
e95c0242a8
commit
29c16f6326
@ -1,6 +1,9 @@
|
|||||||
import gradio as gr
|
import gradio as gr
|
||||||
from typing import TYPE_CHECKING, Dict, Optional, Tuple
|
from typing import TYPE_CHECKING, Dict, Optional, Tuple
|
||||||
|
|
||||||
|
from ..utils import check_json_schema
|
||||||
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from gradio.blocks import Block
|
from gradio.blocks import Block
|
||||||
from gradio.components import Component
|
from gradio.components import Component
|
||||||
@ -29,6 +32,8 @@ def create_chat_box(
|
|||||||
top_p = gr.Slider(0.01, 1, value=gen_kwargs.top_p, step=0.01)
|
top_p = gr.Slider(0.01, 1, value=gen_kwargs.top_p, step=0.01)
|
||||||
temperature = gr.Slider(0.01, 1.5, value=gen_kwargs.temperature, step=0.01)
|
temperature = gr.Slider(0.01, 1.5, value=gen_kwargs.temperature, step=0.01)
|
||||||
|
|
||||||
|
tools.input(check_json_schema, [tools])
|
||||||
|
|
||||||
submit_btn.click(
|
submit_btn.click(
|
||||||
engine.chatter.predict,
|
engine.chatter.predict,
|
||||||
[chatbot, query, history, system, tools, max_new_tokens, top_p, temperature],
|
[chatbot, query, history, system, tools, max_new_tokens, top_p, temperature],
|
||||||
|
@ -41,6 +41,13 @@ def can_quantize(finetuning_type: str) -> Dict[str, Any]:
|
|||||||
return gr.update(interactive=True)
|
return gr.update(interactive=True)
|
||||||
|
|
||||||
|
|
||||||
|
def check_json_schema(text: str) -> None:
|
||||||
|
try:
|
||||||
|
json.loads(text)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
gr.Warning("Invalid JSON schema")
|
||||||
|
|
||||||
|
|
||||||
def gen_cmd(args: Dict[str, Any]) -> str:
|
def gen_cmd(args: Dict[str, Any]) -> str:
|
||||||
args.pop("disable_tqdm", None)
|
args.pop("disable_tqdm", None)
|
||||||
args["plot_loss"] = args.get("do_train", None)
|
args["plot_loss"] = args.get("do_train", None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user