|
import gradio as gr |
|
import plotly.graph_objects as go |
|
|
|
|
|
def create_gauge(value): |
|
fig = go.Figure(go.Indicator( |
|
mode="gauge+number", |
|
value=value, |
|
gauge={ |
|
'axis': {'range': [0, 100]}, |
|
'bar': {'color': "black"}, |
|
'steps': [ |
|
{'range': [0, 40], 'color': "#55efc4"}, |
|
{'range': [40, 70], 'color': "#ffeaa7"}, |
|
{'range': [70, 100], 'color': "#ff7675"} |
|
], |
|
'threshold': { |
|
'line': {'color': "black", 'width': 4}, |
|
'thickness': 0.75, |
|
'value': value |
|
} |
|
}, |
|
number={'font': {'size': 48}} |
|
)) |
|
|
|
fig.update_layout(paper_bgcolor="#f8f9fa", |
|
font={'color': "#2d3436", 'family': "Arial"}, |
|
width=250, |
|
height=150, |
|
margin=dict(l=20, r=180, t=20, b=20)) |
|
return fig |
|
|
|
|
|
def get_success_forecast_1(): |
|
return create_gauge(76) |
|
|
|
def get_success_forecast_2(): |
|
return create_gauge(85) |
|
|
|
def get_success_forecast_3(): |
|
return create_gauge(62) |
|
|
|
|
|
def change_tab(id): |
|
return gr.Tabs(selected=id) |
|
|
|
with gr.Blocks() as demo: |
|
with gr.Tabs() as tabs: |
|
|
|
|
|
with gr.TabItem("Исходные данные", id=0): |
|
with gr.Row(): |
|
with gr.Column(): |
|
desc = gr.Textbox(label="Описание предложения", lines=5) |
|
benefits = gr.Textbox(label="Преимущества", lines=5) |
|
key_message = gr.Textbox(label="Ключевое сообщение", lines=5) |
|
with gr.Column(): |
|
gender = gr.Dropdown(label="Пол", choices=["Мужчина", "Женщина", "Не указан"]) |
|
generation = gr.Dropdown(label="Поколение", choices=["Поколение Z", "Миллениалы", "Поколение X", "Бэби-бумеры"]) |
|
psychotype = gr.Textbox(label="Психотип") |
|
business_stage = gr.Textbox(label="Стадия бизнеса") |
|
industry = gr.Textbox(label="Отрасль") |
|
opf = gr.Textbox(label="ОПФ") |
|
|
|
btn_to_prompts = gr.Button("Создать") |
|
btn_to_prompts.click(fn=change_tab, inputs=[gr.Number(value=1, visible=False)], outputs=tabs) |
|
|
|
|
|
with gr.TabItem("Ассистент", id=1): |
|
with gr.Row(): |
|
with gr.Column(): |
|
non_personalized_prompt = gr.Textbox(label="Задание для копирайтера", lines=25) |
|
with gr.Column(): |
|
personalized_prompt = gr.Textbox(label="Задание для редактора", lines=25) |
|
|
|
|
|
with gr.TabItem("Сообщения", id=2): |
|
|
|
|
|
with gr.Row(): |
|
gr.Markdown("### Копирайтер") |
|
gr.Markdown("### Редактор") |
|
|
|
|
|
with gr.Row(): |
|
non_personalized_1 = gr.Textbox(label="Стандартное сообщение 1", lines=4, interactive=False) |
|
personalized_1 = gr.Textbox(label="Персонализированное сообщение 1", lines=4, interactive=False) |
|
|
|
|
|
with gr.Row(): |
|
non_personalized_2 = gr.Textbox(label="Стандартное сообщение 2", lines=4, interactive=False) |
|
personalized_2 = gr.Textbox(label="Персонализированное сообщение 2", lines=4, interactive=False) |
|
|
|
|
|
with gr.Row(): |
|
non_personalized_3 = gr.Textbox(label="Стандартное сообщение 3", lines=4, interactive=False) |
|
personalized_3 = gr.Textbox(label="Персонализированное сообщение 3", lines=4, interactive=False) |
|
|
|
|
|
with gr.Row(): |
|
btn_check = gr.Button("Проверить", elem_id="check3") |
|
btn_check.click(fn=change_tab, inputs=[gr.Number(value=3, visible=False)], outputs=tabs) |
|
|
|
|
|
with gr.TabItem("Проверка", id=3): |
|
|
|
|
|
with gr.Row(): |
|
gr.Markdown("") |
|
gr.Markdown("### Корректор") |
|
gr.Markdown("### Аналитик") |
|
|
|
|
|
with gr.Row(): |
|
personalized_message_1 = gr.Textbox(label="Персонализированное сообщение 1", lines=5) |
|
check_message_1 = gr.Textbox(label="Проверка сообщения 1", lines=5) |
|
success_forecast_1 = gr.Plot(value=get_success_forecast_1(), label="Прогноз успешности сообщения 1") |
|
|
|
|
|
with gr.Row(): |
|
personalized_message_2 = gr.Textbox(label="Персонализированное сообщение 2", lines=5) |
|
check_message_2 = gr.Textbox(label="Проверка сообщения 2", lines=5) |
|
success_forecast_2 = gr.Plot(value=get_success_forecast_2(), label="Прогноз успешности сообщения 2") |
|
|
|
|
|
with gr.Row(): |
|
personalized_message_3 = gr.Textbox(label="Персонализированное сообщение 3", lines=5) |
|
check_message_3 = gr.Textbox(label="Проверка сообщения 3", lines=5) |
|
success_forecast_3 = gr.Plot(value=get_success_forecast_3(), label="Прогноз успешности сообщения 3") |
|
|
|
|
|
demo.launch() |