Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -32,8 +32,8 @@ def complation(history, model, system_prompt, tools=None):
|
|
32 |
for msg in history:
|
33 |
if type(msg) == dict:
|
34 |
msg = ChatMessage(**msg)
|
35 |
-
if msg.role == "assistant" and len(msg.
|
36 |
-
tools_calls = json.loads(msg.
|
37 |
messages.append({"role": "assistant", "tool_calls": tools_calls})
|
38 |
messages.append({"role": "tool", "content": msg.content})
|
39 |
else:
|
@@ -127,8 +127,7 @@ def respond(
|
|
127 |
ChatMessage(
|
128 |
role="assistant",
|
129 |
content="",
|
130 |
-
metadata= {"title": f"🛠️ Using tool '{name}', arguments: {json.dumps(json_arguments, ensure_ascii=False)}"},
|
131 |
-
options=[{"label":"tool_call", "value": json.dumps([{"id": "call_FthC9qRpsL5kBpwwyw6c7j4k","function": {"arguments": arguments,"name": name},"type": "function"}])}]
|
132 |
)
|
133 |
)
|
134 |
yield history[-1]
|
@@ -138,8 +137,7 @@ def respond(
|
|
138 |
history[-1] = ChatMessage(
|
139 |
role="assistant",
|
140 |
content=result,
|
141 |
-
metadata= {"title": f"🛠️ Used tool '{name}', arguments: {json.dumps(json_arguments, ensure_ascii=False)}"},
|
142 |
-
options=[{"label":"tool_call", "value": json.dumps([{"id": "call_FthC9qRpsL5kBpwwyw6c7j4k","function": {"arguments": arguments,"name": name},"type": "function"}])}]
|
143 |
)
|
144 |
yield history[-1]
|
145 |
|
|
|
32 |
for msg in history:
|
33 |
if type(msg) == dict:
|
34 |
msg = ChatMessage(**msg)
|
35 |
+
if msg.role == "assistant" and len(msg.metadata):
|
36 |
+
tools_calls = json.loads(msg.metadata["tool_calls"])
|
37 |
messages.append({"role": "assistant", "tool_calls": tools_calls})
|
38 |
messages.append({"role": "tool", "content": msg.content})
|
39 |
else:
|
|
|
127 |
ChatMessage(
|
128 |
role="assistant",
|
129 |
content="",
|
130 |
+
metadata= {"title": f"🛠️ Using tool '{name}', arguments: {json.dumps(json_arguments, ensure_ascii=False)}", "tool_calls": json.dumps([{"id": "call_FthC9qRpsL5kBpwwyw6c7j4k","function": {"arguments": arguments,"name": name},"type": "function"}])},
|
|
|
131 |
)
|
132 |
)
|
133 |
yield history[-1]
|
|
|
137 |
history[-1] = ChatMessage(
|
138 |
role="assistant",
|
139 |
content=result,
|
140 |
+
metadata= {"title": f"🛠️ Used tool '{name}', arguments: {json.dumps(json_arguments, ensure_ascii=False)}", "tool_calls": json.dumps([{"id": "call_FthC9qRpsL5kBpwwyw6c7j4k","function": {"arguments": arguments,"name": name},"type": "function"}])},
|
|
|
141 |
)
|
142 |
yield history[-1]
|
143 |
|