MCPcopy
hub / github.com/zai-org/GLM-4 / process_response

Function process_response

demo/composite_demo/src/client.py:60–79  ·  view source on GitHub ↗
(output, history)

Source from the content-addressed store, hash-verified

58
59
60def process_response(output, history):
61 content = ""
62 history = deepcopy(history)
63 for response in output.split("<|assistant|>"):
64 if "\n" in response:
65 metadata, content = response.split("\n", maxsplit=1)
66 else:
67 metadata, content = "", response
68 if not metadata.strip():
69 content = content.strip()
70 history.append({"role": "assistant", "metadata": metadata, "content": content})
71 content = content.replace("[[训练时间]]", "2023年")
72 else:
73 history.append({"role": "assistant", "metadata": metadata, "content": content})
74 if history[0]["role"] == "system" and "tools" in history[0]:
75 parameters = json.loads(content)
76 content = {"name": metadata.strip(), "parameters": parameters}
77 else:
78 content = {"name": metadata.strip(), "content": content}
79 return content, history
80
81
82# glm-4v-9b is not available in vLLM backend, use HFClient instead.

Callers 3

generate_streamMethod · 0.90
generate_streamMethod · 0.90
generate_streamMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected