Skip to content

Commit

Permalink
Update README.md (#207)
Browse files Browse the repository at this point in the history
* Update README.md

add example for one request

* Update README.md

Co-authored-by: Siyuan Liu <lsiyuan@google.com>

---------

Co-authored-by: Siyuan Liu <lsiyuan@google.com>
  • Loading branch information
qihqi and lsy323 authored Jan 13, 2025
1 parent ec66526 commit 1874be7
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,42 @@ of the `checkpoints/<org>/<model>/hf_original` dir (or the corresponding subdir
Llama3 checkpoints will be at `checkpoints/meta-llama/Llama-2-7b-hf/hf_original/*.safetensors`. You can replace these files with modified
weights in HuggingFace format.

## Send one request

Jetstream-pytorch uses gRPC for handling requests, the script below demonstrates how to
send gRPC in Python. You can also use other gPRC clients.

```python
import requests
import os
import grpc

from jetstream.core.proto import jetstream_pb2
from jetstream.core.proto import jetstream_pb2_grpc

prompt = "What are the top 5 languages?"

channel = grpc.insecure_channel("localhost:8888")
stub = jetstream_pb2_grpc.OrchestratorStub(channel)

request = jetstream_pb2.DecodeRequest(
text_content=jetstream_pb2.DecodeRequest.TextContent(
text=prompt
),
priority=0,
max_tokens=2000,
)

response = stub.Decode(request)
output = []
for resp in response:
output.extend(resp.stream_content.samples[0].text)

text_output = "".join(output)
print(f"Prompt: {prompt}")
print(f"Response: {text_output}")
```


# Run the server with ray
Below are steps run server with ray:
Expand Down

0 comments on commit 1874be7

Please sign in to comment.