# Попробую писать коментарии на двух языках. # I'll try to write bilingual comments. #========= #========= # Library Import print("=========\nBegin import library\n") import random import gradio as gr from huggingface_hub import InferenceClient print("\nEnd import library\n=========") #========= #========= # Backend Logic print("=========\nBegin definition Backend Logic\n") def random_response(message, history): return random.choice(["Yes", "No"]) print("\nEnd definition Backend Logic\n=========") # ========= # ========= # User Interface (UI) Definition print("=========\nBegin definition User Interface (UI)\n") with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="slate", neutral_hue="neutral")) as demo: # Using Soft theme with adjusted hues for a refined look gr.HTML(""" """) print("Test") with gr.Accordion( "API", open=False, ): with gr.Row(): Textbox_Block_API_key = gr.Textbox( label="API key", scale=4, ) with gr.Row(): Button_Block_Apply_API_key = gr.Button( value="Apply", scale=1, ) Button_Block_Reset_API_key = gr.Button( value="Reset", scale=1, ) Markdown_Block_API_key_State = gr.Markdown("API key State: False") # Возможные варианты, используеться стандартный API ключь и используеться выбранный API ключь. # Possible options, standard API key is used and selected API key is used. Dropdown_Block_Choose_provider = gr.Dropdown(label="Choose provider") # На данный момент времени единственным провайдером будет Google и Google API для доступа к Gemini. (19.04.2025) # At this point in time, the only provider will be Google and the Google API to access Gemini. (19.04.2025) Markdown_Block_Povider_State = gr.Markdown("Provider State: False") # Варианты используеться, выбранный провайдер и указание его наименования и провайдер не используеться, и причины. # The options are used, the selected provider and the name of the provider and the provider not used, and the reasons. ChatIntarface_Block_Main_chat_window = gr.ChatInterface(random_response, multimodal=True, chatbot=gr.Chatbot( label="output", ), type="messages", textbox=gr.MultimodalTextbox( label="input", ), editable=True, title="Chat interface test", save_history=True, ) Markdown_Block_Output_token = gr.Markdown("Token in output: False") Markdown_Block_Input_token = gr.Markdown("Token in input: False") with gr.Accordion( "Settings", open=False, ): Dropdown_Block_Choose_model = gr.Dropdown(label="Choose model") # От Google будут использованы следующие модели: Gemini 2.5 Flash Preview 04-17 (10 зпаросов в минуту, 250.000 токенов в минуту, 500 запросов в день) (19.04.2025) # Gemini 2.5 Pro Experimental (5 зпаросов в минуту, 250.000 токенов в минуту, 25 запросов в день) (19.04.2025) # Gemini 2.0 Flash (15 зпаросов в минуту, 1.000.000 токенов в минуту, 1.500 запросов в день) (19.04.2025) # Gemini 2.0 Flash Experimental (10 зпаросов в минуту, 1.000.000 токенов в минуту, 1.500 запросов в день) (19.04.2025) # Gemini 2.0 Flash-Lite (30 зпаросов в минуту, 1.000.000 токенов в минуту, 1.500 запросов в день) (19.04.2025) # Gemini 1.5 Flash (15 зпаросов в минуту, 1.000.000 токенов в минуту, 1.500 запросов в день) (19.04.2025) # Gemini 1.5 Flash-8B (15 зпаросов в минуту, 1.000.000 токенов в минуту, 1.500 запросов в день) (19.04.2025) # Gemini 1.5 Pro (2 зпаросов в минуту, 32.000 токенов в минуту, 50 запросов в день) (19.04.2025) # Gemma 3 (30 зпаросов в минуту, 15.000 токенов в минуту, 14.400 запросов в день) (19.04.2025) # По умалчанию будет выбрана модель: Gemini 2.0 Flash Experimental (19.04.2025) # # The following models will be used from Google: Gemini 2.5 Flash Preview 04-17 (10 zparos per minute, 250,000 tokens per minute, 500 requests per day) (19.04.2025) # Gemini 2.5 Pro Experimental (5 drops per minute, 250,000 tokens per minute, 25 requests per day) (19.04.2025) # Gemini 2.0 Flash (15 drops per minute, 1,000,000 tokens per minute, 1,500 requests per day) (19.04.2025) # Gemini 2.0 Flash Experimental (10 drops per minute, 1,000,000 tokens per minute, 1,500 requests per day) (19.04.2025) # Gemini 2.0 Flash-Lite (30 drops per minute, 1,000,000 tokens per minute, 1,500 requests per day) (19.04.2025) # Gemini 1.5 Flash (15 drops per minute, 1,000,000 tokens per minute, 1,500 requests per day) (19.04.2025) # Gemini 1.5 Flash-8B (15 drops per minute, 1,000,000 tokens per minute, 1,500 requests per day) (19.04.2025) # Gemini 1.5 Pro (2 drops per minute, 32,000 tokens per minute, 50 requests per day) (19.04.2025) # Gemma 3 (30 zparos per minute, 15.000 tokens per minute, 14.400 requests per day) (19.04.2025) # Gemini 2.0 Flash Experimental will be chosen by default. (19.04.2025) # Translated with www.DeepL.com/Translator (free version) # Я даже не буду исправлять этот преревод. # I'm not even gonna fix this pre-translation # Textbox_Block_System_instructions = gr.Textbox(label="System instructions",) Slier_Block_Model_Temperature = gr.Slider(label="temperature", interactive=True, minimum=0, maximum=2, value=0.95) Slier_Block_Model_topP = gr.Slider(label="topP", interactive=True, minimum=0, maximum=1, value=0.5) Slier_Block_Model_topK = gr.Slider(label="topK", interactive=True, value=100) Checkbox_Block_Output_Stream = gr.Checkbox( label="Enable output stream" ) Checkbox_Block_Google_Grounding_Search = gr.Checkbox( label="Grounding with Google Search" ) print("\nEnd definition User Interface (UI)\n=========") print("=========\nBegin launch demo\n") if __name__ == "__main__": demo.launch() print("\nEnd launch demo\n=========")