(output, history)
| 58 | |
| 59 | |
| 60 | def 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. |
no outgoing calls
no test coverage detected