Please write an extremely detailed and vivid fantasy story, set in a world full of intricate magic systems, political intrigue, and complex characters.
Ensure that you thoroughly describe every scene, character's motivations, and the environment. Include long, engaging dialogues and elaborate on the inner thoughts of the characters.
Each section should be as comprehensive as possible to create a rich and immersive experience for the reader.
The story should span multiple events, challenges, and character developments over time. Aim to make the story at least 3,000 words long.
"""
classMatchedStopMixin:
def_run_completions_generation(
self,
prompt=MANY_NEW_TOKENS_PROMPT,
max_tokens=1,
stop=None,
stop_regex=None,
finish_reason=None,
matched_stop=None,
):
payload={
"prompt":prompt,
"model":self.model,
"temperature":0,
"top_p":1,
"max_tokens":max_tokens,
}
ifstopisnotNone:
payload["stop"]=stop
ifstop_regexisnotNone:
payload["stop_regex"]=stop_regex
response_completions=requests.post(
self.base_url+"/v1/completions",
json=payload,
)
res=response_completions.json()
print(json.dumps(res))
print("="*100)
ifnotisinstance(matched_stop,list):
matched_stop=[matched_stop]
assert(
res["choices"][0]["finish_reason"]==finish_reason
),f"Expected finish_reason: {finish_reason}, but got: {res['choices'][0]['finish_reason']}"
assert(
res["choices"][0]["matched_stop"]inmatched_stop
),f"Expected matched_stop: {matched_stop}, but got: {res['choices'][0]['matched_stop']}"
def_run_chat_completions_generation(
self,
prompt=MANY_NEW_TOKENS_PROMPT,
max_tokens=1,
stop=None,
stop_regex=None,
finish_reason=None,
matched_stop=None,
):
chat_payload={
"model":self.model,
"messages":[
{"role":"system","content":"You are a helpful AI assistant"},
{"role":"user","content":prompt},
],
"temperature":0,
"top_p":1,
"max_tokens":max_tokens,
}
ifstopisnotNone:
chat_payload["stop"]=stop
ifstop_regexisnotNone:
chat_payload["stop_regex"]=stop_regex
response_chat=requests.post(
self.base_url+"/v1/chat/completions",
json=chat_payload,
)
res=response_chat.json()
print(json.dumps(res))
print("="*100)
ifnotisinstance(matched_stop,list):
matched_stop=[matched_stop]
assert(
res["choices"][0]["finish_reason"]==finish_reason
),f"Expected finish_reason: {finish_reason}, but got: {res['choices'][0]['finish_reason']}"
assert(
res["choices"][0]["matched_stop"]inmatched_stop
),f"Expected matched_stop: {matched_stop}, but got: {res['choices'][0]['matched_stop']}"
@@ -12,15 +10,8 @@ from sglang.test.test_utils import (
...
@@ -12,15 +10,8 @@ from sglang.test.test_utils import (
popen_launch_server,
popen_launch_server,
)
)
MANY_NEW_TOKENS_PROMPT="""
Please write an extremely detailed and vivid fantasy story, set in a world full of intricate magic systems, political intrigue, and complex characters.
Ensure that you thoroughly describe every scene, character's motivations, and the environment. Include long, engaging dialogues and elaborate on the inner thoughts of the characters.
Each section should be as comprehensive as possible to create a rich and immersive experience for the reader.
The story should span multiple events, challenges, and character developments over time. Aim to make the story at least 3,000 words long.