Jina-16.py
· 430 B · Python
Eredeti
# Server
with Deployment(uses=TokenStreamingExecutor, port=12345, protocol='grpc') as dep:
dep.block()
# Client
async def main():
client = Client(port=12345, protocol='grpc', asyncio=True)
async for doc in client.stream_doc(
on='/stream',
inputs=PromptDocument(prompt='what is the capital of France ?', max_tokens=10),
return_type=ModelOutputDocument,
):
print(doc.generated_text)
1 | # Server |
2 | with Deployment(uses=TokenStreamingExecutor, port=12345, protocol='grpc') as dep: |
3 | dep.block() |
4 | |
5 | |
6 | # Client |
7 | async def main(): |
8 | client = Client(port=12345, protocol='grpc', asyncio=True) |
9 | async for doc in client.stream_doc( |
10 | on='/stream', |
11 | inputs=PromptDocument(prompt='what is the capital of France ?', max_tokens=10), |
12 | return_type=ModelOutputDocument, |
13 | ): |
14 | print(doc.generated_text) |