ahmedheakl commited on
Commit
fff64e0
·
verified ·
1 Parent(s): 620aca7

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. gradio_app.py +10 -0
gradio_app.py CHANGED
@@ -30,9 +30,19 @@ def load_chat(
30
  message: str, history: list | None
31
  ) -> Generator[str, None, None]:
32
  history = history or start_message
 
33
  if len(history) > 0 and isinstance(history[0], (list, tuple)):
34
  history = history[:TOP_N_HISTORY]
35
  history = ChatInterface._tuples_to_messages(history)
 
 
 
 
 
 
 
 
 
36
  files = message.get('files', [])
37
  content = [
38
  {"type": "text", "text": message.get('text', '')}
 
30
  message: str, history: list | None
31
  ) -> Generator[str, None, None]:
32
  history = history or start_message
33
+ print(history)
34
  if len(history) > 0 and isinstance(history[0], (list, tuple)):
35
  history = history[:TOP_N_HISTORY]
36
  history = ChatInterface._tuples_to_messages(history)
37
+ elif len(history) > 0 and isinstance(history[0], dict):
38
+ hist = []
39
+ for i, h in enumerate(history):
40
+ content = h.get("content", "")
41
+ if isinstance(content, tuple):
42
+ hist.append({"role": "user", "content": [{"type": "image_url", "image_url": {"url": content[0]}}]})
43
+ else:
44
+ hist.append({"role": "user", "content": [{"type": "text", "text": content}]})
45
+ history = hist
46
  files = message.get('files', [])
47
  content = [
48
  {"type": "text", "text": message.get('text', '')}