Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -29,11 +29,9 @@ def clean_json_string(json_str):
|
|
29 |
|
30 |
def complation(history, model, system_prompt, tools=None):
|
31 |
messages = [{"role": "system", "content": system_prompt}]
|
32 |
-
print("================")
|
33 |
for msg in history:
|
34 |
if type(msg) == dict:
|
35 |
msg = ChatMessage(**msg)
|
36 |
-
print(msg.role, end=", ")
|
37 |
if msg.role == "assistant" and len(msg.options) > 0 and msg.options[0]["label"] == "tool_calls":
|
38 |
tools_calls = json.loads(msg.options[0]["value"])
|
39 |
messages.append({"role": "assistant", "tool_calls": tools_calls})
|
@@ -41,6 +39,8 @@ def complation(history, model, system_prompt, tools=None):
|
|
41 |
else:
|
42 |
messages.append({"role": msg.role, "content": msg.content})
|
43 |
print("================")
|
|
|
|
|
44 |
if not tools:
|
45 |
return client.chat.completions.create(
|
46 |
model=model,
|
|
|
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.options) > 0 and msg.options[0]["label"] == "tool_calls":
|
36 |
tools_calls = json.loads(msg.options[0]["value"])
|
37 |
messages.append({"role": "assistant", "tool_calls": tools_calls})
|
|
|
39 |
else:
|
40 |
messages.append({"role": msg.role, "content": msg.content})
|
41 |
print("================")
|
42 |
+
print(messages)
|
43 |
+
print("================")
|
44 |
if not tools:
|
45 |
return client.chat.completions.create(
|
46 |
model=model,
|