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


Release history Release notifications | RSS feed

This version

2.8.0

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-2.8.0.tar.gz (58.6 kB view details)

Uploaded Source

Built Distribution

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

xinference_client-2.8.0-py3-none-any.whl (40.1 kB view details)

Uploaded Python 3

File details

Details for the file xinference_client-2.8.0.tar.gz.

File metadata

  • Download URL: xinference_client-2.8.0.tar.gz
  • Upload date:
  • Size: 58.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for xinference_client-2.8.0.tar.gz
Algorithm Hash digest
SHA256 40cb19f304b5a830cd58ef6b5b2ece35570c2bce6ed1c77289aa45b6fe747b11
MD5 f6ed5d2e375b21af03d6b80dd134579c
BLAKE2b-256 31f4ffb468d4ee1bcdfc446e50e0975a24babcdf3291605753f3f081e45f262d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xinference_client-2.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2bfe56a2ba84fe7697604e47361df208e0751397f4fd13a2901bb37703b3e00
MD5 796303ff5d6121f35ff64d57b9b4b7e1
BLAKE2b-256 7e05b6b408982c2ff68f9cdc4bcbbb841607aab7f2d1450b58a188925b4cd83c

See more details on using hashes here.

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