jina-3.9.3.dev9


توضیحات

Multimodal AI services & pipelines with cloud-native stack: gRPC, Kubernetes, Docker, OpenTelemetry, Prometheus, Jaeger, etc.
ویژگی مقدار
سیستم عامل OS Independent
نام فایل jina-3.9.3.dev9
نام jina
نسخه کتابخانه 3.9.3.dev9
نگهدارنده []
ایمیل نگهدارنده []
نویسنده Jina AI
ایمیل نویسنده hello@jina.ai
آدرس صفحه اصلی https://github.com/jina-ai/jina/
آدرس اینترنتی https://pypi.org/project/jina/
مجوز Apache 2.0
# Jina-Serve <a href="https://pypi.org/project/jina/"><img alt="PyPI" src="https://img.shields.io/pypi/v/jina?label=Release&style=flat-square"></a> <a href="https://discord.jina.ai"><img src="https://img.shields.io/discord/1106542220112302130?logo=discord&logoColor=white&style=flat-square"></a> <a href="https://pypistats.org/packages/jina"><img alt="PyPI - Downloads from official pypistats" src="https://img.shields.io/pypi/dm/jina?style=flat-square"></a> <a href="https://github.com/jina-ai/jina/actions/workflows/cd.yml"><img alt="Github CD status" src="https://github.com/jina-ai/jina/actions/workflows/cd.yml/badge.svg"></a> Jina-serve is a framework for building and deploying AI services that communicate via gRPC, HTTP and WebSockets. Scale your services from local development to production while focusing on your core logic. ## Key Features - Native support for all major ML frameworks and data types - High-performance service design with scaling, streaming, and dynamic batching - LLM serving with streaming output - Built-in Docker integration and Executor Hub - One-click deployment to Jina AI Cloud - Enterprise-ready with Kubernetes and Docker Compose support <details> <summary><strong>Comparison with FastAPI</strong></summary> Key advantages over FastAPI: - DocArray-based data handling with native gRPC support - Built-in containerization and service orchestration - Seamless scaling of microservices - One-command cloud deployment </details> ## Install ```bash pip install jina ``` See guides for [Apple Silicon](https://jina.ai/serve/get-started/install/apple-silicon-m1-m2/) and [Windows](https://jina.ai/serve/get-started/install/windows/). ## Core Concepts Three main layers: - **Data**: BaseDoc and DocList for input/output - **Serving**: Executors process Documents, Gateway connects services - **Orchestration**: Deployments serve Executors, Flows create pipelines ## Build AI Services Let's create a gRPC-based AI service using StableLM: ```python from jina import Executor, requests from docarray import DocList, BaseDoc from transformers import pipeline class Prompt(BaseDoc): text: str class Generation(BaseDoc): prompt: str text: str class StableLM(Executor): def __init__(self, **kwargs): super().__init__(**kwargs) self.generator = pipeline( 'text-generation', model='stabilityai/stablelm-base-alpha-3b' ) @requests def generate(self, docs: DocList[Prompt], **kwargs) -> DocList[Generation]: generations = DocList[Generation]() prompts = docs.text llm_outputs = self.generator(prompts) for prompt, output in zip(prompts, llm_outputs): generations.append(Generation(prompt=prompt, text=output)) return generations ``` Deploy with Python or YAML: ```python from jina import Deployment from executor import StableLM dep = Deployment(uses=StableLM, timeout_ready=-1, port=12345) with dep: dep.block() ``` ```yaml jtype: Deployment with: uses: StableLM py_modules: - executor.py timeout_ready: -1 port: 12345 ``` Use the client: ```python from jina import Client from docarray import DocList from executor import Prompt, Generation prompt = Prompt(text='suggest an interesting image generation prompt') client = Client(port=12345) response = client.post('/', inputs=[prompt], return_type=DocList[Generation]) ``` ## Build Pipelines Chain services into a Flow: ```python from jina import Flow flow = Flow(port=12345).add(uses=StableLM).add(uses=TextToImage) with flow: flow.block() ``` ## Scaling and Deployment ### Local Scaling Boost throughput with built-in features: - Replicas for parallel processing - Shards for data partitioning - Dynamic batching for efficient model inference Example scaling a Stable Diffusion deployment: ```yaml jtype: Deployment with: uses: TextToImage timeout_ready: -1 py_modules: - text_to_image.py env: CUDA_VISIBLE_DEVICES: RR replicas: 2 uses_dynamic_batching: /default: preferred_batch_size: 10 timeout: 200 ``` ### Cloud Deployment #### Containerize Services 1. Structure your Executor: ``` TextToImage/ ├── executor.py ├── config.yml ├── requirements.txt ``` 2. Configure: ```yaml # config.yml jtype: TextToImage py_modules: - executor.py metas: name: TextToImage description: Text to Image generation Executor ``` 3. Push to Hub: ```bash jina hub push TextToImage ``` #### Deploy to Kubernetes ```bash jina export kubernetes flow.yml ./my-k8s kubectl apply -R -f my-k8s ``` #### Use Docker Compose ```bash jina export docker-compose flow.yml docker-compose.yml docker-compose up ``` #### JCloud Deployment Deploy with a single command: ```bash jina cloud deploy jcloud-flow.yml ``` ## LLM Streaming Enable token-by-token streaming for responsive LLM applications: 1. Define schemas: ```python from docarray import BaseDoc class PromptDocument(BaseDoc): prompt: str max_tokens: int class ModelOutputDocument(BaseDoc): token_id: int generated_text: str ``` 2. Initialize service: ```python from transformers import GPT2Tokenizer, GPT2LMHeadModel class TokenStreamingExecutor(Executor): def __init__(self, **kwargs): super().__init__(**kwargs) self.model = GPT2LMHeadModel.from_pretrained('gpt2') ``` 3. Implement streaming: ```python @requests(on='/stream') async def task(self, doc: PromptDocument, **kwargs) -> ModelOutputDocument: input = tokenizer(doc.prompt, return_tensors='pt') input_len = input['input_ids'].shape[1] for _ in range(doc.max_tokens): output = self.model.generate(**input, max_new_tokens=1) if output[0][-1] == tokenizer.eos_token_id: break yield ModelOutputDocument( token_id=output[0][-1], generated_text=tokenizer.decode( output[0][input_len:], skip_special_tokens=True ), ) input = { 'input_ids': output, 'attention_mask': torch.ones(1, len(output[0])), } ``` 4. Serve and use: ```python # 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) ``` ## Support Jina-serve is backed by [Jina AI](https://jina.ai) and licensed under [Apache-2.0](./LICENSE).


