An integration package connecting Xinference and LangChain
Project description
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"})
chain.stream(input={"country": "France"}) # streaming data
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"})
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
Built Distribution
File details
Details for the file langchain_xinference-0.1.0.tar.gz
.
File metadata
- Download URL: langchain_xinference-0.1.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4415d1650be9743a1d6f71a2629095ef8e467ebad6a24fcce8f533c4a3cf9ddb |
|
MD5 | 35a306a6c5ecefa380a017f127436166 |
|
BLAKE2b-256 | eed1bda51c7a0e490e963998fe0fc9834c7476e39afb330e7a7128315696b4df |
File details
Details for the file langchain_xinference-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: langchain_xinference-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db859b1a3da0eed11b5d0f8269fdff72dfc1953f987ccda85d95b3850590029f |
|
MD5 | b39b8ddddc586296949705567029acb2 |
|
BLAKE2b-256 | ffa09e161d47820e1d895b61d343b24ebc01b3f8f447a56de34cd41d08ff9785 |