测试stop参数
()
| 592 | |
| 593 | |
| 594 | def test_stop_parameter(): |
| 595 | """测试stop参数""" |
| 596 | client = LightLLMClient() |
| 597 | |
| 598 | try: |
| 599 | print("=== 测试stop参数 ===") |
| 600 | |
| 601 | # 测试单个stop字符串 |
| 602 | result = client.completions_with_stop("Count: 1, 2, 3, 4", stop="12", max_tokens=50) |
| 603 | print("提示: Count: 1, 2, 3, 4 (stop='12')") |
| 604 | print("补全:", repr(result["choices"][0]["text"])) |
| 605 | print("完成原因:", result["choices"][0]["finish_reason"]) |
| 606 | print() |
| 607 | |
| 608 | # 测试多个stop字符串 |
| 609 | result = client.completions_with_stop("The colors are red, blue, green", stop=["red", "blue"], max_tokens=50) |
| 610 | print("提示: The colors are red, blue, green (stop=['red', 'blue'])") |
| 611 | print("补全:", repr(result["choices"][0]["text"])) |
| 612 | print("完成原因:", result["choices"][0]["finish_reason"]) |
| 613 | print() |
| 614 | except Exception as e: |
| 615 | print(f"错误: {e}") |
| 616 | |
| 617 | |
| 618 | def test_multiple_token_arrays(): |
no test coverage detected