Update app.py
Browse files
app.py
CHANGED
|
@@ -31,40 +31,53 @@ print("\nEnd definition Backend Logic\n=========")
|
|
| 31 |
print("=========\nBegin definition User Interface (UI)\n")
|
| 32 |
|
| 33 |
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
|
|
|
|
| 34 |
gr.HTML("""<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2Fzelk12%2FChat_interface_test_With_backend">
|
| 35 |
<img src="https://api.visitorbadge.io/api/combined?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2Fzelk12%2FChat_interface_test_With_backend&countColor=%23263759" />
|
| 36 |
</a>""")
|
| 37 |
-
|
| 38 |
-
|
| 39 |
with gr.Accordion(
|
| 40 |
"API",
|
| 41 |
open=False,
|
| 42 |
):
|
|
|
|
| 43 |
with gr.Row():
|
|
|
|
| 44 |
Textbox_Block_API_key = gr.Textbox(
|
| 45 |
label="API key",
|
| 46 |
scale=4,
|
| 47 |
)
|
|
|
|
|
|
|
| 48 |
with gr.Row():
|
|
|
|
| 49 |
Button_Block_Apply_API_key = gr.Button(
|
| 50 |
value="Apply",
|
| 51 |
scale=1,
|
| 52 |
)
|
|
|
|
| 53 |
Button_Block_Reset_API_key = gr.Button(
|
| 54 |
value="Reset",
|
| 55 |
scale=1,
|
| 56 |
)
|
|
|
|
|
|
|
| 57 |
Markdown_Block_API_key_State = gr.Markdown("API key State: False")
|
| 58 |
# Возможные варианты, используеться стандартный API ключь и используеться выбранный API ключь.
|
| 59 |
# Possible options, standard API key is used and selected API key is used.
|
| 60 |
-
|
|
|
|
| 61 |
Dropdown_Block_Choose_provider = gr.Dropdown(label="Choose provider")
|
| 62 |
# На данный момент времени единственным провайдером будет Google и Google API для доступа к Gemini. (19.04.2025)
|
| 63 |
# At this point in time, the only provider will be Google and the Google API to access Gemini. (19.04.2025)
|
|
|
|
|
|
|
| 64 |
Markdown_Block_Povider_State = gr.Markdown("Provider State: False")
|
| 65 |
# Варианты используеться, выбранный провайдер и указание его наименования и провайдер не используеться, и причины.
|
| 66 |
# The options are used, the selected provider and the name of the provider and the provider not used, and the reasons.
|
| 67 |
-
|
|
|
|
| 68 |
ChatIntarface_Block_Main_chat_window = gr.ChatInterface(random_response,
|
| 69 |
multimodal=True,
|
| 70 |
chatbot=gr.Chatbot(
|
|
@@ -78,13 +91,18 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="slate", n
|
|
| 78 |
title="Chat interface test",
|
| 79 |
save_history=True,
|
| 80 |
)
|
|
|
|
|
|
|
| 81 |
Markdown_Block_Output_token = gr.Markdown("Token in output: False")
|
|
|
|
| 82 |
Markdown_Block_Input_token = gr.Markdown("Token in input: False")
|
| 83 |
-
|
|
|
|
| 84 |
with gr.Accordion(
|
| 85 |
"Settings",
|
| 86 |
open=False,
|
| 87 |
):
|
|
|
|
| 88 |
Dropdown_Block_Choose_model = gr.Dropdown(label="Choose model")
|
| 89 |
# От Google будут использованы следующие модели: Gemini 2.5 Flash Preview 04-17 (10 зпаросов в минуту, 250.000 токенов в минуту, 500 запросов в день) (19.04.2025)
|
| 90 |
# Gemini 2.5 Pro Experimental (5 зпаросов в минуту, 250.000 токенов в минуту, 25 запросов в день) (19.04.2025)
|
|
@@ -111,24 +129,30 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="slate", n
|
|
| 111 |
|
| 112 |
# Я даже не буду исправлять этот преревод.
|
| 113 |
# I'm not even gonna fix this pre-translation #
|
| 114 |
-
|
|
|
|
| 115 |
Textbox_Block_System_instructions = gr.Textbox(label="System instructions",)
|
|
|
|
| 116 |
Slier_Block_Model_Temperature = gr.Slider(label="temperature",
|
| 117 |
interactive=True,
|
| 118 |
minimum=0,
|
| 119 |
maximum=2,
|
| 120 |
value=0.95)
|
|
|
|
| 121 |
Slier_Block_Model_topP = gr.Slider(label="topP",
|
| 122 |
interactive=True,
|
| 123 |
minimum=0,
|
| 124 |
maximum=1,
|
| 125 |
value=0.5)
|
|
|
|
| 126 |
Slier_Block_Model_topK = gr.Slider(label="topK",
|
| 127 |
interactive=True,
|
| 128 |
value=100)
|
|
|
|
| 129 |
Checkbox_Block_Output_Stream = gr.Checkbox(
|
| 130 |
label="Enable output stream"
|
| 131 |
)
|
|
|
|
| 132 |
Checkbox_Block_Google_Grounding_Search = gr.Checkbox(
|
| 133 |
label="Grounding with Google Search"
|
| 134 |
)
|
|
|
|
| 31 |
print("=========\nBegin definition User Interface (UI)\n")
|
| 32 |
|
| 33 |
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
|
| 34 |
+
print("Create visitor badge")
|
| 35 |
gr.HTML("""<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2Fzelk12%2FChat_interface_test_With_backend">
|
| 36 |
<img src="https://api.visitorbadge.io/api/combined?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2Fzelk12%2FChat_interface_test_With_backend&countColor=%23263759" />
|
| 37 |
</a>""")
|
| 38 |
+
|
| 39 |
+
print("Create API block")
|
| 40 |
with gr.Accordion(
|
| 41 |
"API",
|
| 42 |
open=False,
|
| 43 |
):
|
| 44 |
+
print("Create API key textbox row")
|
| 45 |
with gr.Row():
|
| 46 |
+
print("Create API key textbox")
|
| 47 |
Textbox_Block_API_key = gr.Textbox(
|
| 48 |
label="API key",
|
| 49 |
scale=4,
|
| 50 |
)
|
| 51 |
+
|
| 52 |
+
print("Create API block button row")
|
| 53 |
with gr.Row():
|
| 54 |
+
print("Create API apply button")
|
| 55 |
Button_Block_Apply_API_key = gr.Button(
|
| 56 |
value="Apply",
|
| 57 |
scale=1,
|
| 58 |
)
|
| 59 |
+
print("Create API reset button")
|
| 60 |
Button_Block_Reset_API_key = gr.Button(
|
| 61 |
value="Reset",
|
| 62 |
scale=1,
|
| 63 |
)
|
| 64 |
+
|
| 65 |
+
print("Create API state markdown")
|
| 66 |
Markdown_Block_API_key_State = gr.Markdown("API key State: False")
|
| 67 |
# Возможные варианты, используеться стандартный API ключь и используеться выбранный API ключь.
|
| 68 |
# Possible options, standard API key is used and selected API key is used.
|
| 69 |
+
|
| 70 |
+
print("Create provider dropdown")
|
| 71 |
Dropdown_Block_Choose_provider = gr.Dropdown(label="Choose provider")
|
| 72 |
# На данный момент времени единственным провайдером будет Google и Google API для доступа к Gemini. (19.04.2025)
|
| 73 |
# At this point in time, the only provider will be Google and the Google API to access Gemini. (19.04.2025)
|
| 74 |
+
|
| 75 |
+
print("Create provider state")
|
| 76 |
Markdown_Block_Povider_State = gr.Markdown("Provider State: False")
|
| 77 |
# Варианты используеться, выбранный провайдер и указание его наименования и провайдер не используеться, и причины.
|
| 78 |
# The options are used, the selected provider and the name of the provider and the provider not used, and the reasons.
|
| 79 |
+
|
| 80 |
+
print("Create main chat window")
|
| 81 |
ChatIntarface_Block_Main_chat_window = gr.ChatInterface(random_response,
|
| 82 |
multimodal=True,
|
| 83 |
chatbot=gr.Chatbot(
|
|
|
|
| 91 |
title="Chat interface test",
|
| 92 |
save_history=True,
|
| 93 |
)
|
| 94 |
+
|
| 95 |
+
print("Create output token markdown")
|
| 96 |
Markdown_Block_Output_token = gr.Markdown("Token in output: False")
|
| 97 |
+
print("Create input token markdown")
|
| 98 |
Markdown_Block_Input_token = gr.Markdown("Token in input: False")
|
| 99 |
+
|
| 100 |
+
print("Create ssettings block")
|
| 101 |
with gr.Accordion(
|
| 102 |
"Settings",
|
| 103 |
open=False,
|
| 104 |
):
|
| 105 |
+
print("Create model dropdown")
|
| 106 |
Dropdown_Block_Choose_model = gr.Dropdown(label="Choose model")
|
| 107 |
# От Google будут использованы следующие модели: Gemini 2.5 Flash Preview 04-17 (10 зпаросов в минуту, 250.000 токенов в минуту, 500 запросов в день) (19.04.2025)
|
| 108 |
# Gemini 2.5 Pro Experimental (5 зпаросов в минуту, 250.000 токенов в минуту, 25 запросов в день) (19.04.2025)
|
|
|
|
| 129 |
|
| 130 |
# Я даже не буду исправлять этот преревод.
|
| 131 |
# I'm not even gonna fix this pre-translation #
|
| 132 |
+
|
| 133 |
+
print("Create system instructions textbox")
|
| 134 |
Textbox_Block_System_instructions = gr.Textbox(label="System instructions",)
|
| 135 |
+
print("Create slider model temperature")
|
| 136 |
Slier_Block_Model_Temperature = gr.Slider(label="temperature",
|
| 137 |
interactive=True,
|
| 138 |
minimum=0,
|
| 139 |
maximum=2,
|
| 140 |
value=0.95)
|
| 141 |
+
print("Create slider model topP")
|
| 142 |
Slier_Block_Model_topP = gr.Slider(label="topP",
|
| 143 |
interactive=True,
|
| 144 |
minimum=0,
|
| 145 |
maximum=1,
|
| 146 |
value=0.5)
|
| 147 |
+
print("Create slider model topK")
|
| 148 |
Slier_Block_Model_topK = gr.Slider(label="topK",
|
| 149 |
interactive=True,
|
| 150 |
value=100)
|
| 151 |
+
print("Create checkbox output stream")
|
| 152 |
Checkbox_Block_Output_Stream = gr.Checkbox(
|
| 153 |
label="Enable output stream"
|
| 154 |
)
|
| 155 |
+
print("Create checkbox Grounding with Google Search")
|
| 156 |
Checkbox_Block_Google_Grounding_Search = gr.Checkbox(
|
| 157 |
label="Grounding with Google Search"
|
| 158 |
)
|