ankush13r commited on
Commit
8973442
·
verified ·
1 Parent(s): d20a00b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -121,17 +121,24 @@ def respond(
121
  result = f"💥 Error using tool {name}, tools doesn't exists"
122
  print("arguments:", arguments)
123
  json_arguments = json.loads(arguments)
 
 
 
 
 
 
 
 
 
124
  if tools.get(name):
125
  result = str(tools[name].invoke(input=json_arguments))
126
  result = json.dumps({name: result}, ensure_ascii=False)
127
- history.append(
128
- ChatMessage(
129
  role="assistant",
130
  content=result,
131
  metadata= {"title": f"🛠️ Used tool '{name}', arguments: {json.dumps(json_arguments, ensure_ascii=False)}"},
132
  options=[{"label":"tool_calls", "value": json.dumps([{"id": "call_FthC9qRpsL5kBpwwyw6c7j4k","function": {"arguments": arguments,"name": name},"type": "function"}])}]
133
  )
134
- )
135
  yield history[-1]
136
 
137
  completion = complation(history=history, tools=oitools, model=model, system_prompt=additional_inputs)
 
121
  result = f"💥 Error using tool {name}, tools doesn't exists"
122
  print("arguments:", arguments)
123
  json_arguments = json.loads(arguments)
124
+ history.append(
125
+ ChatMessage(
126
+ role="assistant",
127
+ content="",
128
+ metadata= {"title": f"🛠️ Using tool '{name}', arguments: {json.dumps(json_arguments, ensure_ascii=False)}"},
129
+ options=[{"label":"tool_calls", "value": json.dumps([{"id": "call_FthC9qRpsL5kBpwwyw6c7j4k","function": {"arguments": arguments,"name": name},"type": "function"}])}]
130
+ )
131
+ )
132
+ yield history[-1]
133
  if tools.get(name):
134
  result = str(tools[name].invoke(input=json_arguments))
135
  result = json.dumps({name: result}, ensure_ascii=False)
136
+ history[-1] = ChatMessage(
 
137
  role="assistant",
138
  content=result,
139
  metadata= {"title": f"🛠️ Used tool '{name}', arguments: {json.dumps(json_arguments, ensure_ascii=False)}"},
140
  options=[{"label":"tool_calls", "value": json.dumps([{"id": "call_FthC9qRpsL5kBpwwyw6c7j4k","function": {"arguments": arguments,"name": name},"type": "function"}])}]
141
  )
 
142
  yield history[-1]
143
 
144
  completion = complation(history=history, tools=oitools, model=model, system_prompt=additional_inputs)