MCPcopy Index your code
hub / github.com/ModelTC/LightLLM / test_logprobs

Function test_logprobs

test/test_api/test_openai_api.py:549–569  ·  view source on GitHub ↗

测试logprobs功能

()

Source from the content-addressed store, hash-verified

547
548
549def test_logprobs():
550 """测试logprobs功能"""
551 client = LightLLMClient()
552
553 try:
554 print("=== 测试logprobs ===")
555 result = client.completions_with_logprobs("The capital of France is", logprobs=5, max_tokens=20)
556 print("提示: The capital of France is")
557 print("补全:", result["choices"][0]["text"])
558
559 # 检查logprobs结构
560 logprobs = result["choices"][0]["logprobs"]
561 if logprobs:
562 print("Logprobs结构:")
563 print(f" tokens: {logprobs.get('tokens', [])[:5]}...") # 只显示前5个
564 print(f" token_logprobs: {logprobs.get('token_logprobs', [])[:5]}...")
565 print(f" text_offset: {logprobs.get('text_offset', [])[:5]}...")
566 print(f" top_logprobs: {logprobs.get('top_logprobs', [])[:2]}...") # 只显示前2个
567 print()
568 except Exception as e:
569 print(f"错误: {e}")
570
571
572def test_echo():

Callers 1

mainFunction · 0.85

Calls 3

LightLLMClientClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected