lamdao commited on
Commit
9458bb1
·
verified ·
1 Parent(s): b42bafc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -43,13 +43,15 @@ with gr.Blocks() as demo:
43
  return "", history + [[user_message, None]] # Add user message to chat history
44
 
45
  def bot(history):
46
- user_message = history[-1][0]
47
- payload = {
48
- "inputs": user_message,
49
- "parameters": {"function_call": "auto"}
50
- }
51
- output = query_model(payload)
52
-
 
 
53
  # Parse the model's response
54
  if 'function_call' in output and 'name' in output['function_call']:
55
  function_name = output['function_call']['name']
 
43
  return "", history + [[user_message, None]] # Add user message to chat history
44
 
45
  def bot(history):
46
+ if history:
47
+ user_message = history[-1][0]
48
+ payload = {
49
+ "inputs": user_message,
50
+ "parameters": {"function_call": "auto"}
51
+ }
52
+ output = query_model(payload)
53
+ else:
54
+ return history # Or some default response if history is empty
55
  # Parse the model's response
56
  if 'function_call' in output and 'name' in output['function_call']:
57
  function_name = output['function_call']['name']