Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -98,22 +98,20 @@ footer {visibility: hidden !important;}
|
|
| 98 |
|
| 99 |
# Создаем интерфейс с помощью Gradio
|
| 100 |
with gr.Blocks(css=css) as demo:
|
|
|
|
| 101 |
with gr.Row():
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
image_input = gr.Image(label="Загрузить изображение", type="pil", interactive=True)
|
| 106 |
-
with gr.Column(scale=4):
|
| 107 |
-
instructions = gr.Textbox(label="Сообщение", lines=2, placeholder="Введите ваше сообщение здесь...")
|
| 108 |
-
with gr.Column(scale=1):
|
| 109 |
-
submit_button = gr.Button("Отправить")
|
| 110 |
|
| 111 |
def process_input(instructions, image_input):
|
| 112 |
response = ask_openai_with_image(instructions, image_input)
|
| 113 |
-
|
|
|
|
| 114 |
if image_input:
|
| 115 |
-
|
| 116 |
-
|
|
|
|
| 117 |
|
| 118 |
submit_button.click(
|
| 119 |
fn=process_input,
|
|
|
|
| 98 |
|
| 99 |
# Создаем интерфейс с помощью Gradio
|
| 100 |
with gr.Blocks(css=css) as demo:
|
| 101 |
+
chatbot = gr.Chatbot()
|
| 102 |
with gr.Row():
|
| 103 |
+
image_input = gr.Image(label="Загрузить изображение", type="pil", interactive=True, tool="upload")
|
| 104 |
+
instructions = gr.Textbox(label="Сообщение", lines=2, placeholder="Введите ваше сообщение здесь...")
|
| 105 |
+
submit_button = gr.Button("Отправить")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
def process_input(instructions, image_input):
|
| 108 |
response = ask_openai_with_image(instructions, image_input)
|
| 109 |
+
if instructions:
|
| 110 |
+
chatbot.add_message(instructions, is_user=True)
|
| 111 |
if image_input:
|
| 112 |
+
chat_image = Image.open(image_input)
|
| 113 |
+
chatbot.add_message(chat_image, is_user=True)
|
| 114 |
+
chatbot.add_message(response, is_user=False)
|
| 115 |
|
| 116 |
submit_button.click(
|
| 117 |
fn=process_input,
|