cz-base / app /utils /utils.py
chengzhiedu's picture
chore(ui): modefied theme, error message and placeholder
c87676b
Raw History Blame Contribute Delete
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