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
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-1.0.0.tar.gz
(44.3 kB
view details)
Built Distribution
File details
Details for the file xinference-client-1.0.0.tar.gz
.
File metadata
- Download URL: xinference-client-1.0.0.tar.gz
- Upload date:
- Size: 44.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9abad5623dbfd82bd3c12f7263f4da914b14c3c19c81a97373a5e7552157ae67 |
|
MD5 | 390f94aeee98250a31740e747ddb9e3d |
|
BLAKE2b-256 | 606004eb084ea70afef4645e8f9b3d691219ff0c2dfa97cb6d0a999379157ed7 |
File details
Details for the file xinference_client-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: xinference_client-1.0.0-py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4bd011b2d447bc44bf8589f04a6ab3ba543b6d127b88e6c1a64b1a1094d8722 |
|
MD5 | 4bd770d14594be80ca21f02d5fc04b46 |
|
BLAKE2b-256 | fb8014cc8f989f1271a5a33c9be074572cde3ac7f4896de5643ce1cd7585228e |