Spaces:
Paused
Paused
Download app/utils/utils.py from taboola-cz/cz-base: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/spaces/taboola-cz/cz-base/resolve/main/app/utils/utils.py
- Command line
-
hf download hf://spaces/taboola-cz/cz-base/app/utils/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/taboola-cz/cz-base/resolve/main/app/utils/utils.py
1.44 kB
| import json | |
| import gradio as gr | |
| import os | |
| CORRECT_PASSWORD = os.getenv('ui_password') | |
| def show_json(obj): | |
| print(json.loads(obj.model_dump_json())) | |
| def print_assistant_info(assistant): | |
| """Print key information about an assistant object.""" | |
| # Get model | |
| model = assistant.model | |
| # Get description (limited to 2 lines) | |
| desc_lines = assistant.description.split('\n')[:2] | |
| desc = '\n'.join(desc_lines) | |
| if len(desc) > 150: # Truncate if too long | |
| desc = desc[:147] + "..." | |
| # Get instructions (limited to 2 lines) | |
| instr_lines = assistant.instructions.split('\n')[:2] | |
| instr = '\n'.join(instr_lines) | |
| if len(instr) > 150: # Truncate if too long | |
| instr = instr[:147] + "..." | |
| # Print information | |
| print(f"Assistant ID: {assistant.id}") | |
| print(f"Name: {assistant.name}") | |
| print(f"Model: {model}") | |
| print(f"Description: {desc}") | |
| print(f"Instructions: {instr}") | |
| print(f"Tools: {[tool.type for tool in assistant.tools]}") | |
| print(f"Response Format: {assistant.response_format}") | |
| print(f"Created at: {assistant.created_at}") | |
| def check_password(username, input_password): | |
| if input_password == CORRECT_PASSWORD: | |
| return gr.update(visible=False), gr.update(visible=True), "", username | |
| else: | |
| return gr.update(visible=True), gr.update(visible=False), gr.update(value="密碼錯誤,請重試。hint: channel name", visible=True), username | |