نیازمندی

مقدار نام
latform_syste uvloop;
- pyyaml>=5.3.1
- grpcio-health-checking<=1.68.0,>=1.46.0
- jcloud>=0.0.35
- opentelemetry-exporter-otlp>=1.12.0
- prometheus_client>=0.12.0
- protobuf>=3.19.0
- pydantic<3.0.0
- urllib3<2.0.0,>=1.25.9
- grpcio<=1.68.0,>=1.46.0
- opentelemetry-sdk>=1.14.0
- pathspec
- opentelemetry-instrumentation-aiohttp-client>=0.33b0
- opentelemetry-exporter-prometheus>=0.33b0
- requests
- websockets
- grpcio-reflection<=1.68.0,>=1.46.0
- docarray>=0.16.4
- opentelemetry-exporter-otlp-proto-grpc>=1.13.0
- uvicorn<=0.23.1
- opentelemetry-instrumentation-fastapi>=0.33b0
- docker
- aiofiles
- fastapi>=0.76.0
- numpy
- opentelemetry-instrumentation-grpc>=0.35b0
- aiohttp
- filelock
- python-multipart
- jina-hubble-sdk>=0.30.4
- opentelemetry-api>=1.12.0
- packaging>=20.0
xtr opentelemetry-instrumentation-grpc>=0.35b0;
xtr pyyaml>=5.3.1;
xtr numpy;
xtr grpcio-health-checking<=1.68.0,>=1.46.0;
xtr jcloud>=0.0.35;
xtr protobuf>=3.19.0;
xtr grpcio-reflection<=1.68.0,>=1.46.0;
xtr pydantic<3.0.0;
xtr docarray>=0.16.4;
xtr urllib3<2.0.0,>=1.25.9;
xtr jina-hubble-sdk>=0.30.4;
xtr opentelemetry-api>=1.12.0;
xtr packaging>=20.0;
xtr grpcio<=1.68.0,>=1.46.0;
xtr numpy;
xtr protobuf>=3.19.0;
xtr grpcio<=1.68.0,>=1.46.0;
xtr grpcio-reflection<=1.68.0,>=1.46.0;
xtr grpcio-health-checking<=1.68.0,>=1.46.0;
xtr pyyaml>=5.3.1;
xtr packaging>=20.0;
xtr docarray>=0.16.4;
xtr jina-hubble-sdk>=0.30.4;
xtr jcloud>=0.0.35;
xtr opentelemetry-api>=1.12.0;
xtr opentelemetry-instrumentation-grpc>=0.35b0;
xtr opentelemetry-exporter-prometheus>=0.33b0;
xtr opentelemetry-exporter-otlp>=1.12.0;
xtr prometheus_client>=0.12.0;
xtr opentelemetry-exporter-otlp-proto-grpc>=1.13.0;
xtr uvloop;
xtr opentelemetry-instrumentation-fastapi>=0.33b0;
xtr opentelemetry-sdk>=1.14.0;
xtr opentelemetry-instrumentation-aiohttp-client>=0.33b0;
latform_syste uvloop;
xtr sgqlc;
xtr opentelemetry-exporter-otlp>=1.12.0;
xtr prometheus_client>=0.12.0;
xtr opentelemetry-sdk>=1.14.0;
xtr pathspec;
xtr opentelemetry-instrumentation-aiohttp-client>=0.33b0;
xtr opentelemetry-exporter-prometheus>=0.33b0;
xtr requests;
xtr websockets;
xtr opentelemetry-exporter-otlp-proto-grpc>=1.13.0;
xtr uvicorn<=0.23.1;
xtr opentelemetry-instrumentation-fastapi>=0.33b0;
xtr docker;
xtr strawberry-graphql>=0.96.0;
xtr aiofiles;
xtr fastapi>=0.76.0;
xtr aiohttp;
xtr filelock;
xtr python-multipart;
xtr watchfiles>=0.18.0;
xtr uvloop;
xtr opentelemetry-exporter-prometheus>=0.33b0;
xtr aiohttp;
xtr requests;
xtr filelock;
xtr opentelemetry-exporter-otlp>=1.12.0;
xtr prometheus_client>=0.12.0;
xtr websockets;
xtr python-multipart;
xtr uvloop;
xtr uvicorn<=0.23.1;
xtr opentelemetry-instrumentation-fastapi>=0.33b0;
xtr docker;
xtr opentelemetry-sdk>=1.14.0;
xtr pathspec;
xtr aiofiles;
xtr opentelemetry-instrumentation-aiohttp-client>=0.33b0;
xtr fastapi>=0.76.0;
xtr prometheus_client>=0.12.0;
xtr opentelemetry-sdk>=1.14.0;
xtr opentelemetry-exporter-otlp>=1.12.0;
xtr opentelemetry-exporter-prometheus>=0.33b0;
xtr opentelemetry-instrumentation-aiohttp-client>=0.33b0;
xtr opentelemetry-instrumentation-fastapi>=0.33b0;
xtr opentelemetry-exporter-otlp-proto-grpc>=1.13.0;
xtr opentelemetry-exporter-otlp-proto-grpc>=1.13.0;
xtr fastapi>=0.76.0;
xtr uvicorn<=0.23.1;
xtr docker;
xtr pathspec;
xtr filelock;
xtr requests;
xtr websockets;
xtr pydantic<3.0.0;
xtr python-multipart;
xtr aiofiles;
xtr aiohttp;
xtr pytest-mock;
xtr pytest-kind==22.11.1;
xtr prometheus-api-client>=0.5.1;
xtr coverage==6.2;
xtr pytest-timeout;
xtr pytest-lazy-fixture;
xtr requests-mock;
xtr pytest-cov==3.0.0;
xtr kubernetes<31.0.0,>=18.20.0;
xtr pytest-asyncio<0.23.0;
xtr black==24.3.0;
xtr pytest-custom_exit_code;
xtr flaky;
xtr pytest-reraise;
xtr Pillow;
xtr opentelemetry-test-utils>=0.33b0;
xtr psutil;
xtr pytest<8.0.0;
xtr pytest-repeat;
xtr scipy>=1.6.1;
xtr mock;
xtr scipy>=1.6.1;
xtr Pillow;
xtr pytest<8.0.0;
xtr pytest-timeout;
xtr pytest-mock;
xtr pytest-cov==3.0.0;
xtr coverage==6.2;
xtr pytest-repeat;
xtr pytest-asyncio<0.23.0;
xtr pytest-reraise;
xtr flaky;
xtr mock;
xtr requests-mock;
xtr pytest-custom_exit_code;
xtr black==24.3.0;
xtr kubernetes<31.0.0,>=18.20.0;
xtr pytest-kind==22.11.1;
xtr pytest-lazy-fixture;
xtr portforward<0.4.3,>=0.2.4;
xtr torch;
xtr sgqlc;
xtr bs4;
xtr tensorflow>=2.0;
xtr strawberry-graphql>=0.96.0;
xtr jsonschema;
xtr torch;
xtr psutil;
xtr strawberry-graphql>=0.96.0;
xtr sgqlc;
xtr bs4;
xtr jsonschema;
xtr portforward<0.4.3,>=0.2.4;
xtr tensorflow>=2.0;
xtr opentelemetry-test-utils>=0.33b0;
xtr prometheus-api-client>=0.5.1;
xtr watchfiles>=0.18.0;
xtr urllib3<2.0.0,>=1.25.9;
xtr pytest-mock;
xtr pytest-kind==22.11.1;
latform_syste uvloop;
xtr pyyaml>=5.3.1;
xtr grpcio-health-checking<=1.68.0,>=1.46.0;
xtr prometheus-api-client>=0.5.1;
xtr jcloud>=0.0.35;
xtr protobuf>=3.19.0;
xtr pydantic<3.0.0;
xtr opentelemetry-exporter-otlp>=1.12.0;
xtr prometheus_client>=0.12.0;
xtr urllib3<2.0.0,>=1.25.9;
xtr sgqlc;
xtr bs4;
xtr coverage==6.2;
xtr grpcio<=1.68.0,>=1.46.0;
xtr pytest-timeout;
xtr torch;
xtr pytest-lazy-fixture;
xtr requests-mock;
xtr opentelemetry-sdk>=1.14.0;
xtr pathspec;
xtr opentelemetry-instrumentation-aiohttp-client>=0.33b0;
xtr jsonschema;
xtr opentelemetry-exporter-prometheus>=0.33b0;
xtr portforward<0.4.3,>=0.2.4;
xtr requests;
xtr opentelemetry-api>=1.12.0;
xtr pytest-cov==3.0.0;
xtr grpcio-reflection<=1.68.0,>=1.46.0;
xtr websockets;
xtr docarray>=0.16.4;
xtr opentelemetry-exporter-otlp-proto-grpc>=1.13.0;
xtr uvicorn<=0.23.1;
xtr opentelemetry-instrumentation-fastapi>=0.33b0;
xtr kubernetes<31.0.0,>=18.20.0;
xtr pytest-asyncio<0.23.0;
xtr docker;
xtr strawberry-graphql>=0.96.0;
xtr aiofiles;
xtr black==24.3.0;
xtr fastapi>=0.76.0;
xtr pytest-custom_exit_code;
xtr numpy;
xtr flaky;
xtr pytest-reraise;
xtr opentelemetry-instrumentation-grpc>=0.35b0;
xtr Pillow;
xtr aiohttp;
xtr opentelemetry-test-utils>=0.33b0;
xtr psutil;
xtr filelock;
xtr python-multipart;
xtr pytest<8.0.0;
xtr tensorflow>=2.0;
xtr pytest-repeat;
xtr jina-hubble-sdk>=0.30.4;
xtr scipy>=1.6.1;
xtr packaging>=20.0;
xtr mock;
xtr watchfiles>=0.18.0;


نحوه نصب


نصب پکیج whl jina-3.9.3.dev9:

    pip install jina-3.9.3.dev9.whl


نصب پکیج tar.gz jina-3.9.3.dev9:

    pip install jina-3.9.3.dev9.tar.gz