MCPcopy
hub / github.com/mudler/LocalAI / test_sampling_params

Method test_sampling_params

backend/python/vllm/test.py:78–122  ·  view source on GitHub ↗

This method tests if all sampling parameters are correctly processed NOTE: this does NOT test for correctness, just that we received a compatible response

(self)

Source from the content-addressed store, hash-verified

76 self.tearDown()
77
78 def test_sampling_params(self):
79 """
80 This method tests if all sampling parameters are correctly processed
81 NOTE: this does NOT test for correctness, just that we received a compatible response
82 """
83 try:
84 self.setUp()
85 with grpc.insecure_channel("localhost:50051") as channel:
86 stub = backend_pb2_grpc.BackendStub(channel)
87 response = stub.LoadModel(backend_pb2.ModelOptions(Model="facebook/opt-125m"))
88 self.assertTrue(response.success)
89
90 req = backend_pb2.PredictOptions(
91 Prompt="The capital of France is",
92 TopP=0.8,
93 Tokens=50,
94 Temperature=0.7,
95 TopK=40,
96 PresencePenalty=0.1,
97 FrequencyPenalty=0.2,
98 RepetitionPenalty=1.1,
99 MinP=0.05,
100 Seed=42,
101 StopPrompts=["\n"],
102 StopTokenIds=[50256],
103 BadWords=["badword"],
104 IncludeStopStrInOutput=True,
105 IgnoreEOS=True,
106 MinTokens=5,
107 Logprobs=5,
108 PromptLogprobs=5,
109 SkipSpecialTokens=True,
110 SpacesBetweenSpecialTokens=True,
111 TruncatePromptTokens=10,
112 GuidedDecoding=True,
113 N=2,
114 )
115 resp = stub.Predict(req)
116 self.assertIsNotNone(resp.message)
117 self.assertIsNotNone(resp.logprobs)
118 except Exception as err:
119 print(err)
120 self.fail("sampling params service failed")
121 finally:
122 self.tearDown()
123
124
125 def test_messages_to_dicts(self):

Callers

nothing calls this directly

Calls 4

setUpMethod · 0.95
tearDownMethod · 0.95
LoadModelMethod · 0.65
PredictMethod · 0.65

Tested by

no test coverage detected