Rooni commited on
Commit
6d9548a
·
1 Parent(s): 261ffd6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
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
- chatbot = gr.Chatbot()
103
- with gr.Row():
104
- with gr.Column(scale=1):
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
- chatbot.append("user", instructions)
 
114
  if image_input:
115
- chatbot.append("user", image_input)
116
- chatbot.append("bot", response)
 
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,