Files
ColossalAI/examples/inference/serving/ray_serve/send_requests.py
Yuanheng Zhao 573f270537 [Infer] Serving example w/ ray-serve (multiple GPU case) (#4841)
* fix imports

* add ray-serve with Colossal-Infer tp

* trivial: send requests script

* add README

* fix worker port

* fix readme

* use app builder and autoscaling

* trivial: input args

* clean code; revise readme

* testci (skip example test)

* use auto model/tokenizer

* revert imports fix (fixed in other PRs)
2023-10-02 17:48:38 +08:00

28 lines
764 B
Python

import ray
import requests
@ray.remote
def send_query(text):
resp = requests.get("http://localhost:8000/?text={}".format(text))
return resp.text
test_sentences = [
"Introduce some landmarks in Beijing",
"What is the weather today",
"Coding requires practice and patience",
"Rainy days inspire cozy reading",
"Laughter is contagious and heartwarming",
"Hiking mountains builds strength and resilience",
"Family bonds grow stronger with time",
"Science unlocks mysteries of the universe",
"Music soothes the soul and ignites passion",
"Artistic expression knows no boundaries",
]
results = ray.get([send_query.remote(text) for text in test_sentences])
print("Result returned:")
for res in results:
print(res)