Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -29,11 +29,12 @@ def clean_json_string(json_str):
|
|
29 |
|
30 |
def complation(history, model, system_prompt, tools=None):
|
31 |
messages = [{"role": "system", "content": system_prompt}]
|
|
|
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["
|
37 |
messages.append({"role": "assistant", "tool_calls": tools_calls})
|
38 |
messages.append({"role": "tool", "content": msg.content})
|
39 |
else:
|
@@ -127,7 +128,7 @@ def respond(
|
|
127 |
ChatMessage(
|
128 |
role="assistant",
|
129 |
content="",
|
130 |
-
metadata= {"title":
|
131 |
)
|
132 |
)
|
133 |
yield history[-1]
|
@@ -137,7 +138,7 @@ def respond(
|
|
137 |
history[-1] = ChatMessage(
|
138 |
role="assistant",
|
139 |
content=result,
|
140 |
-
metadata= {"title":
|
141 |
)
|
142 |
yield history[-1]
|
143 |
|
|
|
29 |
|
30 |
def complation(history, model, system_prompt, tools=None):
|
31 |
messages = [{"role": "system", "content": system_prompt}]
|
32 |
+
print(history)
|
33 |
for msg in history:
|
34 |
if type(msg) == dict:
|
35 |
msg = ChatMessage(**msg)
|
36 |
if msg.role == "assistant" and len(msg.metadata):
|
37 |
+
tools_calls = json.loads(msg.metadata["title"])
|
38 |
messages.append({"role": "assistant", "tool_calls": tools_calls})
|
39 |
messages.append({"role": "tool", "content": msg.content})
|
40 |
else:
|
|
|
128 |
ChatMessage(
|
129 |
role="assistant",
|
130 |
content="",
|
131 |
+
metadata= {"title": json.dumps([{"id": "call_FthC9qRpsL5kBpwwyw6c7j4k","function": {"arguments": arguments,"name": name},"type": "function"}])}
|
132 |
)
|
133 |
)
|
134 |
yield history[-1]
|
|
|
138 |
history[-1] = ChatMessage(
|
139 |
role="assistant",
|
140 |
content=result,
|
141 |
+
metadata= {"title": json.dumps([{"id": "call_FthC9qRpsL5kBpwwyw6c7j4k","function": {"arguments": arguments,"name": name},"type": "function"}])}
|
142 |
)
|
143 |
yield history[-1]
|
144 |
|