Skip to main content

Client for Xinference

Project description

Xinference Restful Client

Xinference provides a restful client for managing and accessing models programmatically.

Install

pip install xinference-client

Usage

from xinference_client import RESTfulClient as Client

client = Client("http://localhost:9997")
model_uid = client.launch_model(model_name="chatglm2")
model = client.get_model(model_uid)

chat_history = []
prompt = "What is the largest animal?"
model.chat(
    prompt,
    chat_history=chat_history,
    generate_config={"max_tokens": 1024}
)

Result:

{
  "id": "chatcmpl-8d76b65a-bad0-42ef-912d-4a0533d90d61",
  "model": "56f69622-1e73-11ee-a3bd-9af9f16816c6",
  "object": "chat.completion",
  "created": 1688919187,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The largest animal that has been scientifically measured is the blue whale, which has a maximum length of around 23 meters (75 feet) for adult animals and can weigh up to 150,000 pounds (68,000 kg). However, it is important to note that this is just an estimate and that the largest animal known to science may be larger still. Some scientists believe that the largest animals may not have a clear \"size\" in the same way that humans do, as their size can vary depending on the environment and the stage of their life."
      },
      "finish_reason": "None"
    }
  ],
  "usage": {
    "prompt_tokens": -1,
    "completion_tokens": -1,
    "total_tokens": -1
  }
}

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

xinference-client-0.16.2.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

xinference_client-0.16.2-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file xinference-client-0.16.2.tar.gz.

File metadata

  • Download URL: xinference-client-0.16.2.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for xinference-client-0.16.2.tar.gz
Algorithm Hash digest
SHA256 dc40e1daa97b8eb9e5c1e199e95e5d7fd0a789f9f767db6c342987c0e2c2a2e1
MD5 4d61f77183ab1eed02f65c3c189d1585
BLAKE2b-256 c12681a91fb95e50c664a642a1e6c20fd00701f652a9cc8748c60ebc2fa7abd7

See more details on using hashes here.

File details

Details for the file xinference_client-0.16.2-py3-none-any.whl.

File metadata

File hashes

Hashes for xinference_client-0.16.2-py3-none-any.whl
Algorithm Hash digest
SHA256 69d62330c46a32d5ad0641fcaf46a7468d1da65e8cdde152289ba1781d689263
MD5 43fb21c4921353ad67d61a298f14a840
BLAKE2b-256 4912a5f25144cbe7fdd5b3e94bf57808f760635e268474db29a9b1d2ddcab7a1

See more details on using hashes here.

Supported by

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