MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / process_response

Function process_response

SwissArmyTransformer/examples/chatglm3/chat_sat.py:10–29  ·  view source on GitHub ↗
(output, history)

Source from the content-addressed store, hash-verified

8from copy import deepcopy
9
10def process_response(output, history):
11 content = ""
12 history = deepcopy(history)
13 for response in output.split("<|assistant|>"):
14 metadata, content = response.split("\n", maxsplit=1)
15 if not metadata.strip():
16 content = content.strip()
17 history.append({"role": "assistant", "metadata": metadata, "content": content})
18 content = content.replace("[[训练时间]]", "2023年")
19 else:
20 history.append({"role": "assistant", "metadata": metadata, "content": content})
21 if history[0]["role"] == "system" and "tools" in history[0]:
22 content = "\n".join(content.split("\n")[1:-1])
23 def tool_call(**kwargs):
24 return kwargs
25 parameters = eval(content)
26 content = {"name": metadata.strip(), "parameters": parameters}
27 else:
28 content = {"name": metadata.strip(), "content": content}
29 return content, history
30
31def chat(model, tokenizer,
32 max_length: int = 256, num_beams=1, top_p=0.7, top_k=0, temperature=0.95):

Callers 1

chatFunction · 0.70

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected