No project description provided
Project description
dat1-cli
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
- .DS_Store
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 one of the example models.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dat1_cli-0.2.3.tar.gz.
File metadata
- Download URL: dat1_cli-0.2.3.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0626f5c0a6a19ce72861d2cd6317930c87de93b41f2b2964ba962d8ace4db474
|
|
| MD5 |
934a5e2c3e92d179cfe49fc2a38a620c
|
|
| BLAKE2b-256 |
5bd8d689e17a56db23bab4dfbd8b35f2afac25050a7a8beeb272bee5e2ad7b0b
|
Provenance
The following attestation bundles were made for dat1_cli-0.2.3.tar.gz:
Publisher:
publish.yml on dat1-co/dat1-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dat1_cli-0.2.3.tar.gz -
Subject digest:
0626f5c0a6a19ce72861d2cd6317930c87de93b41f2b2964ba962d8ace4db474 - Sigstore transparency entry: 672303511
- Sigstore integration time:
-
Permalink:
dat1-co/dat1-cli@6af5efbec5fb22f3e0f6ff0ff9601fdc07d65fa7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dat1-co
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6af5efbec5fb22f3e0f6ff0ff9601fdc07d65fa7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dat1_cli-0.2.3-py3-none-any.whl.
File metadata
- Download URL: dat1_cli-0.2.3-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dcc071702d0b56bfc661c26e66d81fbf2f1408ff37e74040b3c3abdd92ababe
|
|
| MD5 |
347162b7cba81ddf94e626387ff8ffda
|
|
| BLAKE2b-256 |
e0d973441f62cd9d851efe83ddf31877a75d11eaefb390a50b7e6038a0240588
|
Provenance
The following attestation bundles were made for dat1_cli-0.2.3-py3-none-any.whl:
Publisher:
publish.yml on dat1-co/dat1-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dat1_cli-0.2.3-py3-none-any.whl -
Subject digest:
1dcc071702d0b56bfc661c26e66d81fbf2f1408ff37e74040b3c3abdd92ababe - Sigstore transparency entry: 672303642
- Sigstore integration time:
-
Permalink:
dat1-co/dat1-cli@6af5efbec5fb22f3e0f6ff0ff9601fdc07d65fa7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dat1-co
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6af5efbec5fb22f3e0f6ff0ff9601fdc07d65fa7 -
Trigger Event:
push
-
Statement type: