Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,7 +33,7 @@ default_tools = [{"type": "function", "function": {"name": "get_current_weather"
|
|
| 33 |
}
|
| 34 |
}}]
|
| 35 |
|
| 36 |
-
def apply_chat_template(model_name, test_conversation, add_generation_prompt, cleanup_whitespace, hf_token,
|
| 37 |
try:
|
| 38 |
if hf_token:
|
| 39 |
login(token=hf_token) # Ensure login is successful
|
|
@@ -49,7 +49,7 @@ def apply_chat_template(model_name, test_conversation, add_generation_prompt, cl
|
|
| 49 |
conversation,
|
| 50 |
tokenize=False,
|
| 51 |
add_generation_prompt=add_generation_prompt,
|
| 52 |
-
tools=
|
| 53 |
)
|
| 54 |
return formatted
|
| 55 |
except Exception as e:
|
|
@@ -70,6 +70,9 @@ with gr.Blocks() as demo:
|
|
| 70 |
with gr.Column():
|
| 71 |
output = gr.TextArea(label="Formatted Conversation", interactive=False, lines=12)
|
| 72 |
|
|
|
|
|
|
|
|
|
|
| 73 |
format_button.click(
|
| 74 |
fn=apply_chat_template,
|
| 75 |
inputs=[
|
|
@@ -78,9 +81,9 @@ with gr.Blocks() as demo:
|
|
| 78 |
add_generation_prompt_checkbox,
|
| 79 |
cleanup_whitespace_checkbox,
|
| 80 |
hf_token_input,
|
| 81 |
-
|
| 82 |
],
|
| 83 |
outputs=output
|
| 84 |
)
|
| 85 |
|
| 86 |
-
demo.launch()
|
|
|
|
| 33 |
}
|
| 34 |
}}]
|
| 35 |
|
| 36 |
+
def apply_chat_template(model_name, test_conversation, add_generation_prompt, cleanup_whitespace, hf_token, tools):
|
| 37 |
try:
|
| 38 |
if hf_token:
|
| 39 |
login(token=hf_token) # Ensure login is successful
|
|
|
|
| 49 |
conversation,
|
| 50 |
tokenize=False,
|
| 51 |
add_generation_prompt=add_generation_prompt,
|
| 52 |
+
tools=tools
|
| 53 |
)
|
| 54 |
return formatted
|
| 55 |
except Exception as e:
|
|
|
|
| 70 |
with gr.Column():
|
| 71 |
output = gr.TextArea(label="Formatted Conversation", interactive=False, lines=12)
|
| 72 |
|
| 73 |
+
# Use gr.State() to pass default_tools correctly
|
| 74 |
+
tools_state = gr.State(default_tools)
|
| 75 |
+
|
| 76 |
format_button.click(
|
| 77 |
fn=apply_chat_template,
|
| 78 |
inputs=[
|
|
|
|
| 81 |
add_generation_prompt_checkbox,
|
| 82 |
cleanup_whitespace_checkbox,
|
| 83 |
hf_token_input,
|
| 84 |
+
tools_state # Wrapped inside gr.State()
|
| 85 |
],
|
| 86 |
outputs=output
|
| 87 |
)
|
| 88 |
|
| 89 |
+
demo.launch()
|