Format code & move functions (#155)
This commit is contained in:
@@ -12,6 +12,7 @@ import argparse
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def test_decode(url, return_logprob):
|
||||
response = requests.post(
|
||||
url + "/generate",
|
||||
@@ -27,6 +28,7 @@ def test_decode(url, return_logprob):
|
||||
)
|
||||
print(response.json())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--host", type=str, default="http://127.0.0.1")
|
||||
|
||||
@@ -12,6 +12,7 @@ import json
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def test_decode_stream(url, return_logprob):
|
||||
response = requests.post(
|
||||
url + "/generate",
|
||||
@@ -39,7 +40,7 @@ def test_decode_stream(url, return_logprob):
|
||||
assert data["meta_info"]["prompt_logprob"] is not None
|
||||
assert data["meta_info"]["token_logprob"] is not None
|
||||
assert data["meta_info"]["normalized_prompt_logprob"] is not None
|
||||
if prev == 0: # Skip prompt logprobs
|
||||
if prev == 0: # Skip prompt logprobs
|
||||
prev = data["meta_info"]["prompt_tokens"]
|
||||
for token_txt, _, logprob in data["meta_info"]["token_logprob"][prev:]:
|
||||
print(f"{token_txt}\t{logprob}", flush=True)
|
||||
@@ -50,6 +51,7 @@ def test_decode_stream(url, return_logprob):
|
||||
prev = len(output)
|
||||
print("")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--host", type=str, default="http://127.0.0.1")
|
||||
|
||||
@@ -64,9 +64,8 @@ def test_completion_stream(args, echo, logprobs):
|
||||
first = False
|
||||
if logprobs:
|
||||
print(
|
||||
f"{r.choices[0].text:12s}\t"
|
||||
f"{r.choices[0].logprobs.token_logprobs}",
|
||||
flush=True
|
||||
f"{r.choices[0].text:12s}\t" f"{r.choices[0].logprobs.token_logprobs}",
|
||||
flush=True,
|
||||
)
|
||||
else:
|
||||
print(r.choices[0].text, end="", flush=True)
|
||||
|
||||
Reference in New Issue
Block a user