vilarin commited on
Commit
6e89311
1 Parent(s): 2d251eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -22,7 +22,7 @@ MODEL_NAME = MODEL_ID.split("/")[-1]
22
 
23
  TITLE = "<h1><center>VL-Chatbox</center></h1>"
24
 
25
- DESCRIPTION = f'<h3><center>MODEL: <a href="https://hf.co/models/{MODEL_ID}">{MODEL_NAME}</a></center></h3>'
26
 
27
  CSS = """
28
  .duplicate-button {
@@ -65,12 +65,12 @@ def stream_chat(message, history: list, temperature: float, max_new_tokens: int)
65
  conversation.append({"role": "user", "content": message['text']})
66
  print(f"Conversation is -\n{conversation}")
67
 
68
- streamer = TextIteratorStreamer(tokenizer, **{"skip_special_tokens": True, "skip_prompt": True, 'clean_up_tokenization_spaces':False,})
69
 
70
  generate_kwargs = dict(
71
  image=image,
72
  msgs=conversation,
73
- streamer=streamer,
74
  max_new_tokens=max_new_tokens,
75
  temperature=temperature,
76
  sampling=True,
@@ -79,7 +79,7 @@ def stream_chat(message, history: list, temperature: float, max_new_tokens: int)
79
  if temperature == 0:
80
  generate_kwargs["sampling"] = False
81
 
82
-
83
  thread = Thread(target=model.chat, kwargs=generate_kwargs)
84
  thread.start()
85
 
@@ -87,6 +87,9 @@ def stream_chat(message, history: list, temperature: float, max_new_tokens: int)
87
  for new_text in streamer:
88
  buffer += new_text
89
  yield buffer
 
 
 
90
 
91
 
92
  chatbot = gr.Chatbot(height=450)
 
22
 
23
  TITLE = "<h1><center>VL-Chatbox</center></h1>"
24
 
25
+ DESCRIPTION = f'<h3><center>MODEL: <a href="https://hf.co/{MODEL_ID}">{MODEL_NAME}</a></center></h3>'
26
 
27
  CSS = """
28
  .duplicate-button {
 
65
  conversation.append({"role": "user", "content": message['text']})
66
  print(f"Conversation is -\n{conversation}")
67
 
68
+ # streamer = TextIteratorStreamer(tokenizer, **{"skip_special_tokens": True, "skip_prompt": True, 'clean_up_tokenization_spaces':False,})
69
 
70
  generate_kwargs = dict(
71
  image=image,
72
  msgs=conversation,
73
+ # streamer=streamer,
74
  max_new_tokens=max_new_tokens,
75
  temperature=temperature,
76
  sampling=True,
 
79
  if temperature == 0:
80
  generate_kwargs["sampling"] = False
81
 
82
+ """
83
  thread = Thread(target=model.chat, kwargs=generate_kwargs)
84
  thread.start()
85
 
 
87
  for new_text in streamer:
88
  buffer += new_text
89
  yield buffer
90
+ """
91
+ response = model.chat(**generate_kwargs)
92
+ return response
93
 
94
 
95
  chatbot = gr.Chatbot(height=450)