Skip to content

Commit 1874be7

Browse files
qihqilsy323
andauthored
Update README.md (#207)
* Update README.md add example for one request * Update README.md Co-authored-by: Siyuan Liu <[email protected]> --------- Co-authored-by: Siyuan Liu <[email protected]>
1 parent ec66526 commit 1874be7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,42 @@ of the `checkpoints/<org>/<model>/hf_original` dir (or the corresponding subdir
122122
Llama3 checkpoints will be at `checkpoints/meta-llama/Llama-2-7b-hf/hf_original/*.safetensors`. You can replace these files with modified
123123
weights in HuggingFace format.
124124

125+
## Send one request
126+
127+
Jetstream-pytorch uses gRPC for handling requests, the script below demonstrates how to
128+
send gRPC in Python. You can also use other gPRC clients.
129+
130+
```python
131+
import requests
132+
import os
133+
import grpc
134+
135+
from jetstream.core.proto import jetstream_pb2
136+
from jetstream.core.proto import jetstream_pb2_grpc
137+
138+
prompt = "What are the top 5 languages?"
139+
140+
channel = grpc.insecure_channel("localhost:8888")
141+
stub = jetstream_pb2_grpc.OrchestratorStub(channel)
142+
143+
request = jetstream_pb2.DecodeRequest(
144+
text_content=jetstream_pb2.DecodeRequest.TextContent(
145+
text=prompt
146+
),
147+
priority=0,
148+
max_tokens=2000,
149+
)
150+
151+
response = stub.Decode(request)
152+
output = []
153+
for resp in response:
154+
output.extend(resp.stream_content.samples[0].text)
155+
156+
text_output = "".join(output)
157+
print(f"Prompt: {prompt}")
158+
print(f"Response: {text_output}")
159+
```
160+
125161

126162
# Run the server with ray
127163
Below are steps run server with ray:

0 commit comments

Comments
 (0)