测试多语言混合输入是否能够被正确处理
()
| 139 | |
| 140 | |
| 141 | def test_multilingual_input(): |
| 142 | """测试多语言混合输入是否能够被正确处理""" |
| 143 | data = { |
| 144 | "messages": [ |
| 145 | { |
| 146 | "role": "user", |
| 147 | "content": "这是一个包含多种语言的输入:Hello, 世界!Bonjour, le monde! Hola, el mundo! こんにちは、世界!", |
| 148 | } |
| 149 | ], |
| 150 | "stream": False, |
| 151 | } |
| 152 | payload = build_request_payload(TEMPLATE, data) |
| 153 | resp = send_request(URL, payload).json() |
| 154 | |
| 155 | # 验证响应是否包含有效的回复 |
| 156 | assert "choices" in resp, "未收到有效的回复" |
| 157 | assert len(resp["choices"]) > 0, "回复为空" |
| 158 | assert "message" in resp["choices"][0], "回复中未包含消息内容" |
| 159 | assert "content" in resp["choices"][0]["message"], "回复中未包含内容字段" |
| 160 | # 验证模型是否能够正确处理多语言输入 |
| 161 | response_content = resp["choices"][0]["message"]["content"] |
| 162 | assert response_content.strip() != "", "模型未生成任何内容" |
| 163 | print("多语言混合输入测试通过!") |
| 164 | |
| 165 | |
| 166 | def test_too_long_input(): |
nothing calls this directly
no test coverage detected