Skip to main content

No project description provided

Project description

dat1-cli

PyPI - Version

A command line interface for the dat1 platform.

Installation

pip install dat1-cli

Usage

Initialize with your API key:

dat1 login

To initialize a new model project, run in the root directory of your project:

dat1 init

This will create a dat1.yaml file in the root directory of your project. This file contains the configuration for your model:

model_name: <your model name>
exclude:
  - '**/.git/**'
  - '**/.idea/**'
  - '*.md'
  - '*.jpg'
  - .dat1.yaml

Exclude uses glob patterns to exclude files from being uploaded to the platform.

To upload your model to the platform:

dat1 deploy

A good starting point for your model is using the example model.

Otherwise, the platform expects a handler.py file in the root directory of your project that contains a FastAPI app with two endpoints: GET / for healthchecks and POST /infer for inference. An example handler is shown below:

from fastapi import Request, FastAPI
from vllm import LLM, SamplingParams
import os

# Model initialization Code
# This code should be placed before the FastAPI app is initialized

llm = LLM(model=os.path.expanduser('./'), load_format="safetensors", enforce_eager=True)

app = FastAPI()

@app.get("/")
async def root():
    return "OK"

@app.post("/infer")
async def infer(request: Request):
    # Inference Code
    request = await request.json()
    prompts = request["prompt"]
    sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
    outputs = llm.generate(prompts, sampling_params)
    return { "response" : outputs[0].outputs[0].text }

Streaming Responses with Server-Sent Events

To stream responses to the client, you can use Server-Sent Events (SSE). To specify that the response should be streamed, you need to add response_type: sse to the model definition in the dat1.yaml file.

model_name: chat_completion
response_type: sse
exclude:
  - '**/.git/**'
  - '**/.idea/**'
  - '*.md'
  - '*.jpg'
  - .dat1.yaml

The handler code should be modified to return a generator that yields the responses:

from fastapi import Request, FastAPI
from sse_starlette.sse import EventSourceResponse
import json

app = FastAPI()

@app.get("/")
async def root():
    return "OK"

async def response_generator():
    for i in range(10):
        yield json.dumps({"response": f"Response {i}"})    

@app.post("/infer")
async def infer(request: Request):
    return EventSourceResponse(response_generator(), sep="\n")

Launching Locally

Pre-requisites

  • Docker
  • CUDA-compatible GPU
  • NVIDIA Container Toolkit

To launch your model locally, run:

dat1 serve

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dat1_cli-0.1.9.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dat1_cli-0.1.9-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file dat1_cli-0.1.9.tar.gz.

File metadata

  • Download URL: dat1_cli-0.1.9.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for dat1_cli-0.1.9.tar.gz
Algorithm Hash digest
SHA256 3224ed4918baad4d9e7b65d6983122a146c04db142339c6fdc0ff5a9dc2b751b
MD5 1d06fafe8b964b5f75b5087bc57bd60d
BLAKE2b-256 14639838843662e9e85b797ab25330e43303fe457f935b7973d3281177fc7a1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dat1_cli-0.1.9.tar.gz:

Publisher: publish.yml on dat1-co/dat1-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dat1_cli-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: dat1_cli-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for dat1_cli-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 40f120cc50dfc7ada97f3a2750636ef92ef34ef101720f47811a9deb26c288d1
MD5 932598f1645e513168bcbc843daeaa07
BLAKE2b-256 8dfb1a41037716e3fc9068132e256fb0f939f6ffd7b0e848bfa8a7272d42f93f

See more details on using hashes here.

Provenance

The following attestation bundles were made for dat1_cli-0.1.9-py3-none-any.whl:

Publisher: publish.yml on dat1-co/dat1-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page