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
}
}
Release files for xinference-client 3.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| xinference_client-3.4.0.tar.gz | 64.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xinference_client-3.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 108.6 kB
Release files / xinference_client-3.4.0.tar.gz
| Download URL | xinference_client-3.4.0.tar.gz |
|---|---|
| Size | 64.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33cdceda81c1dd8983a92380b91eae960ee36e110301de1fa8bb43459b1e9305
|
|
BLAKE2b-256 checksum How to use checksums |
15f1b737ba401b243855611e6f6be0cf66b649e1d33fc294be262ae9257ea84b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / xinference_client-3.4.0-py3-none-any.whl
| Download URL | xinference_client-3.4.0-py3-none-any.whl |
|---|---|
| Size | 44.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aeb1a6c927213e7336d3cd0b08b2ca330e5ae343f6765d01811ffc0bc50ac726
|
|
BLAKE2b-256 checksum How to use checksums |
e7ac3a3272b98428dfcb019a70e7dd3e571629e82b1a6b972300ae3ee1376337
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|