vilarin commited on
Commit
2692054
1 Parent(s): b188e1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -9
app.py CHANGED
@@ -26,8 +26,6 @@ TITLE = "<h1><center>VL-Chatbox</center></h1>"
26
 
27
  DESCRIPTION = "<h3><center>MODEL: " + MODEL_NAME + "</center></h3>"
28
 
29
- DEFAULT_SYSTEM = "You named Chatbox. You are a good assitant."
30
-
31
  CSS = """
32
  .duplicate-button {
33
  margin: auto !important;
@@ -50,9 +48,9 @@ eos_token_id=processor.tokenizer.eos_token_id
50
 
51
 
52
  @spaces.GPU(queue=False)
53
- def stream_chat(message, history: list, system: str, temperature: float, max_new_tokens: int):
54
  print(message)
55
- conversation = [{"role": "user", "content": system or DEFAULT_SYSTEM}]
56
  for prompt, answer in history:
57
  conversation.extend([{"role": "user", "content": f"<|image_1|>\n{prompt}"}, {"role": "assistant", "content": answer}])
58
  conversation.append({"role": "user", "content": message['text']})
@@ -60,6 +58,8 @@ def stream_chat(message, history: list, system: str, temperature: float, max_new
60
  if message["files"]:
61
  image = Image.open(message["files"][-1]).convert('RGB')
62
  else:
 
 
63
  image = None
64
 
65
  prompt = processor.tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True)
@@ -111,11 +111,6 @@ with gr.Blocks(css=CSS) as demo:
111
  fill_height=True,
112
  additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=False, render=False),
113
  additional_inputs=[
114
- gr.Text(
115
- value="",
116
- label="System",
117
- render=False,
118
- ),
119
  gr.Slider(
120
  minimum=0,
121
  maximum=1,
 
26
 
27
  DESCRIPTION = "<h3><center>MODEL: " + MODEL_NAME + "</center></h3>"
28
 
 
 
29
  CSS = """
30
  .duplicate-button {
31
  margin: auto !important;
 
48
 
49
 
50
  @spaces.GPU(queue=False)
51
+ def stream_chat(message, history: list, temperature: float, max_new_tokens: int):
52
  print(message)
53
+ conversation = []
54
  for prompt, answer in history:
55
  conversation.extend([{"role": "user", "content": f"<|image_1|>\n{prompt}"}, {"role": "assistant", "content": answer}])
56
  conversation.append({"role": "user", "content": message['text']})
 
58
  if message["files"]:
59
  image = Image.open(message["files"][-1]).convert('RGB')
60
  else:
61
+ if len(history) == 0:
62
+ gr.Error("Please upload an image first.")
63
  image = None
64
 
65
  prompt = processor.tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True)
 
111
  fill_height=True,
112
  additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=False, render=False),
113
  additional_inputs=[
 
 
 
 
 
114
  gr.Slider(
115
  minimum=0,
116
  maximum=1,