Nils Durner commited on
Commit
df844fd
1 Parent(s): 877d346

fix handling of empty inputs

Browse files
Files changed (2) hide show
  1. app.py +2 -1
  2. llm.py +2 -2
app.py CHANGED
@@ -10,7 +10,8 @@ from llm import LLM, log_to_console, image_embed_prefix
10
  dump_controls = False
11
 
12
  def add_text(history, text):
13
- history = history + [(text, None)]
 
14
  return history, gr.Textbox(value="", interactive=False)
15
 
16
 
 
10
  dump_controls = False
11
 
12
  def add_text(history, text):
13
+ if text:
14
+ history = history + [(text, None)]
15
  return history, gr.Textbox(value="", interactive=False)
16
 
17
 
llm.py CHANGED
@@ -67,7 +67,7 @@ class Claude(LLM):
67
  history_claude_format = []
68
  user_msg_parts = []
69
  for human, assi in history:
70
- if human is not None:
71
  if human.startswith(image_embed_prefix):
72
  with open(human.lstrip(image_embed_prefix), mode="rb") as f:
73
  content = f.read()
@@ -76,7 +76,7 @@ class Claude(LLM):
76
  else:
77
  user_msg_parts.append({"type": "text", "text": human})
78
 
79
- if assi is not None:
80
  if user_msg_parts:
81
  history_claude_format.append({"role": "user", "content": user_msg_parts})
82
  user_msg_parts = []
 
67
  history_claude_format = []
68
  user_msg_parts = []
69
  for human, assi in history:
70
+ if human:
71
  if human.startswith(image_embed_prefix):
72
  with open(human.lstrip(image_embed_prefix), mode="rb") as f:
73
  content = f.read()
 
76
  else:
77
  user_msg_parts.append({"type": "text", "text": human})
78
 
79
+ if assi:
80
  if user_msg_parts:
81
  history_claude_format.append({"role": "user", "content": user_msg_parts})
82
  user_msg_parts = []