langchain-xinference
This package contains the LangChain integration with Xinference
Installation
pip install -U langchain-xinference
Dependence
Install Xinference by using pip as follows. (For more options, see Installation page.)
pip install "xinference[all]"
To start a local instance of Xinference, run the following command:
$ xinference-local
Chat Models
ChatXinference class exposes chat models from Xinference.
from langchain_xinference.chat_models import ChatXinference
from langchain.prompts import PromptTemplate
llm = ChatXinference(
server_url="http://0.0.0.0:9997", # replace your xinference server url
model_uid={model_uid} # replace model_uid with the model UID return from launching the model
)
prompt = PromptTemplate(input=["country"], template="Q: where can we visit in the capital of {country}? A:")
chain = prompt | llm
chain.invoke(input={"country": "France"})
ai_res = chain.stream(input={"country": "France"})
for chunk in ai_res:
print(chunk.content)
LLMs
Xinference class exposes LLMs from Xinference.
from langchain_xinference.llms import Xinference
from langchain.prompts import PromptTemplate
llm = Xinference(
server_url="http://0.0.0.0:9997", # replace your xinference server url
model_uid={model_uid} # replace model_uid with the model UID return from launching the model
)
prompt = PromptTemplate(input=["country"], template="Q: where can we visit in the capital of {country}? A:")
chain = prompt | llm
chain.invoke(input={"country": "France"})
ai_res = chain.stream(input={"country": "France"})
for chunk in ai_res:
print(chunk)
Metadata
Release files for langchain-xinference 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_xinference-0.1.1.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_xinference-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.4 kB
Release files / langchain_xinference-0.1.1.tar.gz
| Download URL | langchain_xinference-0.1.1.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6316da4582a8fed1cf5b9902af8ccbea2115f776ae5ae295e606fea23229db80
|
|
BLAKE2b-256 checksum How to use checksums |
bbe6058fc6714cc007f8861e8ad2e27a309f6f95d4e50dc8c69e9361e25d838e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.8
|
Release files / langchain_xinference-0.1.1-py3-none-any.whl
| Download URL | langchain_xinference-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9afd853842c70a3c5d7695ca9e7c8389fc014a0d7c2dac58b75657cdd9fb6c58
|
|
BLAKE2b-256 checksum How to use checksums |
935d7287d2d016131d725b1178c3592e77d0eb55acfdd65687438d3609fa0ee1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.8
|